[Coco] (D)ECB and command-line arguments

William Astle lost at l-w.ca
Thu Jun 19 10:51:45 EDT 2014


On 14-06-19 07:07 AM, Mark McDougall wrote:
> I had the idea of using something like:
>
> EXEC :arg1, arg2, ...

Actually, that should work. EXEC is a normal basic statement and can 
appear normally anywhere on a line.

You have to manually check for the colon at the current input character. 
You can't just call the routine at $9F to see if you have a colon - with 
a syntactically correct EXEC statement, that will be the first character 
*after* the colon. Call the routine at $A5 to see if you're at a colon. 
If you don't have a colon, do something like a syntax error.

The reason you have to do this check is because DECB doesn't actually 
throw an error on extra characters after the statement arguments until 
it goes to parse the next statement.

You will need to be wary of the fact that basic keywords will be 
tokenized in statements following the colon. If you're looking for 
regular numeric expressions and the like, that should be fine.

If you want a bare string as an argument, you're better off using 
something like:

EXEC `ARGS HERE

The ' statement is tokenized as a colon followed by its token value 
(which I'd have to look up) so you would still be looking for a colon 
following the EXEC. Then you would check for the ' token at which point 
you would be able to go on with parsing it as you see fit.

You could also use:

EXEC:REM ARGS HERE

This would be detected the same as the ' option above but using the 
token for REM.

Any of the above will work whether the execution address was specified 
or not.


More information about the Coco mailing list