home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 100.lha / FramSet / myconsole.f < prev   
Text File  |  1986-11-20  |  1KB  |  46 lines

  1. \ *****************
  2. \ *  MyConsole.f  *
  3. \ *****************
  4.  
  5. \ Words to open a console for TYPE and QUERY I/O (i.e. setup INFILE & 
  6. \      OUTFILE) for an application running in background,
  7. \      as with RUN from CLI.
  8.  
  9. cr ." loading MyConsole.f..." 
  10.  
  11. Global MyConsoleID   0 to MyConsoleID
  12.  
  13.  
  14. \ open a console if we are running in background and are in a turnkey
  15. \ 0$addr is a string defining the console as in:
  16. \      0" CON:0/10/640/120/ Multi-Forth "
  17.  
  18. \ If value zero is given for the 0$addr; a default console is opened
  19.  
  20. : ?open.console  ( 0$addr-- )
  21.     depth 0= if 0 then  locals| 0$addr |
  22.     background @ BOOLEAN ?turnkey AND
  23.     IF 0$addr 0=
  24.        IF    0" CON:0/10/640/100/Multi-Forth "
  25.        ELSE  0$addr
  26.        THEN
  27.        open dup to MyConsoleID
  28.        IF   MyConsoleID dup  INFILE ! OUTFILE !
  29.        ELSE
  30.             error" Unable to open Console!..."
  31.        THEN
  32.     ELSE
  33.        0 to MyConsoleID
  34.     THEN ;
  35.  
  36.  
  37. \ close the console if it was open
  38.  
  39. : ?close.console  ( -- )
  40.     MyConsoleID ?dup
  41.     IF  close
  42.         INFILE off  OUTFILE off
  43.         0 to MyConsoleID
  44.     THEN ;
  45.  
  46.