home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.hypercard
- Path: sparky!uunet!cs.utexas.edu!asuvax!ennews!gtephx!patfieldk
- From: patfieldk@gtephx.UUCP (Kevin M. Patfield)
- Subject: Re: Validating Data Entry in a Field
- Message-ID: <1992Aug28.234435.22838@gtephx.UUCP>
- Summary: Use ask instead!
- Organization: AG Communication Systems, Phoenix, AZ
- References: <14612@mindlink.bc.ca>
- Date: Fri, 28 Aug 1992 23:44:35 GMT
- Lines: 44
-
- In article <14612@mindlink.bc.ca> John_Miller@mindlink.bc.ca (John Miller) writes:
- >Gadzooks! You're right!
- >
- >I've been using code something like this to check for errors:
- >
- >on closeField
- > if me is not a number then
- > answer "Gimme numerics or gimme death!"
- > select char 1 to 1000 of me
- > end if
- >end closeField
- >
- >This works great when the user moves around with the
- >Tab key. (Notice I am *not* trapping tabKey directly.)
- >I never realized it didn't work when the user used the
- >mouse to exit the field.
-
- <<More and more complicatd solutions mercifully omitted!>>
-
- This is arguably less "mac-like" (?) but it works...
-
- on closeField
- get me
- repeat until (it is a number) and (it is not empty)
- ask "Gimme numerics or gimme death!" with it
- end repeat
- put it into me
- end closeField
-
- I usually name numeric fields something like balanceVal then
- I can just put one handler in my stack to handle all numeric
- fields. In this case I need to use "target" instead of "me"
- and check in the generic closeField wether the name of the
- target contains Val. Adding new numeric fields is then
- automatic and fail safe. If you don't understand this
- paragraph just pretend it doesn't exist!
-
- Note also the fact that hypercard erroneously (IMHO) considers
- empty to be a number!
- --
- Kevin Patfield, AG Communication Systems, Phoenix, AZ
- UUCP: {ncar!noao!enuucp | uunet!zardoz!hrc | att}!gtephx!patfieldk
- Internet: gtephx!patfieldk@enuucp.eas.asu.edu
- AOL: Patfield
-