AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
=>     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.

if R2 was -ve (read length)
<=     R0 corrupt (pointer to error)
     R2 =     NOT (length), or 0 if variable does not exist.
     R3 =     new name pointer
     R4 =     Variable type

if R2 was +ve (read value)
<=     R0 preserved
     R2 =     bytes read
     R3 =     new name pointer
     R4 =     Variable type

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 &87 which has undefined re-entrancy. D'oh.

See PRM 1, page 309.

[sh-index] Back to list of manuals