Author Topic: APPEND vs. APPEND_FILE  (Read 385 times)

Offline subtledoctor

  • Planewalker
  • *****
  • Posts: 75
APPEND vs. APPEND_FILE
« on: March 31, 2017, 09:18:44 AM »
The APPEND action has some nice underlying code which makes sure the appended text appears immediate following the bottom-most row of the subject file. Meanwhile, the APPEND_FILE patch command has nothing like that, which can result in text being added to the right side of the last row, instead of below it; or, if you try to control for that by adding a carriage return to the text to be appended, you can end up with blank lines in the middle of the subject file.

Camdawg has written a separate "Remove_Blank_Lines" function which helps with this, but lately it has been causing occasional install errors, for reasons I cannot determine.

It sure would be nice if APPEND_FILE has the same ability to handle to that APPEND has...

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 883
Re: APPEND vs. APPEND_FILE
« Reply #1 on: April 08, 2017, 08:19:43 AM »
Is your problem that APPEND_FILE is a straight concatenation of strings or that APPEND can only append to files in the override?

Offline subtledoctor

  • Planewalker
  • *****
  • Posts: 75
Re: APPEND vs. APPEND_FILE
« Reply #2 on: April 09, 2017, 05:30:46 PM »
2 issues.

1) There is no APPEND patch.

2) The closest thing, APPEND_FILE, does not have this functionality:
Quote
If KEEP_CRLF is not present, double newlines in the file (but not in newText) will be removed; otherwise, they’re kept.
In any event, if the file ends with CRLF only newText and an ending CRLF will be written; otherwise, if the file does not end with CRLF, it will be written before newText.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 883
Re: APPEND vs. APPEND_FILE
« Reply #3 on: April 21, 2017, 12:12:49 PM »
I can probably swing a TEXT option for APPEND_FILE that ensures that what's appended is separated by at least one newline from that to which it is appended. Would this be satisfactory? Or do you want the optional removal of already present multiple line breaks, as well? (NB. TEXT would not by itself cause any multiple line breaks.) I am personally inclined to say that mutations of appended text or appended-to text is not within the scope of an append function and if you want that, you should write something for that explicit purpose.

I should also mention that, on account of this issue, WeiDU will henceforth only introduce features dealing in LF and if I want to fix the aforementioned bug, I will probably need to convert usage of CRLF (say, by APPEND) into LF.
« Last Edit: April 21, 2017, 12:20:11 PM by Wisp »

Offline subtledoctor

  • Planewalker
  • *****
  • Posts: 75
Re: APPEND vs. APPEND_FILE
« Reply #4 on: May 15, 2017, 10:29:32 AM »
I can probably swing a TEXT option for APPEND_FILE that ensures that what's appended is separated by at least one newline from that to which it is appended ... (NB. TEXT would not by itself cause any multiple line breaks.)

I would love to see exactly this. If there is already a newline, ignore it; if there isn't, add one. And if there are multiple newlines, leave them as is because they are presumably intentional.

For me personally, the main issue is with .2da files: many end with newlines, and many others don't. Appending text to the bottom in a patch situation is therefore unreliable and requires workarounds which are themselves prone to failure.

Quote
I should also mention that, on account of this issue, WeiDU will henceforth only introduce features dealing in LF and if I want to fix the aforementioned bug, I will probably need to convert usage of CRLF (say, by APPEND) into LF.

I guess I'm not sure what the preferred standard is here. In early iterations of my mods my text files (created on a Mac) did not preserve newlines and I was getting mangled .2da files. I vaguely recall someone telling me the text files need to be CRLF, or maybe they said "Windows-style" newlines. So I switched everything over to CRLF and all of my .tp2, .tpa, and .txt files since then have been coded as CRLF. (And they all seems to be working well at the moment.) Official word as to how these files should be encoded is probably a good idea, since lots of new modders are springing up and Windows is no longer as monolithic as it was.

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 883
Re: APPEND vs. APPEND_FILE
« Reply #5 on: May 20, 2017, 07:08:34 PM »
Coded.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: