programming tools for Windows applications development
  Home  |   SwiftForth Archive  |   SwiftX Archive  |

Re: argc & argv

From: Jeff <jma_at_mfire.com>
Date: Tue, 25 Nov 2003 23:09:06 -0700

Hello Carlos,

I just figured this one out, myself, about a month ago. Here's some
sample code to help get you started with a few samples:

requires dosbox
requires fpmath

\ check the "-mb" flag
: -mb ( a u -- flag )
        s" -mb" compare 0= dup if ( TODO ) then ;

\ check the "-o" flag
: -o ( a u -- flag )
        s" -o" compare 0= dup if ( TODO ) then ;

\ check the "-debug" flag
: -debug ( a u -- flag )
        s" -debug" compare 0= dup if ( TODO ) then ;

\ parse the command line, check all known flags
: -flags ( a u -- )
        2dup -mb if 2drop exit then
        2dup -o if 2drop exit then
        2dup -debug if 2drop exit then

        \ no command line option, handle last argument
        ( a u ) ." Last argument: " type cr ;

\ parse all the command line options
: parse-cmdline ( -- )
        cmdline argc 0 ?do cmdline i argv -flags loop ;

\ entry point
: go ( -- )
        dos-console OPEN-PERSONALITY parse-cmdline ;

--
Best regards,
 Jeff                            mailto:jma_at_mfire.com
----------------------------------------------------------------------
sftalk_at_forth.com      The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users.  For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Tue Nov 25 2003 - 22:16:34 PST

This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:34 PST