Page 1 of 1

Empty a lot of fields at once

Posted: Wed May 07, 2014 7:03 pm
by pink
Right now, I have 20 fields that I put empty into; and also I put 0 into 35 fields on a mouseUp... is there a faster way of clearing a lot of fields at once?

Re: Empty a lot of fields at once

Posted: Wed May 07, 2014 7:08 pm
by Klaus
Hi pink,

you need to do a repeat loop like this:

Code: Select all

...
## Always lock the screen when updating lot of controls!
lock screen
repeat with i = 1 to 20
  put EMPTY into fld i
end repeat
unlock screen
...

Code: Select all

...
## Always lock the screen when updating lot of controls!
lock screen
repeat with i = 1 to 35
  put "0" into fld i
end repeat
unlock screen
...
Best

Klaus

Re: Empty a lot of fields at once

Posted: Wed May 07, 2014 7:14 pm
by dunbarx
Hi.

Have you ever written a repeat loop? I like to make new users do their own work. (So everyone else, back off) Please read up on the "repeat" control structure in the dictionary, especially its "repeat with" variant.

Think about the following (pseudocode)

loop through all the fields on the card --how shall we reference each one?
put empty into each field --looks like you have done this sort of thing already

Write back as soon as you have something, or have questions or problems.

Craig Newman

Re: Empty a lot of fields at once

Posted: Wed May 07, 2014 7:15 pm
by dunbarx
Pay no attention to what Klaus wrote. Do it my way.

Craig

Re: Empty a lot of fields at once

Posted: Wed May 07, 2014 8:01 pm
by Klaus
dunbarx wrote:Pay no attention to what Klaus wrote. Do it my way.

Craig
:D :D :D

Re: Empty a lot of fields at once

Posted: Fri May 09, 2014 9:01 pm
by pink
Thanks Craig & Klaus, you were both a big help

I put two fields on a card that just holds some data and the fields that need to be reset get put into it as theya re being processed.
This is what I ended up using:

Code: Select all

     repeat for each line fieldToEmpty in field "fieldlist" on card "data"
          do "put empty into field"&quote&fieldToEmpty&quote 
     end repeat
     repeat for each line fieldToZero in field "fieldlistcounters" on card "data"
          do "put 0 into field"&quote&fieldToZero&quote
     end repeat
Thanks again for your help

Re: Empty a lot of fields at once

Posted: Fri May 09, 2014 9:23 pm
by Klaus
Hi pink,

you're welcome! :D

But no need to DO something here!

Code: Select all

...
     repeat for each line fieldToEmpty in field "fieldlist" of card "data"
          put empty into field fieldToEmpty
     end repeat
     repeat for each line fieldToZero in field "fieldlistcounters" of card "data"
         put 0 into field fieldToZero 
     end repeat
...
will do!

Best

Klaus