[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gforth] (novice) looking for example to use somevar=argv[1] ??
From: |
carl hansen |
Subject: |
Re: [gforth] (novice) looking for example to use somevar=argv[1] ?? |
Date: |
Sat, 17 Jun 2017 18:02:22 -0700 |
On Sat, Jun 17, 2017 at 1:47 PM, Francois Pussault
<address@hidden> wrote:
> Hello
>
> I don't understand the official doc page
I often can't understand it either.
https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/OS-command-line-arguments.html
It says version 7.0, it might or might not be the latest version.
> so I cannot use args.
>
> gforth foo.fs 5 10
> using a code like :
>
> 1 arg type CR
>
> display it ok but as a text so I cannot affect that numbers to variables
>
>
>
>
>
> Cordialement
likewise
> Francois Pussault
> 10 chemin de négo saoumos
> apt 202 - bat 2
> 31300 Toulouse
> +33 6 17 230 820
> address@hidden
>
Joel Rees is on track, s>number? is the key for you. Here is
something I got to work:
\ usage: gforth argtest.fs -e "34333" -e bye
\ this file name is argtest.fs
variable ararg
: getvarnumbers
arg 2dup s>number? if drop ararg ! ." I got a variable! " ararg @ .
else 2drop type
then cr
;
0 dup . getvarnumbers
1 dup . getvarnumbers
2 dup . getvarnumbers
3 dup . getvarnumbers
4 dup . getvarnumbers
ararg @ dup * . ." See? It works! " cr
\ try it like this:
gforth argtest.fs -e "34333" -e bye