thomasrapp wrote: ↑Tue Jun 02, 2020 4:13 pm
You should keep in mind that the argument substitution in scripts is a textual one. So if you run the script without any arguments the line IF NOT {loop} becomes IF NOT. This does not make any sense. To be honest, even if you supply arguments, for example, "4", it still makes no sense for me.
I see what you mean and I share your view. As I said, the example was taken from the official AmigaOS 3.1 DOS Guide, and I was just wondering about the different outcome of the script.
I interpreted the statement as below, and maybe it is how the author of the text and whoever wrote the "IF" command back then, might have thought of it, oh, and btw, read it and imagine Yoda from StarWars speaking:
Code: Select all
IF NOT (given the argument) {loop} (was, then)
DOWHATEVERCOMESNEXT
ELSE (if the argument given was)
DOTHISINSTEAD
ENDIF
and then
What shall IF NOT 4 do?
IF NOT 4 (yes, it's true: because 4 is 4; it is using the reflexive relation, if no 4 was given, then this would be false)
Well, that is how I tried to make sense of it anyway. Now, your examples are more of an immediate logic

hopefully, "IF" is going to be fixed on AmigaOS 3.2 too, so the experience is more cohesive.
About your examples: thanks. The second example is ehm.. prettier but it did not work right away,
Code: Select all
3.RAM Disk:> ram:testscript5 0
argument given
IF: wrong number of arguments
3.RAM Disk:>
I had to swap the EQ and VAL arguments to "IF $loop VAL EQ 0"; should IF be more tolerant?
And there is a small cosmetic bug when invoking "IF ?" in the shell btw. I'll post that as a reply to nbache.
