home *** CD-ROM | disk | FTP | other *** search
- ┌──────────────────────────────────────────────────────────────┐
- │ ENHANCED SET INSTRUCTION 2.12 - (C) 1992 STERN Marc │
- └──────────────────────────────────────────────────────────────┘
-
-
- All you always wanted to put in an environment variable and
- never dare to ask DOS for...
-
- XSET: The way to easily write efficient batch files.
-
-
- XSET allows you to put EVERYTHING you want in a variable of
- the current environment and use it as if you gave it the value with
- the standard DOS command 'SET'. You will be able to write very efficient
- batch files including string manipulation, calculation,...
-
- XSET is the more powerful environment variable manipulation
- program you never saw. It also has the easiest and most intuitive
- user interface it is possible to write.
-
-
- XSET is fully compatible with MS-DOS 5.0, DR-DOS 6.0, NDOS & 4DOS 4.0 .
-
-
-
- XSET has five major features:
- ════════════════════════════
-
- - XSET permits to catch the output of any command (internal or external)
- or program and put it into an environment variable.
-
- - XSET has several built-in commands to modify the output of a program
- or a string given on the command-line (extract a part of a string,...)
-
- - XSET has a built-in full floating-point calculation functionalitie:
- ──────────────────────────────────────────────
- You can make incremental loops, input a calculation string and
- output a number,...
-
- - XSET can manage variable contents of more than 128 characters
- (your path can now be as long as you want)
-
- - XSET has some other built-in commands to give you access to some
- system datas (date, time, ...)
-
-
-
- * type XSET with no parameters to have the full description
- of all functionalities (parameters and effects).
-
-
-
- Example of use:
- ══════════════
-
- Rem: in all the examples, the command XSET and the its built-in commands
- are typed in uppercase and the environment variables names are
- in lowercase. This is only for readability; when you type it,
- you may mix lowercases and uppercase as you want.
- The case is only significant for arguments strings you enter on the
- command-line.
- The 'C:>' represents your prompt, do not type it!
-
-
- 1) C:> XSET datvar DATE
- Puts the date into the variable 'datvar'
-
- Type the command SET and you will see all the environment variables:
- ...
- COMSPEC=...
- DATVAR=dd-mm-yy (where dd,mm,yy are replaced by current
- day, month and year)
- ...
-
- You can now use the variable 'datvar' in a batch file:
- ECHO the date is %datvar%
-
- 2) C:> XSET name INPUT "Enter your name: "
- Inputs a string from the keyboard (usual answer terminated by <Enter>)
- and puts it into the variable 'name'.
-
- You can now use the variable 'name' in a batch file to enter
- personal environment for each user:
- ECHO Hello %name%, beginning the work
- CD \%name%
-
-
- 3) C:> CD | XSET dirname
- Puts the output of the command 'CD' (i.e. the current directory name)
- into the variable 'dirname'.
-
- You can write a batch file to go to another directory, execute
- a program and come back into the current one
-
- rem ------------------
-
- CD | XSET dirname
- CD \otherdir
- myprog ...
- cd %dirname%
- set dirname=
-
- rem ------------------
-
-
-
- 4) You can write a batch file with automatic loops
-
-
- rem ------------------
-
- set loop=1
-
- :next
- if %loop% == 20 goto end
-
- .......
- anything you want
- .......
-
- XSET loop MATH %loop% + 1
-
- goto next
-
- :end
-
- rem ------------------
-
-
- 5) You can write a batch file where the user may enter
- a calculation and use it as a number
-
-
- rem ------------------
-
- XSET calc INPUT "Enter your calculation: "
-
- XSET result MATH %calc%
-
- echo %calc% = %result%
-
- rem ------------------
-
-
-
-
- 6) More complex example of a login procedure
-
- rem ---------------------- LOGIN.BAT --------------------------------
-
- echo off
- cls
-
- rem Ask login name from keyboard
- rem ----------------------------
- XSET login INPUT "Enter login name : "
-
- rem Test if directory corresponding to login name already exist
- rem -----------------------------------------------------------
- if exist c:\%login%\nul goto LOGIN
-
- rem Directory does not exist, ask to create it
- rem ------------------------------------------
- echo:
- echo Login '%login%' does not exist.
- echo Do you want to create it? (Y/N)
-
- rem Only "yYnN" keys are allowed
- rem ----------------------------
- XSET ask KEY "yYnN"
- XSET ask UPPER %ask%
- if "%ask%" == "N" goto INPUT
-
- rem Create directory
- rem ----------------
- md c:\%login%
-
- :LOGIN
- set ask=
-
- cd \%login%
- if exist autouser.bat autouser.bat
-
- rem -----------------------------------------------------------------
-
- 7) And much more ...
-
-
- Installation:
- ════════════
-
- - XSET.EXE is ready to use; no installation,
- but it is a SHAREWARE version.
-
- - To get a registered version of XSET, print the XSET.REG file,
- fill it and send it to me; you will then receive the password
- mandatory to use the program REGISTER.
- You will receive each new upgrade for free!!!
-
-
- Problems:
- ════════
-
- - If the size of your environment space is not big enough,
- you will receive an error message
-
- 'XSET : not enough environment space.'
-
- This is not a bug, it is because the environment space
- reserved for the variables is too small.
- You must increase it by modifying the line 'SHELL=...'
- in your CONFIG.SYS. By default, DOS reserves 256 bytes
- environment space; this is generally insufficient.
- Try 640 bytes (or more if you need it) by adding '/e:640'
- at the line 'SHELL=...'
-
- ex: SHELL=COMMAND.COM /E:640 /P
-
-
- If this problem is encountered in a secondary shell
- (i.e. you run the batch file from a menu that runs
- a secondary shell) here is a way to work around the
- problem (this is a DOS problem that could be avoided
- by the program that runs the secondary shell):
-
- put in your AUTOEXEC.BAT a line such as:
- SET TO_DELETE=something_very_long_to_be_sure_this_takes_very_much_space
-
- and, before using variables in the secondary shell delete this
- ---------
- variable with the command:
- SET TO_DELETE=
-
-
-
-
- Additional information: 32.2.427.98.52 (after 19h)
- ══════════════════════ or 32.2.465.01.19
-
- E-mail: stern@mble.philips.be
-
-
-
-
- Syntax: XSET <dosvar> COMMAND [args..]
-
- Commands Arguments Action and value assigned to <dosvar>
- -------- --------- -------------------------------------
-
- INPUT [prompt] echo <prompt> and read input from standard input
- ex: XSET name INPUT Enter your name:
-
- PASSWD [prompt] same as INPUT without echoing
-
- APPEND {string} old value + <string>
- ex: XSET path APPEND ;c:\msc600\bin;c:\msc600\binb
- Rem: this allow you to bypass the 128 characters
- limit of DOS
-
- KEY string key pressed (must be in <string> if not empty)
- ex: XSET k KEY 123aAbB
- only keys 123aAbB are allowed
- ex: XSET k KEY
- all are allowed
-
- LENGTH {string} number of characters in <string>
-
- LEFT n {string} the leftmost <n> characters of <string>
- ex: XSET var LEFT 3 abcdef
- puts 'abc' in variable 'var'
-
- MID m n {string} the <n> characters in <string> starting from the <m>th
-
- RIGHT n {string} the rightmost <n> characters of <string>
-
- UPPER {string} uppercase <string>
-
- LOWER {string} lowercase <string>
-
- CHANGE s1 s2 {s3} change <s1> by <s2> in <s3>
-
- SEARCH str1 {str2} portion of <str1> matching <str2>
-
- <str2> is a UNIX-like regular expression.
- A regular expression is one or more occurrences of one or more
- characters.
- The following symbols are treated specially:
-
- ^ start of line $ end of line
- . any character \ quote next character
- * match zero or more time preceding character (or character set)
- + match one or more time preceding character (or character set)
- [] set of characters ('^' means non-inclusion, '-' means range)
-
- ex: [aeiou0-9] match a, e, i, o, u, and 0 thru 9
- [^ae0-9] match anything but a, e and 0 thru 9
- ^a match any line beginning by 'a'
- v$ match any line ending by 'v'
-
- XSET t SEARCH "^T.*K$" "This line will be OK"
- XSET t SEARCH "^T.*[1-9].*K$" "Warning: This line will not be OK"
- XSET t SEARCH "^T.*K$" "This line will not be OK!"
- XSET t SEARCH "^T.*K" "This line will be OK!"
- XSET t SEARCH "T.*K$" "Warning: This line will be OK"
-
-
- COUNT {string} the number of words in <string>
-
- WORD n {string} pick the <n>-th word in <string>
-
- LINE n read the <n>-th line from standard input
-
- MATH {expr} result of calculation of expression <expr>
- valid operators: + - * / () on floats
- + - * / () %% on integers
- ex: XSET var MATH 3+(2*5) + %new%
-
- MIN ┌{str1...strn} minimum or maximum of numbers or strings list
- MAX └{num1...numn} (one string may not contain <space> or <tab>)
- ex: XSET var MIN 3.6 4 9.02
- ex: XSET var MAX 3.6 4 abc 3.9j
-
- DATE system date (dd-mm-yy)
-
- DAY day of the month (1-31)
-
- MONTH month number (1-12)
-
- YEAR system year (4 digits)
-
- DAYOFWEEK day in the week ( 0 = sunday,... )
-
- TIME system time (hh:mm:ss - 24h format)
-
- HOUR system hour (0-24)
-
- MINUTE system minutes (0-59)
-
- SEC system seconds (0-59)
-
- BYTEFREE [drive] number of bytes free on specified (or current) drive
-
- DENSITY [drive] drive density (360, 720, 1200, 1440 or 0)
-
- DIR [drive] current directory of <drive> or current drive
-
- FPATH {file} full pathname of a filename
-
- FDRIVE {file} drive of a filename
-
- FDIR {file} drive & directory of a filename
-
- FEXT {file} extension of a file name (no period included)
-
- FNAME {file} name of a file without extension
-
- FXNAME {file} name & extension of a file
-
- FSIZE {file} size of a file
-
- TRUENAME {file} full truename of a file
-
-
- ERRORLEVEL errorlevel code of last command
- Rem: This command is only valid for
- - MS-DOS 3.20, 3.21, 3.30, 4.0, 4.01 & 5.0
- - NDOS 6.0
- Results are unpredictable under other OS
- or command processor like 4DOS, DR-DOS,
- PC-DOS,...
-
-
- [...] are optional arguments.
-
- If arguments {...} are missing, they are read from the standard input.
- Non quoted arguments on command-line will be separated by 1 blank.
-
- Rem: 'XSET var' is equivalent to 'XSET var INPUT'
- or 'XSET var LINE 1'
- and is more performant.
-