home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / mac / programm / 12912 < prev    next >
Encoding:
Text File  |  1992-07-22  |  968 b   |  32 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!wupost!sdd.hp.com!mips!pacbell.com!well!oster
  3. From: oster@well.sf.ca.us (David Phillip Oster)
  4. Subject: Re: Using CODE rescource files
  5. Message-ID: <Bru380.Esn@well.sf.ca.us>
  6. Sender: news@well.sf.ca.us
  7. Organization: Whole Earth 'Lectronic Link
  8. References: <bHP-sfA@engin.umich.edu>
  9. Date: Thu, 23 Jul 1992 08:50:23 GMT
  10. Lines: 20
  11.  
  12. Use think C to build a resourc with code in it, say type 'mCod'm id = 128.
  13. if it has a main procedure
  14. pascal vvoid main(short verb, long *result, ListHandle lh);
  15.  
  16. then you call it form your main program with:
  17.     Handle    h;
  18.     SignedByte    state;
  19.     long        res;
  20.  
  21.     if(NIL != (h = GetResource('mCod', 128))){
  22.         state = HGetState(h);
  23.         HLock(h);
  24.         CallPascal( 3, &res, lh, *h);
  25.         HSetState(h, state);
  26.     }
  27. For a main that is a C procedure, say:
  28. typedef void (*CodeResType_)(short verb, long *result, ListHandle lh);
  29.  
  30. then, instead of the CallPascal line above, say:
  31. (* (CodeResType) *h)( 3, &res, lh);
  32.