home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / mac / programm / 20200 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  1.7 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!howland.reston.ans.net!hsdndev!dartvax!coos.dartmouth.edu!smsilver
  2. From: smsilver@coos.dartmouth.edu (Scott M. Silver)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Reading Resources II
  5. Summary: How to correctly read resources and use them
  6. Keywords: resources reading mac pascal
  7. Message-ID: <1992Dec22.190758.18473@dartvax.dartmouth.edu>
  8. Date: 22 Dec 92 19:07:58 GMT
  9. Sender: news@dartvax.dartmouth.edu (The News Manager)
  10. Organization: Dartmouth College, Hanover, NH
  11. Lines: 33
  12.  
  13. I am trying to make my own simple resource and read it in (correctly).  The resource is simply created by typing in the ascii region when creating a new resource.  The following code works for printing out the resource, but it really doesn't properly assign the correct characters to the variable ch.
  14.  
  15. {PrintString:  Res is handle to the resource.  Size is the size of the
  16. resource}
  17. {Takes a handle to a resource and prints it out to the text window in Think
  18. Pascal}
  19.  procedure PrintString (res: Handle;
  20.        size: integer);
  21.  
  22.   var
  23.    index: integer;
  24.    ch: char;
  25.    scratch: Ptr;
  26.  
  27.  begin
  28.   Hlock(res);
  29.   for index := 0 to size - 1 do
  30.    begin
  31.     Scratch := Ptr(LongInt(Res^) + longint(index) - longint(1));
  32.     BlockMove(Scratch, @ch, 2);
  33.     write(ch);
  34.     if index mod 32 = 0 then
  35.      writeln;
  36.    end;
  37.   HUnlock(res);
  38.  end;
  39.  
  40. This as it says justs prints out the resource to the text window in Think Pascal.  I think my problem is a conceptual one having to do with memory and not Resources.  Any help would be appreciated, and thank you in advance.  
  41.  
  42. Scott
  43.  
  44.  
  45. "If you met two guys named Hambone and Flippy, which do you think would like dolphins more?  You'd probably say Flippy.  You'd be wrong though, it's Hambone."
  46.