Diff for /gforth/doc/gforth.ds between versions 1.122 and 1.123

version 1.122, 2004/01/18 22:00:21 version 1.123, 2004/01/19 07:41:03
Line 8899  gforth -e "123 456" foo.fs -e bye Line 8899  gforth -e "123 456" foo.fs -e bye
   
 However, you may want to interpret the command-line arguments directly.  However, you may want to interpret the command-line arguments directly.
 In that case, you can access the (image-specific) command-line arguments  In that case, you can access the (image-specific) command-line arguments
 through the variables @code{argc} and @code{argv}. @code{arg} provides  through @code{next-arg}:
 convenient access to @code{argv}.  
   
 doc-argc  doc-next-arg
 doc-argv  
 doc-arg  
   
 @code{0 arg} is the program name with which you started Gforth.  The  Here's an example program @file{echo.fs} for @code{next-arg}:
 next unprocessed argument is always @code{1 arg}, the one after that is  
 @code{2 arg} etc.  All arguments already processed by the system are  
 deleted.  After you have processed an argument, you can delete it with  
 @code{shift-args}.  
   
 doc-shift-args  
   
 Here's an example program @file{echo.fs} using @code{arg} etc.:  
   
 @example  @example
 : echo ( -- )  : echo ( -- )
     begin      begin
         argc @ 1 > while          next-arg 2dup 0 0 d<> while
             1 arg type space              type space
             shift-args      repeat
     repeat ;      2drop ;
   
 echo cr bye  echo cr bye
 @end example  @end example
Line 8933  This can be invoked with Line 8922  This can be invoked with
 gforth echo.fs hello world  gforth echo.fs hello world
 @end example  @end example
   
   and it will print
   
   @example
   hello world
   @end example
   
   The next lower level of dealing with the OS command line are the
   following words:
   
   doc-arg
   doc-shift-args
   
   Finally, at the lowest level Gforth provides the following words:
   
   doc-argc
   doc-argv
   
 @c -------------------------------------------------------------  @c -------------------------------------------------------------
 @node Locals, Structures, Other I/O, Words  @node Locals, Structures, Other I/O, Words
 @section Locals  @section Locals

Removed from v.1.122  
changed lines
  Added in v.1.123


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>