On Sat, Apr 11, 2026 at 01:56:47AM -0500, Shawn K. Quinn wrote:
> Hi,
>
> I'm trying to pass a command line argument to a Gforth program which is the
> name of a directory to change into at program start, where the data files
> are kept. The code in question is:
>
> argc if
> next-arg set-dir
> endif
>
> at the very start of a word called at the start of a word used to replace
> bootmessage.
>
> The error message in question is:
>
> in file included from *args*:1:1:
> Example2026:0:1: error: Is a directory
> >>><<<
> Backtrace:
> /usr/local/share/gforth/0.7.9_20260109/kernel/input.fs:93:25: 0
> $7F7AE0818300 throw
> ...
>
> which seems to mean Gforth is parsing these arguments itself rather than
> passing them on.
>
> The echo.fs example copied verbatim from section 6.25, and called the same
> way, has roughly the same problem:
>
> *args*:2:1: error: No such file or directory
> >>>hello<<<
> Backtrace:
> /usr/local/share/gforth/0.7.9_20260109/kernel/require.fs:112:15: 0
> $7F430EA1ECB8 throw
> /usr/local/share/gforth/0.7.9_20260109/kernel/args.fs:113:28: 1
> $7F430EA1F7C8 execute
>
> Am I missing something or is the documentation just wrong?
I just tried the echo.fs example and it worked as documented:
[a4:~/nfstmp/gforth-amd64:109880] cat <<EOF >echo.fs
> : echo ( -- )
begin
next-arg 2dup 0 0 d<> while
type space
repeat
2drop ;
echo cr bye
EOF
[a4:~/nfstmp/gforth-amd64:109881] gforth echo.fs hello world
hello world
My guess is that you did not include the last line, which invokes
ECHO in the echo.fs example, so the control came back to Gforth's
PROCESS-ARGS, and that then interpreted "hello" as a file name to be
REQUIRED.
Concerning your word that replaces the BOOTMESSAGE, "HELP BOOTMESSAGE"
says:
'bootmessage' ( -- ) gforth-0.4
Hook (deferred word) executed right after interpreting the OS
command-line arguments. Normally prints the Gforth startup message.
So BOOTMESSAGE is only called *after* the command-line arguments have
been processed in the default way, so this cannot have the effect that
you want. Instead, plug your word into "'COLD". Best read the whole
Section "Modifying the Startup Sequence".
- anton