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

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!europa.asd.contel.com!darwin.sura.net!jvnc.net!yale.edu!yale!gumby!kzoo!k044477
  3. From: k044477@hobbes.kzoo.edu (Jamie R. McCarthy)
  4. Subject: Re: Comparing strings 'n stuff...
  5. Message-ID: <1992Aug28.191116.6242@hobbes.kzoo.edu>
  6. Organization: Kalamazoo College
  7. References: <1992Aug28.134804.9876@sun1x.actc.res.utc.com> <D88-JWA.92Aug28194218@dront.nada.kth.se>
  8. Date: Fri, 28 Aug 1992 19:11:16 GMT
  9. Lines: 41
  10.  
  11. d88-jwa@dront.nada.kth.se (Jon W{tte) writes:
  12. >> rer@utrcv1.res.utc.com (Rick E Romkey) writes:
  13. >
  14. >   I am trying to compare a Str255 with a String which exists
  15. >   in my resource file.
  16. >
  17. >   Boolean CompareStrings( Str255 inString )
  18. >   {
  19. >
  20. >WRONG WRONG WRONG. Should say "unsigned char * inString" and
  21. >not Str255 inString, since you're passing a reference to an
  22. >array.
  23.  
  24. Er, much as I hate to correct the master, there's nothing wrong with an
  25. argument of type Str255.  It resolves to:
  26.  
  27. Boolean CompareStrings(unsigned char inString[256])
  28.  
  29. ...and there's nothing wrong with that.  They amount to the same thing.
  30.  
  31.  
  32. While I'm wasting bandwidth, allow me to point out that converting P to
  33. C strings and using strcmp is not only accent-unfriendly, but inefficient.
  34. If you want 'e', 'E', and '<e-acute>' to be considered different, you
  35. may as well write:
  36.  
  37. Boolean pstringsAreEqual(Str255 s1, Str255 s2)
  38. {
  39.     short len = s1[0];
  40.     short i;
  41.     if (s2[0] != len) return FALSE;
  42.     for (i = 1; i <= len; ++i) {
  43.         if (s1[i] != s2[i]) return FALSE;
  44.     }
  45.     return TRUE;
  46. }
  47. -- 
  48.  Jamie McCarthy      Internet: k044477@kzoo.edu      AppleLink: j.mccarthy
  49.  "It's bad enough to send a rude message to another via such an anonymous
  50.   channel [as email].  To flame someone on an open forum is, to me, the
  51.   height of insensitivity."                                 - P.J. Plauger
  52.