Page 1 of 1
Clear variables and fields
Posted: Sat Oct 10, 2009 12:13 pm
by Philhold
Very simple but what is the best way to clear the contents of a field or variable?
This is what I am doing is this correct or is there something better?
Code: Select all
put "" into varA
put "" into field "name"
Thanks
Phil
Posted: Sat Oct 10, 2009 1:29 pm
by Klaus
Hi Phil,
...
put empty into fld "xyz"
...
is the best, if not the only way

Same for emptying variables.
Best
Klaus
Posted: Sat Oct 10, 2009 2:23 pm
by Philhold
Hi Klaus,
Many thanks, your help is very much appreciated.
I'm actually getting my first little app to work.
Cheers
Phil
Posted: Sat Oct 10, 2009 2:29 pm
by Klaus
[qHi Phil,
you're welcome!
And of course "" is the same as -> empty!
Best
Klaus
Posted: Sat Oct 10, 2009 6:08 pm
by Philhold
and this would clear all fields would it?
repeat with x = 1 to number of fields
put empty into fld x
end repeat
any dangers in doing this? Does it just clear all fields on the current card?
Cheers
Phil
Posted: Sun Oct 11, 2009 4:17 pm
by Janschenkel
Your script will indeed clear all the fields on the current card - including label fields, so you have to be careful! If you want to empty all the editable fields in your stack, you would have a loop like this:
Code: Select all
on mouseUp
local tCardCount, tCardIndex, tFieldCount, tFieldIndex
put the number of cards into tCardCount
repeat with tCardIndex = 1 to tCardCount
put the number of fields of card tCardIndex into tFieldCount
repeat with tFieldIndex = 1 to tFieldCount
if the lockText of field tFieldIndex of card tCardIndex is false
then put empty into field tFieldIndex of card tCardIndex
end repeat
end repeat
end mouseUp
HTH,
Jan Schenkel.
Posted: Sun Oct 11, 2009 4:43 pm
by Philhold
Hi Jan,
Many thanks for the tip.
Your script has stimulated me to search around but I can't find the answer. By implication am I right to assume that the lockText of label fields is set to true by default?
Thanks
Phil
Posted: Sun Oct 11, 2009 6:47 pm
by Klaus
Hi Phil,
definitivley maybe!
No just kidding, you are presuming correctly, "label" fields are "locked" by default.
Best
Klaus