[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gforth] (novice) looking for example to use somevar=argv[1] ??
From: |
Joel Rees |
Subject: |
Re: [gforth] (novice) looking for example to use somevar=argv[1] ?? |
Date: |
Sun, 18 Jun 2017 07:30:35 +0900 |
On Sun, Jun 18, 2017 at 5:47 AM, Francois Pussault
<address@hidden> wrote:
> Hello
>
> I don't understand the official doc page
> https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/OS-command-line-arguments.html
> 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
Shell command line arguments generally indicate many things, including
numbers. That means that, when a program looks at a command line
argument, it is looking at a text string -- a string of characters. It is up to
the program to convert that string to a number if the program wants a
number.
Take a look and "Line input and conversion" for some clues about how to
do that:
https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Line-input-and-conversion.html#Line-input-and-conversion
It seems to be about converting text from the keyboard, but the same
principles should apply.
The words >number , >float , s>number? , and s>unumber? are of
particular interest.
--
Joel Rees
One of these days I'll get someone to pay me
to design a language that combines the best of Forth and C.
Then I'll be able to leap wide instruction sets with a single #ifdef,
run faster than a speeding infinite loop with a #define,
and stop all integer size bugs with my bare cast.
http://defining-computers.blogspot.com/2017/06/reinventing-computers.html
More of my delusions:
http://reiisi.blogspot.com/2017/05/do-not-pay-modern-danegeld-ransomware.html
http://reiisi.blogspot.jp/p/novels-i-am-writing.html