Commands
Commands can be executed by
- Mouse: middle-click the command name
- Keyboard: Place the cursor on the command name and then press CTRL-ENTER
The general form of a commands is
Command = CommandName [Parameters] ["~"]
CommandName = ModuleName "." [ ProcedureName ]
Parameters = {Separator} AnyChar
Separator = " " | LineFeed | CarriageReturn | Tab
AnyChar = { 0X..FFX except "~" }
Restrictions:
- LEN(ModuleName) <= LEN(Modules.Name) = 32
- LEN(CommandName) <= WMTextView.MaxCommandLength = 256 bytes
- LEN(Parameters) <= WMTextView.MaxCallParameterBuf = 1024 * 1024 bytes
Notes:
- All names are case-sensitive!!!
- The Separator character is included in the parameter string, the "~" is not
- If the Terminator "~" is omitted, all characters between the CommandName and the end of text (limited by MaxCallParametersBuf size) will be copied into the parameter buffer (even if the command does not accept any parameters). It is therefore recommended to always terminate commands with a tilde.
- Each occurence of the character "^" in the Parameters will be replaced by the most recently selected text (if any)
- If the ModuleName is correct, but the module does not have a valid command with name CommandName, the module will be loaded, but command execution fails
- The command SystemTools.DoCommands is an exception. It requires to subsequent tilde characters to delimit the parameter string. Example: SystemTools.DoCommands SystemTools.Time ~ SystemTools.Time ~ ~.
If you middle click on a CommandName, the system will try to execute the command.
Two kind of command procedures can be executed (must be located in module scope):
PROCEDURE ProcedureName*;
PROCEDURE ProcedureName*(context : Commands.Context);
whereas
Context* = OBJECT
in-, arg- : Streams.Reader;
out-, error- : Streams.Writer;
caller- : OBJECT;
result*: LONGINT;
END Context;
| Field | Explanation |
| in | Optional input stream. Could for example be used to read data from a file but still read parameters from command line |
| arg | Command line parameters |
| out | Output stream |
| error | Error stream that could be used to report errors without corrupting the output format of the output stream |
| caller | Optional reference of the command caller object |
| result | Value that indicates successful (zero or Commands.Ok) or unsuccessful (non-zero) termination of command |
Notes:
- arg, out and error are guaranteed to not be NIL
- in and caller may be NIL
- The output streams (out, error) are buffered! Call out.Update respectively error.Update to flush the buffers
- After command execution is completed, the command runner thread will automatically flush the output streams (out, error)
Example of Commands:
- Load module HelloWorld: HelloWorld.
- Execute command Hello in module HelloWorld: HelloWorld.Hello~
- Execute command Show in module SystemTools with parameter Hello World: SystemTools.Show Hello World~
Nice to know:
- The command SystemTools.DoCommands executes a sequence of commands
- The command SystemTools.Repeat executes a command several times
Command Line Options
The module Options.Mod can be used to parse command line options. For a detailed description of its usage, have a look at the header comment found in the source code.
Example:
PROCEDURE Example*(context : Commands.Context);
VAR
options : Options.Options;
number : LONGINT; string : ARRAY 16 OF CHAR;
BEGIN
NEW(options);
options.Add("n", "number", Options.Integer);
options.Add("s", "string", Options.String);
options.Add("f", "flag1", Options.Flag);
options.Add("g", "flag2", Options.Flag);
IF options.Parse(context.arg, context.error) THEN
IF options.GetInteger("number", number) THEN
context.out.String("Number = ");
context.out.Int(number, 0);
context.out.Ln;
END;
IF options.GetString("string", string) THEN
context.out.String("String = ");
context.out.String(string);
context.out.Ln;
END;
context.out.String("Flag1 = ");
IF options.GetFlag("flag1") THEN
context.out.String("set")
ELSE context.out.String("not set");
END;
context.out.Ln;
context.out.String("Flag2 = ");
IF options.GetFlag("flag2") THEN
context.out.String("set");
ELSE context.out.String("not set");
END;
context.out.Ln;
(* options.Parse will set the position of the argument
stream to the first character after the options
*)
context.arg.GetString(string);
context.out.String("First argument: ");
context.out.String(string);
context.out.Ln;
ELSE
(* error message will be sent to context.error stream
if parsing fails
*)
END;
END Example;
Example usage:
- ModuleName.Example "This is the first string argument" ~ (no options)
- ModuleName.Example -f -g --string="Optional string" --number=1234 "First argument" ~ (all options set)
- ModuleName.Example -fg -s="Optional string" -n=1234 "First argument" ~ (all options set, compact variant)
- ModuleName.Example -s ~ (error: option s requires string parameter)
- ModuleName.Example -u ~ (error: option u unknown)
System Commands
The following table lists some system commands that are used often.
| Module | Command | Decription |
| CPUID | Overview | Processor information |
| CPUID | Show ["-d"|"--details"] "~" | Show CPUID information. Assumption: All processors are the same in multi-processor systems |
| FSTools | Overview | File system commands |
| FSTools | CopyFiles [Options] ({ source "=>" destination } | source destination) "~" | Copy source files to destination files Options: "-o"|"--overwrite": If set, overwrite existing files, otherwise skip "-i"|"--ignore": If set, continue operation in case of errors, otherwise abort "-n"|"--nolist": If set, use source destination argument style (supports wildcards), otherwise use {source "=>" destination} argument style (no wildcards) |
| FSTools | CopyTo sourcepath destinationpath {filenames} "~" | Copy all listed files from sourcepath to destinationpath |
| FSTools | CreateDirectory path "~" | Create the specified directory |
| FSTools | DeleteDirectory path "~" | Delete the specified directory |
| FSTools | Directory ["-s"|"--size"] ["-t"|"--time"] [mask] "~" | List all files the match the filemask, optionally show the file sizes and file creation times |
| FSTools | Mount prefix alias [volpar]["|" fspar] "~" | Mount a volume. The filesystem name will be prefix. alias specifies the file system type (e.g. AosFS, RamFS,...). For physical disks, volpar specifies the partition containing the volume (e.g. IDE0#1) |
| FSTools | RenameFiles [Options] ({source "=>" destination} | source destination) "~" | Rename source files to destination files. Options: "-i"|"--ignore": If set, continue operation in case of errors, otherwise abort "-n"|"--nolist": If set, use source destination argument style (supports wildcards), otherwise use {source "=>" destination} argument style (no wildcards) |
| FSTools | Safe | Enter safe mode, see Unsafe |
| FSTools | SetDefault prefix "~" | When the user does not specified a path for a file, the file systems are search in a specified order. SetDefault can be used to move the specified file system to the list head so that is searched first |
| FSTools | Unmount prefix ["/f"] "~" | Unmount the file system with the name prefix. The force option forces unmounting even if the file system is the system volume |
| FSTools | Unsafe | Enter unsafe mode. Some operations can be extremely dangerous. Example: DeleteFiles -n * ~ would delete all files on all mounted volumes. Such operations can only be executed in unsafe mode |
| FSTools | Watch [prefix] "~" | Show information of the file system named prefix. If the optional argument is omitted, show a list of all file systems in search order |
| PCITools | Overview | Automatic hardware detection and PCI device information |
| PCITools | Scan ["-d"|"--details"] "~" | List information about PCI devices found in the system |
| PCITools | DetectHardware | Load PCI device drivers for all PCI devices in the system (if driver available). Sideeffect: Enable driver database lookups (used by USB subsystem to load USB device drivers on demand) |
| SystemTools | Overview | Access to system functions |
| SystemTools | CollectGarbage | Invoke the garbage collector |
| SystemTools | DoCommands {command "~"} "~" | Sequentially execute a list of commands |
| SystemTools | Free {modulename} "~" | Try to unload the specified list of modules |
| SystemTools | FreeDownTo modulename "~" | Unload all modules that import the specified module and the specified module itself |
| SystemTools | IsLoaded modulename "~" | Show whether the specified module is currently loaded or not |
| SystemTools | Kill processID "~" | Kill the process with ID processID |
| SystemTools | List ("plugins"|"modules"|"commands" modulename) "~" | Call ListPlugins, ListModules or ListCommands |
| SystemTools | ListCommands modulename "~" | Show all commands of the specified module |
| SystemTools | ListModules | Show a list of all currently loaded modules |
| SystemTools | ListPlugins | Show all currently installed plugins |
| SystemTools | Ln | Write new line character to output stream |
| SystemTools | PowerDown | Shutdown the system |
| SystemTools | Reboot | Reboot the system |
| SystemTools | RenameExtension oldExtension newExtension "~" | Rename the extension of all files with extension oldExtension to ''newExtension |
| SystemTools | Repeat nofTimes command "~" | Execute the specified command nofTimes |
| SystemTools | Show string "~" | Write string to output stream |
| SystemTools | ShowFile filename "~" | Write the content of the specified file to the output stream |
| SystemTools | Time | Write the current system time to the output stream |
| SystemTools | Timer ("start" [number]|"elapsed" [number]|"diff" number1 number2) "~" | With start, a timer is started. Elapsed shows the time elapsed on a given timer since started. diff shows the time difference of the start of two timers |
| SystemTools | Version | Write A2 version string to output stream |
| SystemTools | WhoImports moduleName "~" | Show a list of all modules the directly or indirectly import the specified module |
Path
If there are several fileystems mounted, the search path for file lookup can be modified with FSTools.SetDefault name ~, which moves the filesystem with prefix name to the head of the path. The current setting of the path can be queried with FSTools.Watch~. As stated above, the path will be used when the user does not specified a prefix for a file and the file systems are searched in the same order as returned by FSTools.Watch~. See also last section (FSTools entry in table).
WinAos: Mounting an A2 Partition
Run WinAos with administrative priviligies. The execute WinDisks.Install PhysicalDrive0 RW~ and start Partitions.Tool. Now you can mount the A2 partition.