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

  1. Path: rzstud1.rz.uni-karlsruhe.de!uhay
  2. From: uhay@rzstud1.rz.uni-karlsruhe.de (David Luebbren)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Q: Output from Workbench program.
  5. Date: 14 Mar 1996 14:40:08 GMT
  6. Organization: University of Karlsruhe, Germany
  7. Message-ID: <4i9b48$8n7@nz12.rz.uni-karlsruhe.de>
  8. NNTP-Posting-Host: rzstud1.rz.uni-karlsruhe.de
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=iso-8859-1
  11. Content-Transfer-Encoding: 8bit
  12. NNTP-Posting-User: uhay
  13. X-Newsreader: TIN [version 1.2 PL2]
  14.  
  15.  
  16. I want to do output from a workbench started program similar to the way it
  17. is done with STDOUT and STDERR in SAS/C but using the amiga file handles. 
  18. From several examples I gathered the following code but it doesn't work. 
  19. What is wrong with it?
  20.  
  21.  
  22.  
  23. struct WBStartup *WBenchMsg;
  24.  
  25. int
  26. main (int ac, char **av)
  27. {
  28.   struct Process *us;
  29.   long fh;
  30.  
  31.   us = (struct Process *) FindTask (NULL);
  32.   if (!us->pr_CLI) {
  33.     WaitPort (&us->pr_MsgPort);
  34.     WBenchMsg = (struct WBStartup *) GetMsg (&us->pr_MsgPort);
  35.  
  36.     fh = Open ("CON:10/10/300/50/Output", MODE_NEWFILE);
  37.     if (fh) {
  38.       struct FileHandle *handle = (struct FileHandle *) (fh << 2);
  39.       us->pr_ConsoleTask = (APTR) handle->fh_Type;
  40.       us->pr_CIS = fh;
  41.       us->pr_COS = Open ("*", MODE_OLDFILE);
  42.       PutStr ("Hello, world!\n");
  43.     }            
  44.     Forbid ();
  45.     ReplyMsg ((struct Message *) WBenchMsg);
  46.   }
  47. }
  48.  
  49.  
  50.  
  51. Thanks for any help.
  52.