home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.hypercard
- Path: sparky!uunet!gatech!cc.gatech.edu!terminus!byrne
- From: byrne@terminus.gatech.edu (Michael Byrne)
- Subject: Re: How to change letter case in Hypercard? (i.e. caps, or lowercase?)
- Message-ID: <1992Sep16.044244.18615@cc.gatech.edu>
- Sender: news@cc.gatech.edu
- Organization: College of Computing
- References: <9226012.24875@mulga.cs.mu.OZ.AU>
- Date: Wed, 16 Sep 1992 04:42:44 GMT
- Lines: 38
-
- In article <9226012.24875@mulga.cs.mu.OZ.AU> mtc@mundil.cs.mu.OZ.AU (Michael Trevor CUTTER) writes:
- >Does anybody have a script to change the case of a string in HC?
- >
- >I am using HC 2.1, and I need to make a word typed in by the user change to
- >all capitals.
- >
- >I can't find anything in the Hypertalk Reference, and I don't want to write a
- >XCMD or XFCN to do it...I want to use Hypertalk if at all possible.
- >
- >Any ideas?
- >
- Personally, I'd suggest writing the XFCN... But if you must use HyperTalk,
- you can do something like this:
-
- function upperString TheString
- repeat with CharCnt = 1 to the number of chars in TheString
- put upperChar(char CharCnt of TheString) into char CharCnt of TheString
- end repeat
- return TheString
- end upperString
-
- function upperChar TheChar
- put charToNum(TheChar) into CharNum
- if (CharNum > 96) and (CharNum < 123) then -- if it's a lower case char
- subtract 32 from CharNum
- end if
- return numToChar(CharNum)
- end upperChar
-
- ---
- Of course, it'll be dog-slow, but that's the price you pay for
- interpreted languages. It's a really quick hack in C/Pascal.
-
- ================================================================================
- Mike "Suburn" Byrne | "Only the mediocre are
- byrne@cc.gatech.edu | always at their best."
- Grad student in Psychology/Cognitive Science |
- 25947 GA Tech Station, Atlanta, GA 30332 | -Jean Giradoux
-