RISC OS Open
Safeguarding the past, present and future of RISC OS for everyone
ROOL
Home | News | Downloads | Bugs | Bounties | Forum | Documents | Photos | Contact us
Account

Introduction To *Commands

Programmer's Reference Manuals
ยป Introduction to *Commands

*Commands provide a simple method of accessing key functionality provided by RISC OS. A wide range of *Commands is provided by RISC OS for a range of tasks such as file manipulation, updating date and time, using sound and graphics, networking and system configuration.

The advantages of *Commands are:

  • Simple to use
  • Easily typed
  • May be call within applications/programs
  • Provides powerful features

The disadvantages of *Commands are:

  • Not as flexible as SWIs
  • Limited scope to return information back to a program (output is normally directed straight to screen)

There will be instances when it is more appropriate to use a SWI rather than a *Command, and vice-versa.

Issuing *Commands

*Commands can be used in the following ways:

  • From within Programming Languages, such as BASIC, C/C++, or Assembler
  • Typed via the Command Line Interpreter (CLI)
  • From within applications

When a *Command is used, RISC OS passes the text to OS_CLI. This determines which routine(s) should be called to perform the required action.

Calling from BASIC

*Commands can be called from within BASIC by issuing them directly (e.g. *Help). Using the OSCLI *Command provides a method of passing variables:

cmd$ = "Time"
OSCLI "Help " + cmd$	:REM Issues the *Help Command for Time 

The final method available from BASIC is passing the *Command string to the SWI OS_CLI.

SYS "OS_CLI", "*Help"

Calling from Assembler

*Commands can be called from Assembler by passing the *Command string to the SWI OS_CLI. A null byte terminating the command string is required.

Calling from C

[TO DO] Calling from C

Modular nature of *Commands

Because RISC OS is a modular Operating System, *Commands can be altered, added and even replaced. This can be done by claiming vectors, replacing modules, or adding new modules.

When a vector is claimed, it affects how a SWI that uses it works. The same applies for *Commands.

As well as providing a number of SWIs, modules may also provide *Commands. If a module is to be replaced, the replacement must provide the same commands with the same syntax and accept the same parameters (if any). A replacement module may also provide extra *Commands.

New modules can be added to RISC OS to provide new functionality. There is no limit to how many *Commands can be added to the system.

Changing and adding *Commands

By using system variables, it is possible to create new *Commands from existing ones, or to rename existing *Commands. This can be achieved by using an Alias$command variable, where command is the name of the existing command. The example below defines a new command *Mode which changes to the screen mode to the number given after the command.

*Set Alias$Mode echo |<22>|<%0>

See also

Index of *Commands
Modules
Software Vectors
System Variables

Revised on January 17, 2015 09:35:51 by Mike Freestone (2564)? (91.84.95.65)
Edit | Back in time (4 revisions) | See changes | History | Views: Print | Source | Linked from: Programmer's Reference Manuals, CLI Basics, CLI Basics part 1

Search the Wiki

Social

Follow us on and

ROOL Store

Buy RISC OS Open merchandise here, including SD cards for Raspberry Pi and more.

Donate! Why?

Help ROOL make things happen – please consider donating!

RISC OS IPR

RISC OS is an Open Source operating system owned by RISC OS Developments Ltd and licensed primarily under the Apache 2.0 license.

Navigation

  • Home Page
  • All Pages
  • Recently Revised
  • Authors
  • Feeds
Site design © RISC OS Open Limited 2018 except where indicated
The RISC OS Open Instiki theme is based on Insitki's default layout

Valid XHTML 1.0  |  Valid CSS

Instiki 0.19.1(MML+)
This site runs on Rails

Hosted by Arachsys