Page 1 of 1

Clearing a lot of fields

Posted: Mon Aug 10, 2009 3:43 am
by Glenn Boyce
Someone once gave me some code for clearing a whole lot of fields on a card with out writing "put "" into fld "fieldname"" for each one. I have a very busy card and need a clear button on it and think that now is the time to use that piece of code!! Any help appreciated.
Cheers

Glenn

Clearing a lot of fields

Posted: Mon Aug 10, 2009 4:49 am
by edljr
Glenn,

Try this:

Code: Select all

on mouseUp
   put the number of fields on this card into lastField
   repeat with x = 1 to lastField
      put empty into fld x
   end repeat
end mouseUp
Ed
http://idleaders.com

Clearing fields

Posted: Mon Aug 10, 2009 5:20 am
by Glenn Boyce
Great that cleared them all right. BUT it also cleared all the label fields as well!! I just want to clear the ones I have entered data into.

cheers

Clearing a lot of fields

Posted: Mon Aug 10, 2009 5:37 am
by edljr
Glenn,

If you have a naming convention that differentiates your label fields from data entry fields, this is easy. For example, you can name all your labels with the preface "label" (i.e. labelName, labelStreet, labelCity). Then you could ignore those fields in the below code:

Code: Select all

on mouseUp
   put the number of fields on this card into lastField
   repeat with x = 1 to lastField
      put the short name of fld x into tFld
      if tFld contains "label" then
         // do nothing
      else
         put empty into fld x
      end if
   end repeat
end mouseUp
HTH,
Ed

Posted: Mon Aug 10, 2009 9:59 am
by Klaus
Hi Glenn,

"label" fields have their "locktext" property set to true, so you better check for this prop than for the name, which may NOT contain "label" :-)

Code: Select all

on mouseUp 
   put the number of fields on this card into lastField 
   repeat with x = 1 to lastField 
      if the locktext of fld x <> true then 
          put empty into fld x 
      end if 
   end repeat 
end mouseUp 
Best

Klaus

Posted: Mon Aug 10, 2009 9:41 pm
by Glenn Boyce
Thank you. Got an answer that'll work.