home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
- From: d88-jwa@dront.nada.kth.se (Jon W{tte)
- Subject: Re: Comparing strings 'n stuff...
- In-Reply-To: rer@utrcv1.res.utc.com's message of 28 Aug 92 13:48:04 GMT
- Message-ID: <D88-JWA.92Aug28194218@dront.nada.kth.se>
- Originator: d88-jwa@dront.nada.kth.se
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: dront.nada.kth.se
- Organization: Royal Institute of Technology, Stockholm, Sweden
- References: <1992Aug28.134804.9876@sun1x.actc.res.utc.com>
- Date: Fri, 28 Aug 1992 18:42:18 GMT
- Lines: 49
-
- > rer@utrcv1.res.utc.com (Rick E Romkey) writes:
-
-
- I am trying to compare a Str255 with a String which exists
- in my resource file. I have loaded it in, but I am at a loss
- as to what to do to compare these two strings to see if they
- are equivalent.
-
-
- Boolean CompareStrings( Str255 inString )
- {
-
- WRONG WRONG WRONG. Should say "unsigned char * inString" and
- not Str255 inString, since you're passing a reference to an
- array.
-
- StringHandle textHandle;
-
- textHandle = GetString( 128 );
-
- if (textHandle == nil) {
- SysBeep(20);
- ExitToShell();
- }
-
- Most users wouldn't like that kind of error handling...
-
- /* WHAT DO I DO NOW??????? */
-
- A lot of things. The most kosher thing, which works for
- all systems >= 6.0 in all countries, is:
-
- HLock ( ( Handle ) textHandle ) ;
- ret = ! IUEqualString ( * textHandle , inString ) ; // Note the ! !!
- ReleaseResource ( ( Handle ) textHandle ) ;
-
- return ret ;
- }
-
-
- This will return 0 for unequal strings, and 1 for equal strings,
- it will consider diacritical marks for countries such as Sweden,
- but will not compare case. (i.e. 'a' == 'A')
-
- --
- - I have decided that it is not boxes but my lack of skill that's the problem.
- - Traitor! This kind of attitude will get you nowhere around here. If you must
- know, it's not your boxes that are the problem, it's your lack of a
- sufficient number of boxes. Go out and buy something.
-