Resetting Checkboxes & Text Entry Fields

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
haer
Posts: 5
Joined: Mon Dec 23, 2013 1:44 am

Resetting Checkboxes & Text Entry Fields

Post by haer » Tue Dec 24, 2013 6:17 am

Hi all,

looking for help to reset ticked checkboxes and empty text entry fields at one go with a command button instead of doing it one by one.

any help is greatly appreciated.

anws i already have the following code:

Code: Select all

on mouseUp
  repeat with x=1 to number of cards
    repeat with y=1 to number of buttons of cd x
      set the hilite of btn y of cd x to false
    end repeat
  end repeat

  repeat with x=1 to number of cards
    repeat with z=1 to number of fields of cd x
      put empty into fld z of cd x
    end repeat
  end repeat
end mouseUp
the problem i have is that the label fields are also put to empty together with the text fields. is there any way to limit the empty to text fields only?

thanks!

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Resetting Checkboxes & Text Entry Fields

Post by SparkOut » Tue Dec 24, 2013 10:52 am

It depends on how you have set up the fields, but if you have (for instance) named the fields that have editable text (eg field "first_name") and named label fields "Label" or just left as default "field" then you could add a check

Code: Select all

repeat with x=1 to number of cards
    repeat with z=1 to number of fields of cd x
        if not (the short name of field z of card x begins with "field") then  -- or other appropriate test
            put empty into fld z of cd x
        end if
    end repeat
end repeat
This is a bit of overkill in most respects, but if you read this thread http://forums.runrev.com/phpBB2/viewtop ... 204#p34204 you can see it is easy enough to set default properties, the built-ins include the rect, and contents. If you adapt the handlers mentioned you can tailor them to just deal with what you want. HTH

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: Resetting Checkboxes & Text Entry Fields

Post by Simon » Tue Dec 24, 2013 11:48 am

Hi haer,
I think you use

Code: Select all

...
repeat with z=1 to number of fields of cd x
if the lockText of fld z of cd x = true then next repeat
put empty into fld z of cd x
...
Your labels of course should have their lockText set to true so people can't write in them :)

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Resetting Checkboxes & Text Entry Fields

Post by dunbarx » Tue Dec 24, 2013 2:49 pm

What Sparkout and Simon really mean is that a label field is just an ordinary field with a few properties set a certain way. You can morph an editable field, say, into a label field by hand just by fooling around with those properties. There is therefore no way for LC to distinguish one type from another, the way you correctly distinguish control types in your handler. You have to do that yourself, which is what Sparkout meant by "how you have set up the fields". So some convention, the name property being suggested in this case, will allow you to check and separate the fields of interest when you do your initialization. But it must be a property that distinguishes the two "types" of fields. Your choice...

Craig Newman

Post Reply