not sure I get what you are talking about? Let me see:Zood wrote:I have set my URL into a variable: CONTENTS
I have added a line to the URL and the line itself shows itself on a field in which i have put the contents of CONTENTS: So far so good!
So you have put the contents of the file "Contents.csv" into a variable, right?
Then you have put the varialbe into a field named "CONTENTS".
To what URL have you added a line? Or do you mean the field?
And what on earth means " the line itself shows itself on a field..."?
OK, next:
The result of these commands will probably surprise you, please think about this again.Zood wrote:Code: Select all
... put the hilitedline of field "CONTENTS" into tContents ## puts the line-number of the hilitedline into tContents delete line tContents of field "CONTENTS" ## deletes the line which was highlighted from the selected field only, not from the URL put line tContents of field "CONTENTS" into tContents3 ...
Hint: it has to to with the order of the commands.

If field "contents" now has the content that you would also to be in the file "Contents.csv",
then why not just write the field back into the file?
Code: Select all
...
put fld "CONTENTS" into url ("file:" & specialFolderPath("desktop") & "/CONTENTS.csv")
## Done!
...
1. Do not use a repat loop on a FILE.Zood wrote:Code: Select all
... repeat for each line tContents2 in url ("file:" & specialFolderPath("desktop") & "/CONTENTS.csv") if tContents2 = tContents3 then delete line tContents2 in url ("file:" & specialFolderPath("desktop") & "/CONTENTS.csv") end if end repeat ...
Put it into a variable first, compute the variable and then write the variable back to file, this is MUCH faster!
2. tContents2 contains the CONTENT Of that line and NOT the line number, so this does not work of course:
Code: Select all
...
delete line tContents2 in url...
...
Code: Select all
...
put line tContents of field "CONTENTS" into tContents3
put url ("file:" & specialFolderPath("desktop") & "/CONTENTS.csv") into tFile
## Since repeat for each does NOT supply any line number, we need to maintain a counter by ourselves
put 0 into tCounter
repeat for each line tContents2 in tFile
add 1 to tCounter
if tContents2 = tContents3 then
## Found the line, no need to progress!
exit repeat
end if
end repeat
## Now delete the line of the variable and...
delete line tCounter of tFile
### write it back to file.
put tFile into url("file:" & specialFolderPath("desktop") & "/CONTENTS.csv")
...
Klaus