clear fields

Klaus Major klaus at major-k.de
Fri Jun 3 14:10:27 EDT 2005


Hi Bob,

> You wrote:
>
>
>> Hi All
>>
>> I have a script that clears the contents of fields in cards.
>>
>> on mouseUp
>>   repeat with x = 1 to the number of flds
>>    put empty into fld x
>> end repeat end mouseUp
>>
>> Now this works ok except that the card has some labels and the script
>> clears the label contents.
>>
>> All the text fields are called field1, field2 etc
>>
>> so I thought of doing this on mouseUp
>>   repeat with x = 1 to the number of flds
>>     if the name of fld x is "field &*"
>>   then put empty into fld x
>> end repeat end mouseUp
>>
>> But I don't ge tthe fields clearing. I tried variations on the  
>> "field & *"
>>
>
> Then I thought that since the field is number x and the fields are  
> field1,
> field2 etc then
> on mouseUp
>   repeat with x = 1 to the number of flds
>     if the name of fld x is "field" & "x"
>    then put empty into fld x
> end repeat
> end mouseUp
>

sorry, i misunderstood you.

You need brackets :-)

on mouseUp
   repeat with x = 1 to the number of flds
     if the name of fld x = ("field" & "x") then
          put empty into fld x
     end if
   end repeat
end mouseUp

> No luck there

This will work, since the string will be evaluated first and without
the brackets the engine will only look for a field -> "field", but  
with the
brackets it will evaluate the string first to -> "field1" etc... in  
the loop.

Brackets are necessary most of the time when it comes to strings! :-)

> bob

Best

Klaus Major
klaus at major-k.de
http://www.major-k.de



More information about the use-livecode mailing list