SuivantPrec.Bas prec.BasNiv. sup.

Chapter 2 Using ASET 

ASET is designed as a utility to enhance DOS batch files, as well as kind of a desktop calculator. Besides, it can help to install and configure your software.

There are two modes of operation:

Command line operation: This is the default mode, which is used whenever ASET is started without the /f switch. Some examples for command line mode are

 ASET LIB='C:\LIB'
 ASET SORT=DOSPATH('SORT.EXE')
 ASET RESULT=sin(%PHI%)+%X%*COS(%PHI%)
One disadvantage of this mode is that DOS must load ASET into memory whenever it is invoked. This may become slow because of its size. One way to avoid this, is the file operation mode (ASET will have to be loaded only once for an arbitrary number of assignment operations). Look below for the useful -r option.

File operation: This mode is used if ASET is invoked with the /f switch. It then reads its input from a file, not from the command line. This file is expected to contains lines like the above. There can be an arbitrary number of these lines. Empty lines or lines starting with '#' are treated as comment lines, and ignored. Lines longer than 255 characters are truncated.

If you use /f without an argument, ASET reads commands from the standard input. Examples:

 ASET /fMYINST.CMD
 CMDGEN | ASET /f /n
 ASET /n /f
In the first example, ASET will read its commands from MYINST.CMD. This gives you a nice possibility to store several configuration settings in different files, and let ASET execute one of them according to your installment needs.

In the second example, CMDGEN is expected to write ASET commands on standard output. ASET will then read these commands and execute them.

The third example shows how ASET can be used as a calculator. It reads commands from the keyboard until you input Ctrl/Z. This behaviour is due to the empty filename parameter of the /f switch. See below for the /n switch.

Besides the /f option which switches between command line and file mode, there are some other options:

-e Normally, ASET sets a shell variable to a value which is calculated in a certain formula. It then finishes operation. -e lets ASET set the ERRORLEVEL in addition to the shell variable. The ERRORLEVEL can only be set to values 0..255. This makes it necessary to make some assumptions: Note that -e makes it impossible to determine whether ASET has been invoked with -h, -H, or -v (in these cases the ERRORLEVEL is set to 1) or if a runtime error occurred (in which case it is set to 255). The -e switch can be a powerful enhancement to your batch files. Consider the following batch file:
 REM
 REM   Check if there's enough memory for the installation
 REM
 ASET -e -n DUMMY := DISKFREE('C:') gt 1000000
 IF ERRORLEVEL 1 GOTO OKAY
 ECHO Installation Error
 ...
The above ASET command will compute the free bytes on drive C: and check if the value is larger than 1 Megabyte. If this is so, DUMMY is assigned the value 1 (for boolean TRUE), otherwise 0 (boolean FALSE). The switch -e makes ASET set the ERRORLEVEL accordingly, ie. in this case that ERRORLEVEL will be 1.

You may wonder why I built in the -e facility, because it would also have been possible to write

 REM
 REM   Check if there's enough memory for the installation
 REM
 ASET DUMMY := DISKFREE('C:') gt 1000000
 IF %DUMMY%==1 GOTO OKAY
 ECHO Installation Error
 ...
The problem with this is, however, that you assign a new shell variable which may cause problems, (a) because you cannot be sure that the name of the variable has already been used in the current environment (which will result in a loss of the previous value) and, (b) if you invoke the above batch file in a subshell, there is likely no more space in the system environment table for a new variable. -e is the solution to both problems.
-n ASET will not modify the environment. It only calculates the result and displays it, if -e is not specified. If -e is specified together with -n, nothing is displayed (unless you force it with -p, of course). -n is useful if you want to use ASET as a calculator only or if you want ASET to set the ERRORLEVEL without modifying any environment variables.
-p ASET will show the result on standard output in addition to modifying the environment.
-r ASET will repeat the assignment on standard output before actually executing it. This eases debugging in file mode.
SuivantPrec.Bas prec.HautNiv. sup.