home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14676 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.9 KB  |  64 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!sunic!kth.se!dront.nada.kth.se!d88-jwa
  3. From: d88-jwa@dront.nada.kth.se (Jon W{tte)
  4. Subject: Re: Comparing strings 'n stuff...
  5. In-Reply-To: rer@utrcv1.res.utc.com's message of 28 Aug 92 13:48:04 GMT
  6. Message-ID: <D88-JWA.92Aug28194218@dront.nada.kth.se>
  7. Originator: d88-jwa@dront.nada.kth.se
  8. Sender: usenet@kth.se (Usenet)
  9. Nntp-Posting-Host: dront.nada.kth.se
  10. Organization: Royal Institute of Technology, Stockholm, Sweden
  11. References: <1992Aug28.134804.9876@sun1x.actc.res.utc.com>
  12. Date: Fri, 28 Aug 1992 18:42:18 GMT
  13. Lines: 49
  14.  
  15. > rer@utrcv1.res.utc.com (Rick E Romkey) writes:
  16.  
  17.  
  18.    I am trying to compare a Str255 with a String which exists
  19.    in my resource file.  I have loaded it in, but I am at a loss
  20.    as to what to do to compare these two strings to see if they
  21.    are equivalent.
  22.  
  23.  
  24.    Boolean CompareStrings( Str255 inString )
  25.    {
  26.  
  27. WRONG WRONG WRONG. Should say "unsigned char * inString" and
  28. not Str255 inString, since you're passing a reference to an
  29. array.
  30.  
  31.        StringHandle    textHandle;
  32.  
  33.        textHandle = GetString( 128 );
  34.  
  35.        if (textHandle == nil) {
  36.            SysBeep(20);
  37.            ExitToShell();
  38.        }
  39.  
  40. Most users wouldn't like that kind of error handling...
  41.  
  42.    /* WHAT DO I DO NOW??????? */
  43.  
  44. A lot of things. The most kosher thing, which works for
  45. all systems >= 6.0 in all countries, is:
  46.  
  47.     HLock ( ( Handle ) textHandle ) ;
  48.     ret = ! IUEqualString ( * textHandle , inString ) ; // Note the ! !!
  49.     ReleaseResource ( ( Handle ) textHandle ) ;
  50.  
  51.     return ret ;
  52.    }
  53.  
  54.  
  55. This will return 0 for unequal strings, and 1 for equal strings,
  56. it will consider diacritical marks for countries such as Sweden,
  57. but will not compare case. (i.e. 'a' == 'A')
  58.  
  59. -- 
  60. - I have decided that it is not boxes but my lack of skill that's the problem.
  61. - Traitor! This kind of attitude will get you nowhere around here. If you must
  62.   know, it's not your boxes that are the problem, it's your lack of a
  63.   sufficient number of boxes. Go out and buy something.
  64.