Empty a lot of fields at once
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Empty a lot of fields at once
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?
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Empty a lot of fields at once
Hi pink,
you need to do a repeat loop like this:
Best
Klaus
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
...
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Empty a lot of fields at once
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
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
-
- VIP Livecode Opensource Backer
- Posts: 9670
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Empty a lot of fields at once
Pay no attention to what Klaus wrote. Do it my way.
Craig
Craig
Re: Empty a lot of fields at once
dunbarx wrote:Pay no attention to what Klaus wrote. Do it my way.
Craig
Re: Empty a lot of fields at once
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:
Thanks again for your 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""e&fieldToEmpty"e
end repeat
repeat for each line fieldToZero in field "fieldlistcounters" on card "data"
do "put 0 into field""e&fieldToZero"e
end repeat
Greg (pink) Miller
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
MadPink, LLC
I'm Mad, Pink and Dangerous to Know
Re: Empty a lot of fields at once
Hi pink,
you're welcome!
But no need to DO something here!
will do!
Best
Klaus
you're welcome!
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
...
Best
Klaus