next repeat problem

Klaus Major klaus at major-k.de
Tue Aug 17 18:04:46 EDT 2004


Hi Rich,

> Thanks Klaus (and Jan!),
>
> Yes, adding the complete descriptor for i did allow my 'next repeat' 
> to run. However, I'm still having problems getting rid of the extra 
> lines in my global variable.
> I have also been trying your suggestion of using 'repeat for each'.
>
> I get an error when I try to 'apply' this script--
>
> ---------------------------------------------------------------
> set the itemdel to tab
> repeat for each line i in fld "daTable"
> if i = empty then
> delete line i of fld "daTable"
> else
> put item 1 of field "daTable"  & return after theList
> end if
> end repeat
>
> --------------------------------------------------------------
> The error I get is "Chunk: error in chunk expression" and it 
> highlights the line "put item 1 of field "daTable"  & return after 
> theList" -- this is a line of the script that worked before...

"repeat for each xyz" is READ only!!!

Means you cannot manipulate "i" in this case AND "i" holds the
CONTENTS of line i, therefore it is no number and the error is correct 
;-)

If you need the current loop number, you can use this old trick:

set the itemdel to tab
put 1 into my_counter
repeat for each line i in fld "daTable"
    if i = empty then delete line my_counter of fld "daTable"
         else
        ###    put item 1 of field "daTable"  & return after theList
        ###????? Nonono, did not write this ;-)
            put item 1 of i & CR after theList
    end if
add 1 to my_counter
end repeat
...

> Rich

>> ...
>> set the itemdel to TAB
>> repeat for each line i in fld "daTable"
>>    if i <> empty then
>>       put item 1 of i & CR after theList
###!!!
>>    end if
>> end repeat
>> ...
>>

Regards

Klaus Major
klaus at major-k.de
http://www.major-k.de



More information about the use-livecode mailing list