home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / oop / macapp3 / 556 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  1.1 KB

  1. Path: sparky!uunet!think.com!ames!data.nas.nasa.gov!taligent!apple!applelink.apple.com
  2. From: DIGIMATCH@AppleLink.Apple.COM (3M, Ran Bedekar,PRT)
  3. Newsgroups: comp.sys.mac.oop.macapp3
  4. Subject: Re: Record -> Struct
  5. Message-ID: <727630463.7463678@AppleLink.Apple.COM>
  6. Date: 21 Jan 93 14:48:00 GMT
  7. Sender: daemon@Apple.COM
  8. Organization: AppleLink Gateway
  9. Lines: 20
  10.  
  11. Paul,
  12. > The problem comes when I want to write the function to return an empty one. I
  13. > can't figure out how to make each field an empty Pascal string.
  14.  
  15. There are a couple ways you can deal with string assignments.  The most
  16. "C-like" is to use strcpy or its Pascal string counterpart.  It amounts to a
  17. call to BlockMove:
  18. unsigned char *str = "\pSome String";
  19. BlockMove((Ptr) str, (Ptr) (myRec)->HNo, *str + 1);
  20.  
  21. I've also had fair luck casting these things to CStr255 references:
  22. (CStr255 &) *(myRec)->HNo = (const CStr255 &) "\pSome String";
  23.  
  24. It may not be a problem, but you'll want to be careful about the byte alignment
  25. of items in your structure between Pascal and C.  Since you're following an odd
  26. sized byte array with an enum, you may have problems with pad bytes, etc.
  27.  
  28. Regards,
  29. Nick Nallick
  30.  
  31.