Environment Variables
Environment variables can be used to store a sequence of characters which can be instanciated or manipulated using the SET, XSET or LET commands from either the WinOne® prompt or at various points within a batch program.
Standard Environment Variables
Standard environment variables have the format %name%. For example, %COMSPEC% inside a batch program will be replaced with D:\WINDOWS\SYSTEM32\CMD.EXE. This value is system dependent and may vary from system to system.
Multi-dimensional Environment variables
Multi-dimensional environment variables have the following syntax :-
NAME.INDEX1.INDEX2.INDEX3....
where NAME is the name of the environment variable and INDEX1, INDEX2 and so on specifies the index values, which may either be an integer value or the name of another environment variable which contains an integer value. Consider the following example, where the index value is specified by the contents of another environment variable :-
SET idx=0
SET array.idx=10
ECHO %array.idx%
When WinOne® encounters the environment variable array.idx then the idx part is replaced with the contents of the idx environment variable, mapping the final name to array.0. The environment variable array.0 is then created and assigned the value 10. The ECHO command will display the value 10. Continuing from the above example ::-
LET idx=%idx% + 1
SET array.idx=20
ECHO %array.idx%
Now the environment variable idx will contain the value 1 and the environment variable array.1 is created and assigned the value 20. The ECHO command will display the value 20. Continuing from the above example :-
FOR %%i is 0 to 1 DO ECHO %array.%%i%
the FOR loop is identical to the following :-
ECHO %array.0%
ECHO %array.1%
and will display the value 10 on the first line and the value 20 on the second line.
Dynamic Environment Variables
Dynamic environment variables are environment variables that contain values that are determined dynamically, that is, at the time they are instanciated. The following dynamic environment variables are allowed :-
| ERRORLEVEL | Last errorlevel set |
| DATE_FORMAT | System date format string |
| DATE_TODAY | Current date (formatted according to DATE_FORMAT) |
| DATE_YEAR | Current year (yyyy) |
| DATE_MONTH | Current month (mm) |
| DATE_DAY | Current day (dd) |
| DATE_DAYOFWEEK | Current day of the week (0=Sun) |
| TIME_TODAY | Current time (hh:mm:ss in 24 hour format) |
| TIME_HOUR | Current hour (hh as 24 hour) |
| TIME_MINUTE | Current minute (mm) |
| TIME_SECOND | Current second (ss) |
| DISK_DRIVE | Current disk drive letter (A, B, C ...) |
| DISK_PATH | Current working directory. |
| SCREEN_WIDTH | Current screen width |
| SCREEN_HEIGHT | Current screen height |
| WHERE_X | Horizontal cursor location (starting from 0) |
| WHERE_Y | Vertical cursor location (starting from 0) |
| WINDOWS_VERSION | Windows version number |
| WINONE_VERSION | WinOne® version number |
| WINONE_PATH | WinOne® home directory |
| WINONE_FILENAME | Full path of the WinOne® executable |
| OPERATING_SYSTEM | Operating system (WinNT, Win32s or OTHER) |
| RANDOM_NUMBER | Random number (0 to 65534) |
To use these dynamic environment variables, enclose the name in between percentage characters. For example to display the system date format, enter at the WinOne® prompt :-
The system date format string displayed is system dependent and may vary from system to system.
|