Showing changes from revision #1 to #2:
Added | Removed | Changed
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 |
The purpose of this call is to read a variable’s value
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.