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

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!stanford.edu!nntp.Stanford.EDU!leland.Stanford.EDU!cooljohn
  3. From: cooljohn@leland.Stanford.EDU ( Magdaleno)
  4. Subject: Accessing Data in Resource    
  5. Message-ID: <1992Dec14.203030.18641@leland.Stanford.EDU>
  6. Keywords: Resource, Data Handle, Handle
  7. Sender: news@leland.Stanford.EDU (USENET News System)
  8. Organization: DSG, Stanford University, CA 94305, USA
  9. Date: Mon, 14 Dec 92 20:30:30 GMT
  10. Lines: 39
  11.  
  12. Here's one problem of mine that I hope has a quick solution. 
  13.  
  14. In the midst of writing a game, a created my own resource type, say:
  15. MTYP, and in it I stored the map of the game.
  16.  
  17. Now in my program, this is what I do to access the data:
  18.  
  19. type
  20.     pMapType = array[1..MAXSIZE] of integer;
  21.     pMapPtr = ^pMapType;
  22.  
  23. var
  24.     pMap : pMapType;
  25.  
  26. procedure LoadInMap;
  27. var
  28.     MapRes : Handle;
  29. begin
  30.     MapRes := GetResource('MTYP',MAPID);
  31.     pMap := (pMapPtr(MapRes^)^);        { YUCK. }
  32.     etc....
  33. end;
  34.  
  35.     Well this code works for getting info out of the resource,
  36. but unfortunately, I haven't figured out how to point the Handle
  37. in the right direction, when I want to call WriteResource.
  38.     
  39.     So I have two questions:
  40. (1)    Is there better way to access the data... through the Handle.
  41. (2)    If so/not how do I make, in this case, MapRes point to
  42.     the memory where my array is stored. I've tried type
  43.     coercion to no ado.
  44.  
  45.     
  46.     Thank you in advance, 
  47.  
  48.     John Magdaleno
  49.     cooljohn@leland.stanford.edu
  50.  
  51.