MyFlight
Technical User
- Feb 4, 2002
- 193
I am trying to write between 1 and 3 items to a file, on a certian line.
For example I open TEST.TXT (which contains a list of 5 Numbers). I want to add comments after the Numbers.
Example:
TEST.TXT
1234
1235
1236
Revised file (or a New File)
1234 Changed 123456
1235 UNCHANGED No Change
1236 Changed 123456
I know how to open the File (or Files) with fopen (READ and/or READ/WRITE). When I use the fputs or fwrite command it put the TEXT on the 1st line only.
Any Suggestions
For example I open TEST.TXT (which contains a list of 5 Numbers). I want to add comments after the Numbers.
Example:
TEST.TXT
1234
1235
1236
Revised file (or a New File)
1234 Changed 123456
1235 UNCHANGED No Change
1236 Changed 123456
Code:
proc main
string szNewPswd,szSiteName,sTok1,sLine
string Fname = "Completed"
string Sname = ".txt"
sdlginput "Site Name" "Enter Site Name:" szSiteName
set szNewPswd = "123456"
strcat Fname szSiteName
strcat fname Sname
if isfile "C:\Temp Data Files\Raw Data\My Site.txt"
fopen 1 "C:\Temp Data Files\Raw Data\My Site.txt" READ TEXT
fopen 2 Fname CREATE
while not feof 1
fgets 1 sLine
strtok sTok1 sLine "," 1
strreplace sLine " " " "
fputs 2 sTok1
fputs 2 "CHANGED "
fputs 2 szNewPswd
endwhile
endif
fclose 1
fclose 2
endproc
I know how to open the File (or Files) with fopen (READ and/or READ/WRITE). When I use the fputs or fwrite command it put the TEXT on the 1st line only.
Any Suggestions