control scructure repeat and next line

Sarah Reichelt sarahr at genesearch.com.au
Tue Feb 17 19:02:52 EST 2004


> This is the recipe I'm using. the field is "list behavior" and lock  
> text is unchecked.
> the problem is that it stays on the same line it doesn't move on to  
> the next line and so on.
> global myDbid,myLine,thisLine,mySql
> on mouseUp
>   put  
> revOpenDatabase("PostgreSQL","127.0.0.1","test",postgres,myPassword)int 
> o myDbid
>   repeat for each line myL in field "field 1"
>     put  the selectedText of field "field 1"  into mySql
>     put revdb_execute(myDbid,mySql) after field "field 2"-- to see  
> what is going on
>     put the selectedLine of field "field 1" into field "field 3"-- to  
> see what is going on
>     wait for 1 second
>     if the mouse is down then exit repeat
>     end repeat
> end mouseUp

Each time through the loop, myL contains the text of each line of the  
field. In the script above, you do not use this variable anywhere in  
the loop. There is no code to change the selectedText so in effect, you  
are using the number of lines as a counter, not to get any data.

Try this (assuming each line contains the SQL command you want to  
execute):

global myDbid,myLine,thisLine,mySql
on mouseUp
   put  
revOpenDatabase("PostgreSQL","127.0.0.1","test",postgres,myPassword)into 
  myDbid
   repeat for each line myL in field "field 1"
     put revdb_execute(myDbid, myL) after field "field 2"-- to see what  
is going on
     put myL into field "field 3"-- to see what is going on
     wait for 1 second
     if the mouse is down then exit repeat
     end repeat
end mouseUp

If you want to see the selection move down the list as you go, then you  
will have to change it in your scripts, using "set the hilitedLine".

Cheers,
Sarah



More information about the use-livecode mailing list