home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!bgsuvax!m64-134.bgsu.edu!user
- From: dnebing@andy.bgsu.edu (Dave Nebinger)
- Subject: Re: Please help me pull this string
- Message-ID: <dnebing-181292162419@m64-134.bgsu.edu>
- Followup-To: comp.sys.mac.programmer
- Sender: usenet@andy.bgsu.edu (USENET)
- Organization: Bowling Green State University B.G., Oh.
- References: <q8m2+qj@rpi.edu>
- Date: Fri, 18 Dec 1992 21:31:08 GMT
- Lines: 46
-
- In article <q8m2+qj@rpi.edu>, abduls@aix.rpi.edu (Saiful Azuan Abdul Aziz)
- wrote:
- >
- > My template looks like this (in ResEdit)
- >
- > LABEL FIELD TYPE
- > # of Data ZCNT
- > **** LSTC
- > Starting Pts DLNG
- > Ending Pts DLNG
- > Line Name PSTR
- > **** LSTE
- >
- > When I translated this to my C data structure, I make it somthing like
- > this
- >
- > struct MyData{
- > long StartPt;
- > long EndPt;
- > Str255 LineName;
- > };
- >
- > My problem is that I can't get the pascal string working when I did the
- > BlockMove. The pascal string is not in constant size. It is stored in N+1 byte
- > style. (N is # of character). Below is the code that I did to get my
- > resource (part of it)
- >
-
- Str255 and the PSTR are two different things. Str255 variables take
- up 256 bytes of memory. The first is the length, then the string, followed
- by the remaining bytes.
-
- If a Str255 is initialized to "\pabcdefghijklmnopqrstuvwxyz", the length
- byte will be 26, but the 256 bytes of memory reserved for the variable are
- still there, just ignored. If you reset the variable to "\p12345", the
- length byte will be 5, but in memory it will look like "\p12345fghi...".
-
- Your 2 choices to handle this is to initialize your resource to contain
- Str255 strings (save all 256 bytes) or manually get and put the size of
- the string you want. The advantage to the first method is that it is alot
- easier to write, but your template will not look as pretty.
-
- Hope this helps,
-
- David Nebinger
- dnebing@andy.bgsu.edu
-