Variable storage and scope (2)

Beside normal QM variables, you also can also use other media to store data.

Environment variables

When QM starts, it receives copy of system environment variables. You also can create and use your own environment variables. Your environment variables exist until QM exits (differently than normal global variables, that are destroyed when loading other file or reloading current file). Environment variables are strings.

 

To get/set/delete environment variables, use functions GetEnvVar and SetEnvVar.

 

QM file commands, menus and toolbars automatically expand environment variables. See also: str.expandpath.

Window properties

To associate some values with a window, you can use window properties. A window property is some numeric value (it can be int, pointer or lpstr), which has some name and can be set/retrieved/deleted using functions SetProp, GetProp and RemoveProp. Examples:

 

RECT* r
r._new
SetProp(hwnd "ra" r)
...
r=+GetProp(hwnd "ra")
RemoveProp(hwnd "ra")
r._delete

 

Registry

You can use functions rget and rset to save variables to the registry.

Shared memory

You can use function share to share memory with other programs.

Dll variables

Some dlls export variables. You can declare such variable as dll function, but you cannot use it directly as variable. Instead, use it indirectly through reference or pointer variable. Example:

 

dll adll #_variable
int+& _var = &_variable
 now _var can be used as dll variable _variable