home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19979 < prev    next >
Encoding:
Text File  |  1992-12-17  |  1.9 KB  |  71 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!usc!rpi!abduls
  3. From: abduls@aix.rpi.edu (Saiful Azuan Abdul Aziz)
  4. Subject: Please help me pull this string
  5. Message-ID: <q8m2+qj@rpi.edu>
  6. Nntp-Posting-Host: aix.rpi.edu
  7. Organization: Rensselaer Polytechnic Institute, Troy NY
  8. Date: Thu, 17 Dec 1992 18:34:22 GMT
  9. Lines: 60
  10.  
  11.  
  12. Hai there,
  13.     I'm new in Mac programming (infact, I'm new in programming in
  14. general). Anyway, I need to get some information out of one resource.
  15. What I need is how can I get the data structure of pascal string. When
  16. I open the resource using ResEdit, I can built the templates for this resource.
  17. My template looks like this (in ResEdit)
  18.  
  19.     LABEL        FIELD TYPE
  20.     # of Data        ZCNT
  21.     ****        LSTC
  22.     Starting Pts    DLNG
  23.     Ending Pts    DLNG
  24.     Line Name        PSTR
  25.     ****        LSTE
  26.     
  27. When I translated this to my C data structure, I make it somthing like
  28. this
  29.  
  30. struct    MyData{
  31.     long    StartPt;
  32.     long    EndPt;
  33.     Str255    LineName;
  34. };
  35. typedef    struct    MyData    MyData;
  36.  
  37. struct    MyRealData{
  38.     long    NumOfData;
  39.     MyData    theData[];
  40. };
  41. typedef    struct    MyRealData    MyRealData;
  42.  
  43. My problem is that I can't get the pascal string working when I did the
  44. BlockMove. The pascal string is not in constant size. It is stored in N+1 byte
  45. style. (N is # of character). Below is the code that I did to get my
  46. resource (part of it)
  47.  
  48. ...
  49. MyRealData    gPreference;
  50. ...
  51. resHandle = Get1Resource('LINE', 128);
  52. if (resHandle != NIL) {
  53.     MoveHHi(resHandle);
  54.     HLock(resHandle);
  55.     BlockMove(*resHandle, (Ptr)&gPreference, (long) sizeof(MyRealData));
  56.     HUnlock(resHandle);
  57.     ReleaseResource(resHandle);
  58. }
  59. ...
  60.  
  61. gPreference.theData[0] give me a right result, but not the rest of the
  62. array. My question is, what is the right way to get this kind of data.
  63. I'm hoping that there is a mac guru out there in the net that could
  64. help me with this pascal string.
  65.  
  66. Thanks in advance.
  67.  
  68. SAIFUL AZIZ
  69. internet:abduls@rpi.edu bitnet:saiful@rpitsmts aol:azrin compu$erve:70760,371
  70. disclaimer: help me!!!!!!!! what should i say over here???????
  71.