next repeat problem

Klaus Major klaus at major-k.de
Tue Aug 17 11:28:10 CDT 2004


Hi Rich,

> I'm trying to get rid of blank lines in a global variable by using the 
> "next repeat" control structure to stop them from being put into the 
> variable in the first place. I keep getting errors-- but only when I 
> include the "next repeat" line. Here is the script:
>
> on upDateTopicsRequest
>   global theList, order, theListPlus, currentListNam
>
>   put empty into theList
>   ask "Would you like to save your current list?"
>   if it is empty then beep
>   else
>     put it into field "listName"
>     put it into currentListNam
>
>     set the itemDelimiter to tab
>     repeat with i = 1 to the number of lines in field "daTable"
>    ##   if  line i is empty then next repeat
## Does this work?
        if  line i of field "daTable" = empty then next repeat
## Need the complete descriptor for i...

>       put item 1 of line i of field "daTable" & return after theList
>     end repeat
>     put the number of lines of theList into order
>     put field "daTable" into theListPlus --extract the descriptors in 
> productEval stack
>
>   end if
>
> end upDateTopicsRequest
>
>
> 	"daTable" is a table field. If I exclude the "next repeat" line I do 
> not get an error, but I get a lot of blank lines in the global 
> variable "theList". This, in turn, causes other problems down the 
> line. The error I get when I hit the "Apply" button is "if missing 
> 'then'.
> 	Is there a better way of excluding the blank lines in the field 
> "daTable" from my global variable?

If you have MANY lines you could save some time using "repeat for 
each..."

...
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
...

Insanely fast :-D

Hope that helps...

> Thanks,
>
> Rich Lague

Regards

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



More information about the use-livecode mailing list