commandline arguments

30 views
Skip to first unread message

Eulenspiegel

unread,
Dec 12, 2023, 5:13:12 AM12/12/23
to 4tH-compiler
Hi I'm a tcl user.

For speeding up some calculations and because maths is quite ugly in tcl I want to use 4tH. At the moment I use yabasic (damn simple). But future tasks might be better implemented in Forth.
For  calculating the distance I push over geodata as commandline arguments. When I tried the example code from the manual (10.8) I just got an error.

>> 4tH library v3.64 - Copyright 1994,2022 J.L. Bezemer
>> Compiling; Word 5: Undefined name

I saved the example code and ran: "4th cx scriptname.fs Hallo Welt"

What's wrong with my code or the settings?

Greetings from Germany!

The Beez

unread,
Dec 12, 2023, 5:29:46 AM12/12/23
to 4tH-compiler
Hi!

I assume you used this one:

argn 0> if argn 0 do i args type cr loop then

And actually - there is nothing wrong with it! Lemme show you:

$ cat ex2.4th
argn 0>
if
argn 0 do
i args type cr
loop
then
$ 4th cx ex2.4th Hello Welt

4tH library v3.64 - Copyright 1994,2022 J.L. Bezemer
ex2.4th
Hello
Welt
$

I even went as far as:

$ 4th cx scriptname.4th Hello Welt

4tH library v3.64 - Copyright 1994,2022 J.L. Bezemer
scriptname.4th
Hello
Welt
$

Now first, if you encounter a problem I advise you to dump the code. Like this:

$ 4th cd scriptname.4th Hello Welt

4tH library v3.64 - Copyright 1994,2022 J.L. Bezemer
4tH message: No errors at word 11
Object size: 11 words
String size: 0 chars
Variables  : 0 cells
Strings    : 0 chars
Symbols    : 0 names
Reliable   : Yes

  Addr| Opcode                        Operand   Argument

     0| argn                                0
     1| 0>                                  0
     2| 0branch                            10
     3| argn                                0
     4| literal                             0
     5| do                                 10
     6| r@                                  0
     7| args                                0
     8| type                                0
     9| cr                                  0
    10| loop                                5
$


It will at least gimme something more to work with ;-)

I can just assume that some kind of control character has found its way into your code - causing it to misbehave. Or may be you typed it in yourself and made a tiny little error doing it. Next time, please include the code. Since this is a google group, you can. 

But to get you going, I added the script here. It should work fine - since it is the same script I used. And no additional libraries are required to run it. 4tH requires very few settings and those do not come into play here. Hope this helps

Hans Bezemer
  

scriptname.4th

Eulenspiegel

unread,
Dec 12, 2023, 4:10:40 PM12/12/23
to 4tH-compiler
Oh boy! What a bad start! Seems so that I saved the code in an other file. Runs like clockwork. I'm so sorry ...

The Beez

unread,
Dec 13, 2023, 7:00:26 PM12/13/23
to 4tH-compiler
Well, don't be sorry. Everybody makes mistakes and I'm always happy to help. So next time you run into something, don't hesitate to ask.

Hans Bezemer

Reply all
Reply to author
Forward
0 new messages