Script not accepting empty line

Sarah Reichelt sarahr at genesearch.com.au
Wed May 26 23:56:25 EDT 2004


I don't know if this will help in your case, but as a general rule, 
using a "repeat for each" loop is much faster. If you are only dealing 
with 10 lines, it won't really matter, but you may deal with more data 
later
> This script will add data to lines 1 to 10 but then when lines are 
> emptied only line 10 will fill back up.
>
> on Add_New
> repeat with x = 1 to 10
> if line x of variable is empty then
> Add some data to the line here
> end repeat
> end Add_New
>
> This returns true, and is the exact line (minus the if) from the above 
> code!??
> answer (line x of variable is empty)
>
Here is an example - untested but should be right or nearly so :-)

on newAddNew
   put empty into newVariable
   repeat for each line L in variable
     if L is empty then
       -- insert the new data in place of the empty line
       put newData & cr after newVariable
     else
       put L & cr after newVariable
     end if
   end repeat
   delete last line of newVariable  -- extra cr
end newAddNew

Cheers,
Sarah
sarahr at genesearch.com.au
http://www.troz.net/Rev/.



More information about the Use-livecode mailing list