Bob,
On 10/2/2000 at 4:38 AM Bob Dickow wrote:
>(1) How do I get command line arguments ala argc and argv? There are
>argc words, etc., but they must be actions for a class or something. But
>what class?
>I have set up the system to run my application when double clicking on
>one of its associated data files, but my app doesn't know how to load in
>the file that executed it, yet.
To understand the command line arguments, the easiest way to experiment
is by starting swiftforth from a dosbox command line. So:
cd \swiftforth\bin
.\sf ( here are the arguments)
now swiftforth opens. let's look:
SwiftForth 2.03.5 29sep2000
cmdline argc . 5 ok
cmdline 0 argv type ( ok
cmdline 1 argv type here ok
cmdline 2 argv type are ok
cmdline 3 argv type the ok
cmdline 4 argv type arguments) ok
ARGC ( addr len -- n )
How many blank delimited substrings in a string.
ARGV ( addr len n -- addr len )
Return the nth (starting at zero) blank delimited substring.
The code from the sources is attached at the end.
>(2) How do I replace the SwiftForth default program icon such that my
>turnkeyed executables show my own custom icon rather than the SwiftForth
>'cross-hatch' icon on the desktop? Is this something in the registry or
>something, I bet?
When you save the program, a second parameter can specify an icon
file in standard 32x32 16 colors. THe size of such a file is exactly
766 bytes -- no other size is currently supported.
Rick
{ --------------------------------------------------------------------
Simple command string parsing.
These words are useful for parsing command lines, which may contain
words, numbers, or single character options.
ARGC returns the number of blank delimited words in the string.
ARGV returns the Nth word (counting from zero) in the given string.
ATOI converts a counted string to a simple integer. Returns 0 if
it fails. 0x preceeds hex numbers; all others are decimal.
GETC removes the first character from the string and returns it.
-------------------------------------------------------------------- }
?( Command line access)
: ARGC ( addr len -- n )
0 BEGIN ( addr len n)
>R BL SKIP
?DUP WHILE
BL SCAN R> 1+
REPEAT DROP R> ;
: ARGV ( addr len n -- addr # )
0 ?DO
BL SKIP BL SCAN
LOOP
BL SKIP OVER SWAP BL SCAN DROP OVER - ;
: ATOI ( a n -- n ) BASE @ >R
OVER C@ [CHAR] - = DUP >R IF 1 /STRING THEN
OVER H@ $2020 OR $7830 = IF ( 0x format use hex) HEX 2 /STRING THEN
0 0 2SWAP >NUMBER 2DROP DROP R> IF NEGATE THEN
R> BASE ! ;
: GETC ( a n -- a+1 n-1 c )
DUP IF
OVER C@ >R 1 /STRING R>
ELSE DUP THEN ;
Received on Mon Oct 02 2000 - 06:23:10 PDT
Subscribe to our e-mail list service. It's free for all SwiftForth and SwiftX users!
This archive was generated 09-Feb-2012. Archive updated nightly.