home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14673 < prev    next >
Encoding:
Internet Message Format  |  1992-08-29  |  1.5 KB

  1. Path: sparky!uunet!ogicse!usenet.coe.montana.edu!rpi!batcomputer!cornell!csuley
  2. From: csuley@cs.cornell.edu (Christopher Suley)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Comparing strings 'n stuff...
  5. Message-ID: <1992Aug28.171916.16996@cs.cornell.edu>
  6. Date: 28 Aug 92 17:19:16 GMT
  7. Article-I.D.: cs.1992Aug28.171916.16996
  8. References: <1992Aug28.134804.9876@sun1x.actc.res.utc.com> <chuck-280892124136@choffman.gte.com>
  9. Organization: Cornell Univ. CS Dept, Ithaca NY 14853
  10. Lines: 22
  11.  
  12. In article <chuck-280892124136@choffman.gte.com> chuck@gte.com (Chuck Hoffman) writes:
  13. >In article <1992Aug28.134804.9876@sun1x.actc.res.utc.com>,
  14. >rer@utrcv1.res.utc.com (Rick E Romkey) wrote:
  15. >> 
  16. >> 
  17. >> I am trying to compare a Str255 with a String which exists
  18. >> in my resource file.  I have loaded it in, but I am at a loss
  19. >> as to what to do to compare these two strings to see if they
  20. >> are equivalent.
  21. >> 
  22. >
  23. >If you are using THINK C, there are two routines for converting between
  24. >strings of Pascal format (with length byte at the beginning) and C format
  25. >(with null character at the end).  They are "PtoCstr" and "CtoPstr".  If
  26. >you get both strings into C format, then you can use the C library routine
  27. >"strncmp" to compare them, even if they are of dissimilar length.
  28. >
  29.  
  30. If you stored the strings in your resource file in 'STR#' (string list)
  31. resources, you could use GetIndString to read them into a Str255 variable.
  32. Then, you could use IUMagIDString (or EqualString, I think) to compare them.
  33. All the calls mentioned are documented in Inside Macintosh volume 1.
  34.