home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 4160 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.1 KB  |  70 lines

  1. Newsgroups: comp.sys.amiga.programmer
  2. Path: mozart.unx.sas.com!jamie
  3. From: jamie@cdevil.unx.sas.com (James Cooper)
  4. Subject: Re: Replying to WB Startup message with Sas/C
  5. Originator: jamie@cdevil.unx.sas.com
  6. Sender: news@unx.sas.com (Noter of Newsworthy Events)
  7. Message-ID: <DMtLxL.7oo@unx.sas.com>
  8. Date: Thu, 15 Feb 1996 14:08:09 GMT
  9. X-Nntp-Posting-Host: cdevil.unx.sas.com
  10. References: <717.6614T755T957@codeworks.gen.nz> <388.6614T873T1805@nando.net>
  11. Organization: SAS Institute Inc.
  12.  
  13.  
  14. In article <388.6614T873T1805@nando.net>, xyzzy@nando.net (Andy Philpotts) writes:
  15. >>I'm using Sas/C 6.56, and I'm linking WITHOUT the startup code. I would like
  16. >>to run my program from the Workbench, so i have to reply to the WBStartup
  17. >>message. The Sas documentation doesn't tell me how to do this, and the RKM's
  18. >>just say that the startup code should handel it.
  19. >
  20. >Look at "cback.a" in the sc:source directory, I think that may help.
  21.  
  22. That's fine... if one reads assembler.
  23.  
  24. However, if you wish to do it in C:
  25.  
  26. ----------------------------- WBProgSkel.c -----------------------------
  27. #include <dos/dosextens.h>
  28. #include <workbench/startup.h>
  29.  
  30. #include <proto/exec.h>
  31.  
  32. int mymain(void)
  33. {
  34.     struct WBStartup *myWBS;
  35.     struct Process *myproc;
  36.  
  37.     myWBS = NULL;
  38.     myproc = (struct Process *)FindTask(NULL);
  39.  
  40.     if (myproc->pr_CLI == NULL)
  41.     {
  42.         myWBS = (struct WBStartup *)GetMsg(myproc->pr_MsgPort);
  43.     }
  44.  
  45.     ... rest of program ...
  46.  
  47.     if (myWBS)
  48.     {
  49.         Forbid();
  50.         ReplyMsg((struct Message *)myWBS);
  51.     }
  52.     return 0;
  53. }
  54. ------------------------------------------------------------------------
  55.  
  56. That's all you need to simply *run* from WB.  Now, if you want to check
  57. for arguments, etc., you also need to check the 'struct WBArg' structure
  58. in <workbench/startup.h>, and parse things right after the GetMsg() call
  59. above.
  60.  
  61. -- 
  62. ---------------
  63. Jim Cooper
  64. (jamie@unx.sas.com)                             bix: jcooper
  65.  
  66. Any opinions expressed herein are mine (Mine, all mine!  Ha, ha, ha!),
  67. and not necessarily those of my employer.
  68.  
  69. I'm NOT Politically Correct, but that's because I'm "Sensitivity Challenged."
  70.