home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / mac / hypercar / 3453 < prev    next >
Encoding:
Text File  |  1992-09-15  |  1.8 KB  |  50 lines

  1. Newsgroups: comp.sys.mac.hypercard
  2. Path: sparky!uunet!gatech!cc.gatech.edu!terminus!byrne
  3. From: byrne@terminus.gatech.edu (Michael Byrne)
  4. Subject: Re: How to change letter case in Hypercard? (i.e. caps, or lowercase?)
  5. Message-ID: <1992Sep16.044244.18615@cc.gatech.edu>
  6. Sender: news@cc.gatech.edu
  7. Organization: College of Computing
  8. References: <9226012.24875@mulga.cs.mu.OZ.AU>
  9. Date: Wed, 16 Sep 1992 04:42:44 GMT
  10. Lines: 38
  11.  
  12. In article <9226012.24875@mulga.cs.mu.OZ.AU> mtc@mundil.cs.mu.OZ.AU (Michael Trevor CUTTER) writes:
  13. >Does anybody have a script to change the case of a string in HC?
  14. >
  15. >I am using HC 2.1, and I need to make a word typed in by the user change to
  16. >all capitals.
  17. >
  18. >I can't find anything in the Hypertalk Reference, and I don't want to write a 
  19. >XCMD or XFCN to do it...I want to use Hypertalk if at all possible.
  20. >
  21. >Any ideas?
  22. >
  23. Personally, I'd suggest writing the XFCN...  But if you must use HyperTalk,
  24. you can do something like this:
  25.  
  26. function upperString TheString
  27.   repeat with CharCnt = 1 to the number of chars in TheString
  28.     put upperChar(char CharCnt of TheString) into char CharCnt of TheString
  29.   end repeat
  30.   return TheString
  31. end upperString
  32.  
  33. function upperChar TheChar
  34.   put charToNum(TheChar) into CharNum
  35.   if (CharNum > 96) and (CharNum < 123) then    -- if it's a lower case char
  36.     subtract 32 from CharNum
  37.   end if
  38.   return numToChar(CharNum)
  39. end upperChar
  40.  
  41. ---
  42. Of course, it'll be dog-slow, but that's the price you pay for 
  43. interpreted languages.  It's a really quick hack in C/Pascal.
  44.  
  45. ================================================================================
  46. Mike "Suburn" Byrne                           |  "Only the mediocre are 
  47. byrne@cc.gatech.edu                           |   always at their best."
  48. Grad student in Psychology/Cognitive Science  |
  49. 25947 GA Tech Station, Atlanta, GA 30332      |                -Jean Giradoux
  50.