简体   繁体   中英

Openedge add text at the beginning of an existing text file

Found some kb on append text at the end of an xml file

https://knowledgebase.progress.com/articles/Article/P8379

OUTPUT TO VALUE ("cust.xml") APPEND.
/* Append a new line character to the end of the file */
PUT UNFORMATTED "~n ".
/* Append some text after the new line character */
PUT UNFORMATTED "this is the appended text".
OUTPUT CLOSE.

is there similar solution to add text at the beginning? or I have to resort to import the file and rewriting it to a new file?

thank you

You are going to have to read it and re-write it. This is one way to do it:

define variable fileBody as longchar no-undo.

copy-lob from file "test" to fileBody.

fileBody = "new first line~n" + fileBody.

copy-lob from fileBody to file "test".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM