home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / sys / mac / programm / 19759 < prev    next >
Encoding:
Internet Message Format  |  1992-12-13  |  2.0 KB

  1. Path: sparky!uunet!gatech!ncar!hsdndev!dartvax!coos.dartmouth.edu!smsilver
  2. From: smsilver@coos.dartmouth.edu (Scott M. Silver)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: After Dark Modules in Pascal
  5. Summary: How do I properly handle passing "the storage" variable
  6. Keywords: after dark pascal screen saver
  7. Message-ID: <1992Dec14.031126.12060@dartvax.dartmouth.edu>
  8. Date: 14 Dec 92 03:11:26 GMT
  9. Sender: news@dartvax.dartmouth.edu (The News Manager)
  10. Organization: Dartmouth College, Hanover, NH
  11. Lines: 92
  12.  
  13. All:
  14.  
  15. I am currently writing an After Dark module, and was having problems with the storage variable.  I set it up ok...it seems to have the correct intial values, but
  16. after that, it seems that I can't change anything.  See code below:
  17.  
  18. {DoInitialize:  Allocates Memory and various variables}
  19.  function DoInitialize (var storage: Handle; blankRgn: rgnHandle; params:
  20. GMParamBlockPtr): OSErr;
  21.  
  22.  
  23.   var
  24.    msg: msgPtr;
  25.  
  26.  begin
  27.   msg := msgPtr(NewPtr(sizeof(msgType)));
  28.   msg^.h := 100;
  29.   msg^.v := 100;
  30.  
  31.   hlock(storage);
  32.  
  33.   storage^ := Ptr(msg);
  34.  
  35.  
  36.  
  37.   hunlock(storage);
  38.  
  39.  
  40.   DoInitialize := noErr;
  41.  
  42.  end;
  43.  
  44.  
  45. {DoBlank:  Blanks the Screen}
  46.  function DoBlank (storage: Handle; blankRgn: rgnHandle; params:
  47. GMParamBlockPtr): OSErr;
  48.  
  49.  begin
  50.  
  51.  
  52.   FillRgn(blankRgn, params^.qdGlobalsCopy^.qdBlack);
  53.   DoBlank := noErr;
  54.  
  55.  end;
  56.  
  57. {DoDrawFram:  Draws one "animation" Frame.  This is repeatedly called by
  58. AfterDark}
  59.  function DoDrawFrame (storage: Handle; blankRgn: rgnHandle; params:
  60. GMParamBlockPtr): OSErr;
  61.  
  62.  
  63.   var
  64.    msg: msgPtr;
  65.    flag: boolean;
  66.  
  67.  begin
  68.  
  69.   forecolor(blueColor);
  70.  
  71.   Hlock(storage);
  72.  
  73.   msg := msgPtr(storage^);
  74.  
  75.   moveTo(msg^.h, msg^.v);
  76.  
  77.   if msg^.h = 100 then
  78.    DrawString('yo mommmy......')
  79.   else
  80.    drawString('blah blah');
  81.  
  82.   msg^.h := msg^.h + 8;
  83.   msg^.v := msg^.v + 8;
  84.  
  85.  
  86.   Hunlock(storage);
  87.  
  88.   DoDrawFrame := noErr;
  89.  
  90.  end;
  91.  
  92. The individual parts of msg don't seem to ever change...
  93.  
  94. BTW:  msgType is record
  95.  
  96. type msgtype= record
  97. h,v:integer;
  98.  
  99. and msgPtr=^msgType;
  100.  
  101.  
  102. Thanks in advance....
  103.  
  104. Scott
  105.