Hello all,
I'm trying to add a section of code to a script I have written.
the script I have looks through a comma seperated file for a certian (unique) value, when it find that value, do some processing on that value. I need to add a section to then delete it from the file. (Unlike my last question, this line appears anywhere in the file)
At the point that I'm at, i've already read the line, so the file pointer is at the next line.
Here is the bit of code i've come up with:
Assumptions
savestring is the line I read (the file I'm trying to delete the lines out of was opened READWRITE TEXT)
iLen is a Interger
the two files exist, and (for test purposes)the same number of lines exist in each. There are 3 lines in each file. When the scrip finishes execution, there should be no lines in file ID 4.
file ID 4 contains this at start of execution
8005,156 0 0 1
8006,156 0 0 2
8007,156 0 0 3
The following code is called when my all of my processing has finished based on the info it found.
Of course, this doesn't work the way I want it to. I highly suspect it's because I'm subtracting a integer from a long.
The results I get are as follows.
Remember the two files had the same lines in them, so one should be empty when this is executed, but I have this instead. (the format of the file is two comma separated feilds, it appears that one character of one line is left over, and one entire line is also leftover, and appended to that leftover character) I am assuming it is the first character from the first line, and that is the complete 3rd line.
88007,156 0 0 3
That being said... Ummm help? (sorry for the lenght, I just wanted to provide all the info I've got)
I'm trying to add a section of code to a script I have written.
the script I have looks through a comma seperated file for a certian (unique) value, when it find that value, do some processing on that value. I need to add a section to then delete it from the file. (Unlike my last question, this line appears anywhere in the file)
At the point that I'm at, i've already read the line, so the file pointer is at the next line.
Here is the bit of code i've come up with:
Assumptions
savestring is the line I read (the file I'm trying to delete the lines out of was opened READWRITE TEXT)
iLen is a Interger
the two files exist, and (for test purposes)the same number of lines exist in each. There are 3 lines in each file. When the scrip finishes execution, there should be no lines in file ID 4.
file ID 4 contains this at start of execution
8005,156 0 0 1
8006,156 0 0 2
8007,156 0 0 3
The following code is called when my all of my processing has finished based on the info it found.
Code:
strlen savestring iLen
ftell 4 fileposition
fileposition=fileposition-iLen
fseek 4 fileposition 1
if success
fdelblock 4 iLen
if failure
strfmt DEBUG_MSG "ERROR DELETING TN!!"
fputs 2 DEBUG_MSG
endif
endif
Of course, this doesn't work the way I want it to. I highly suspect it's because I'm subtracting a integer from a long.
The results I get are as follows.
Remember the two files had the same lines in them, so one should be empty when this is executed, but I have this instead. (the format of the file is two comma separated feilds, it appears that one character of one line is left over, and one entire line is also leftover, and appended to that leftover character) I am assuming it is the first character from the first line, and that is the complete 3rd line.
88007,156 0 0 3
That being said... Ummm help? (sorry for the lenght, I just wanted to provide all the info I've got)