home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / hypercar / 3306 < prev    next >
Encoding:
Text File  |  1992-08-30  |  1.8 KB  |  56 lines

  1. Newsgroups: comp.sys.mac.hypercard
  2. Path: sparky!uunet!cs.utexas.edu!asuvax!ennews!gtephx!patfieldk
  3. From: patfieldk@gtephx.UUCP (Kevin M. Patfield)
  4. Subject: Re: Validating Data Entry in a Field
  5. Message-ID: <1992Aug28.234435.22838@gtephx.UUCP>
  6. Summary: Use ask instead!
  7. Organization: AG Communication Systems, Phoenix, AZ
  8. References: <14612@mindlink.bc.ca>
  9. Date: Fri, 28 Aug 1992 23:44:35 GMT
  10. Lines: 44
  11.  
  12. In article <14612@mindlink.bc.ca> John_Miller@mindlink.bc.ca (John Miller) writes:
  13. >Gadzooks!  You're right!
  14. >
  15. >I've been using code something like this to check for errors:
  16. >
  17. >on closeField
  18. >  if me is not a number then
  19. >     answer "Gimme numerics or gimme death!"
  20. >         select char 1 to 1000 of me
  21. >  end if
  22. >end closeField
  23. >
  24. >This works great when the user moves around with the
  25. >Tab key.  (Notice I am *not* trapping tabKey directly.)
  26. >I never realized it didn't work when the user used the
  27. >mouse to exit the field.
  28.  
  29. <<More and more complicatd solutions mercifully omitted!>>
  30.  
  31. This is arguably less "mac-like" (?) but it works...
  32.  
  33. on closeField
  34.    get me
  35.    repeat until (it is a number) and (it is not empty)
  36.       ask "Gimme numerics or gimme death!" with it
  37.    end repeat
  38.    put it into me
  39. end closeField
  40.  
  41. I usually name numeric fields something like balanceVal then
  42. I can just put one handler in my stack to handle all numeric
  43. fields.  In this case I need to use "target" instead of "me"
  44. and check in the generic closeField wether the name of the
  45. target contains Val.  Adding new numeric fields is then 
  46. automatic and fail safe.  If you don't understand this
  47. paragraph just pretend it doesn't exist!
  48.  
  49. Note also the fact that hypercard erroneously (IMHO) considers
  50. empty to be a number!
  51. -- 
  52. Kevin Patfield, AG Communication Systems, Phoenix, AZ
  53. UUCP: {ncar!noao!enuucp | uunet!zardoz!hrc | att}!gtephx!patfieldk
  54. Internet: gtephx!patfieldk@enuucp.eas.asu.edu
  55. AOL: Patfield
  56.