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

OS_ReadVarVal

OS SWI Calls
» OS_ReadVarVal

OS_ReadVarVal

(SWI &23)
Entry
R0 Pointer to wildcarded name
R1 Pointer to buffer
R2 Length of buffer, or -ve to check existence/read length
R3 Name pointer, or 0 for 1st call
R4 3 to expand macros and numbers to strings
Exit if R2 on entry was negative (read length)
R0 Corrupt (pointer to error)
R1 Preserved
R2 NOT (length), or 0 if variable does not exist
R3 New name pointer
R4 Variable type
Exit if R2 on entry was positive (read value)
R0 Preserved
R1 Preserved
R2 bytes read
R3 new name pointer
R4 Variable type

Use

The purpose of this call is to read a variable’s value

Notes

This SWI returns type and value of a variable. To check if it exists or find its length, call with R2 < 0. If the variable does not exist R2 will be 0. Otherwise the length is given by NOT(R2), although for anything other than a string variable (type 0) this is the unexpanded length. For either case an error will be returned.

RISC OS 2 does not let you read the length; it merely returns R2 negative to indicate the variable exists. On RISC OS 2 variables are limited to 256 bytes. Returned strings are not zero terminated (and may contain embedded zero bytes). Code variables seem to be indistinguishable from string variables (type 0). Numeric variables are written as 4 bytes in the buffer if expansion is not requested.

This SWI is marked as being re-entrant, which would allow it to re-enter the same code variable’s read code. No note is made about this in OS_SetVarVal and the code variable example in the PRM calls OS_Byte 135 which has undefined re-entrancy.

See also

  • OS_Byte 135
  • OS_ReadVarVal Variable Types
  • OS_SetVarVal
Revised on November 12, 2017 08:26:06 by Alan Robertson (52) (49.192.18.196)
Edit | Back in time (1 revision) | See changes | History | Views: Print | Source | Linked from: OS SWI Calls, Variable Type Code, OS_SetVarVal, Error Generators, *Show, System Variables, OS_ReadVarVal Variable Types, OS SWI Calls (français)

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