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