This column has introduced 'system variables' several times and also mentioned that the SWI "OS_ReadVarVal" is used to read their values.
This SWI is a little complicated to describe fully in this column (translation: "I haven't yet managed to understand it all!") but for use when the specified system variable definitely exists, the following will help:
BlockSize%=256 DIM Block% BlockSize% PRINT FNreadsysvariable("Obey$Dir") END DEF FNreadsysvariable(SysVar$) LOCAL Len% SYS"OS_ReadVarVal",SysVar$,Block%,BlockSize%,,3 TO ,,Len% Block%?Len%=13 =$Block%
Note that the value returned is always a string - although it might sometimes look like a number, in which case you may then have to use VAL to convert it for use afterwards. In the above example, the result is obviously going to be a directory specification string.
You can also use this SWI to check if a particular system variable exists. Further, a wildcarded name can be used for SysVar$, and all matches can then be found in sequence. But that is another story...
Source: | Archive Magazine - 12.10 - "Learners' Column" |
Publication: | Archive Magazine |
Contributor: | Ray Favre |