Delete item won't work in Repeat for each loop

Ian McKnight iangmcknight at googlemail.com
Wed May 24 17:35:08 EDT 2006


Hi all

I have a text file of 60 or so return delimited lines each containing
17 comma delimited items. I wrote a script to read the file into a
variable called theImportedData, delete 2 records, alter a 3rd,
display the results in a field and then save the file again.

I came up with the followiing two handlers. Both are executed by Rev
Media but removeFields1 doesn't do anything! ie the delete lines do
not alter the file. removeFields2 does what its supposed to do.

on removeFields1
  repeat for each line theRecord in theImportedData
    delete the last item of theRecord
    delete word 2 of item 10 of theRecord
    delete item 11 of theRecord
  end repeat
  put theImportedData into fld "Newdata"
end removeFields1

on removeFields2
  repeat with theRecord = 1 to the number of lines in theImportedData
    delete the last item of line theRecord of theImportedData
    delete word 2 of item 10 of line theRecord of theImportedData
    delete item 11 of line theRecord of theImportedData
  end repeat
  put theImportedData into fld "Newdata"
end removeFields2

Am I missing something? I think I must because I can't see what is
wrong with the 1st script -- and Rev doesn't find a problem either
because it executes without error. The data in the variable is just
untouched and gets saved again intact.

I'm quite happy to use the 2nd script but I'm curious as to why the
first one doesn't work.


Thanks

Ian McKnight



More information about the Use-livecode mailing list