Miscellaneous

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 two 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;
FieldExplanation
inOptional input stream. Could for example be used to read data from a file but still read parameters from command line
argCommand line parameters
outOutput stream
errorError stream that could be used to report errors without corrupting the output format of the output stream
callerOptional reference of the command caller object
resultValue 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.

ModuleCommandDecription
CPUIDOverviewProcessor information
CPUIDShow ["-d"|"--details"] "~"Show CPUID information. Assumption: All processors are the same in multi-processor systems
FSToolsOverviewFile system commands
FSToolsCopyFiles [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)
FSToolsCopyTo sourcepath destinationpath {filenames} "~"Copy all listed files from sourcepath to destinationpath
FSToolsCreateDirectory path "~"Create the specified directory
FSToolsDeleteDirectory path "~"Delete the specified directory
FSToolsDirectory ["-s"|"--size"] ["-t"|"--time"] [mask] "~"List all files the match the filemask, optionally show the file sizes and file creation times
FSToolsMount 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)
FSToolsRenameFiles [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)
FSToolsSafeEnter safe mode, see Unsafe
FSToolsSetDefault 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
FSToolsUnmount prefix ["/f"] "~"Unmount the file system with the name prefix. The force option forces unmounting even if the file system is the system volume
FSToolsUnsafeEnter 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
FSToolsWatch [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
PCIToolsOverviewAutomatic hardware detection and PCI device information
PCIToolsScan ["-d"|"--details"] "~"List information about PCI devices found in the system
PCIToolsDetectHardwareLoad 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)
SystemToolsOverviewAccess to system functions
SystemToolsCollectGarbageInvoke the garbage collector
SystemToolsDoCommands {command "~"} "~"Sequentially execute a list of commands
SystemToolsFree {modulename} "~"Try to unload the specified list of modules
SystemToolsFreeDownTo modulename "~"Unload all modules that import the specified module and the specified module itself
SystemToolsIsLoaded modulename "~"Show whether the specified module is currently loaded or not
SystemToolsKill processID "~"Kill the process with ID processID
SystemToolsList ("plugins"|"modules"|"commands" modulename) "~"Call ListPlugins, ListModules or ListCommands
SystemToolsListCommands modulename "~"Show all commands of the specified module
SystemToolsListModulesShow a list of all currently loaded modules
SystemToolsListPluginsShow all currently installed plugins
SystemToolsLnWrite new line character to output stream
SystemToolsPowerDownShutdown the system
SystemToolsRebootReboot the system
SystemToolsRenameExtension oldExtension newExtension "~"Rename the extension of all files with extension oldExtension to ''newExtension
SystemToolsRepeat nofTimes command "~"Execute the specified command nofTimes
SystemToolsShow string "~"Write string to output stream
SystemToolsShowFile filename "~"Write the content of the specified file to the output stream
SystemToolsTimeWrite the current system time to the output stream
SystemToolsTimer ("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
SystemToolsVersionWrite A2 version string to output stream
SystemToolsWhoImports 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.

Copyright (C) 2007 ETH Zürich
August 01, 2014, at 12:42 PM
http://www.ocp.inf.ethz.ch/wiki/Documentation/Miscellaneous