home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / newfile.seq < prev    next >
Text File  |  1990-07-07  |  2KB  |  31 lines

  1. \ NEWFILE.SEQ   Create a new file, and edit it.         by Tom Zimmer
  2.  
  3. defined edit nip 0= #if \s #endif       \ stop loading if EDIT not defined
  4.  
  5. only forth also definitions hidden also
  6.  
  7. : newfile       ( t1 --- )      \ Open an existing file or CREATE a new one.
  8.                 bl word c@ 0=                       \ if no name on line
  9.                 if      cr ." Filename to create? "             \ prompt him
  10.                         #out @ #line @ here dup off 24 lineeditor 0=
  11.                         here c@ 0= or abort" No file specified"
  12.                 then    here
  13.                 seqhandle dup>r hclose drop         \ close any file open
  14.                 r@ $>handle                         \ move name to SEQHANDLE
  15.                 r@ hopen                            \ if we can't open it then
  16.                 if      r@ hcreate                  \ create the new file
  17.                         abort" Create file FAILED"  \ abort if we can't
  18.                         2573                        \ decimal for CRLF
  19.                         sp@ 2 r@ hwrite 2drop       \ write an empty line
  20.                         r@ hclose drop              \ update the directory
  21.                         r@ hopen drop               \ for the new file
  22.                 else    ." \1 File already exists! "
  23.                         1 seconds                   \ warn already exists
  24.                 then    r>drop
  25.                 0 edit ;                            \ enter editor
  26.  
  27. ' newfile is makefile
  28.  
  29. ' newfile alias sed             \ for compatibility with F-PC 2.25
  30.  
  31.