var File

The var file is a pseudo file that maps to the user’s TCL shell variables.

Description

The var driver (most easily used via the var file in the dm account) provides access to TCL shell variables via a file interface.

A read using the variable name as the item-ID returns the shell variable’s contents.

A read using a TCL command surrounded by back-quotes executes the TCL command and returns the results as if those results had been stored in an item.

A write using the variable name as the item-ID is identical to running a TCL set on that variable.

A delete using the variable name as the item-ID is identical to running a TCL unset on that variable.

A select/readnext loop is similar to the TCL penv command except that only the variable names are returned. Note that only user-defined variables are returned by the select. Preset and system variables can only be queried by performing a direct read.

Example(s)

open "var"

*

* Read a shell variable

*

print @user

*

read xx from "user"

print xx

*

*

* Write a shell variable

*

execute "set myvar=abc"

*

write "abc" on "myvar"

*

* Delete a shell variable

*

execute "unset myvar"

*

delete "myvar"

*

* Display a list of user variables

*

execute "penv"

*

select

loop

readnext id then print id else exit

repeat

*

* Execute a TCL command

*

execute "display @‘who‘"

*

read xx from "‘who‘"

print xx

See Also

var