AgonConsole8 / agon-mos

Official AGON QUARK Firmware for Console8: eZ80 MOS
MIT License
25 stars 10 forks source link

System variables (and macros) #54

Open stevesims opened 5 months ago

stevesims commented 5 months ago

We currently have an expanding number of things within MOS where strings of text are stored (e.g. command history, hotkeys), and we have a growing number of pieces of system information that can be set or read (keyboard type, time, etc). Future expansions to this may be providing a mechanism to change the current command prompt, and to adjust the search path used when running commands.

It would be good to expose these pieces of information in a more convenient way.

On the Archimedes, Acorn added system variables to accomplish this. For instance, a function key definition for F1 is found in a system variable named Key$1, the CLI prompt is in a variable named CLI$Prompt. Lots of other information is also made available via system variables, which allows for some potentially sophisticated scripting options and system control.

This system for instance means that F1 can be set in two different ways: *key 1 Foo or *set Key$1 Foo - both commands have exactly the same effect. Arguably the former is there for convenience, and/or backward compatibility with older Acorn systems.

Additionally these variables could be macros. Setting the CLI prompt to show the time before a star can be done using the following command:

*setmacro CLI$Prompt <Sys$Time> *

(You can even use setmacro to set a function key to have a string that includes system variables.)

Viewing variables/macros is done via *show. Using *show with no arguments will show all of the current variables. It can also be used with a single argument to show a specific variable, or an argument with a wildcard to show any/all that match.

It is suggested that we should implement a very similar system on Agon MOS.

Once these variables are in place, we can look to implement other features that can make use of them. An echo command for instance that interpolates in variables into its output. There are lots of possibilities

Information on Acorn's system can be found here: http://www.riscos.com/support/developers/prm/systemvars.html