DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Insert line into text file possible with TextFileWriteLn?

I have some automatic DIAdem scripts running on a server and am generating a log file each time the script runs and something important happens.  Currently, I am writing new lines to this log file at the end of the file.  Is is possible to write new lines at the beginning of the file, or to insert lines rather than append to the file?  It would be nice to have the most recent events at the top of the page.  I hope this is a simple question that I am just completely missing!
 
Thanks!
 
Julia
0 Kudos
Message 1 of 2
(3,593 Views)
maybe this workaround helps you:

Dim intHandleNew, strTextNew, intErrorNew
Dim intHandleOld, strMyTextOld, intErrorOld

intHandleNew = TextFileOpen("c:\test.asc",tfCreate)
intTextNew= TextfileWriteLn(intHandleNew,"1 first line")
intTextNew= TextfileWriteLn(intHandleNew,"2 second line")
intErrorNew = TextFileClose(intHandleNew)

Call FileCopy("c:\test.asc","c:\test.old")
intHandleNew = TextFileOpen("c:\test.asc",tfCreate)
intTextNew= TextfileWriteLn(intHandleNew,"new Line")

intHandleOld = TextFileOpen("c:\test.old",tfRead)
Do While Not TextFileEOF(intHandleOld)
strTextNew = TextFileReadLn(intHandleOld)
intTextNew= TextfileWriteLn(intHandleNew,strTextNew)
loop

intErrorNew = TextFileClose(intHandleNew)
intErrorOld = TextFileClose(intHandleOld)
call FileDelete("c:\test.old", 1)

Andreas
0 Kudos
Message 2 of 2
(3,582 Views)