home *** CD-ROM | disk | FTP | other *** search
- Enhanced SET command
- Copyright (c) 1990 Wayne D. Mingee All rights reserved
- Archive ESET21 Program ESET v2.1 Suggested donation $10.00
-
- OVERVIEW
-
- This program manages DOS [and 4DOS] environment variables. It will:
- -Handle the master or local [secondary] environment. It does find
- them all including Wyse 3.1.
- -Multiple operands per line
- -Set a variable to:
- System date or time
- Whether under a secondary command processor
- A substring of a string
- -Append or Prepend a string
- -Arithmetically process by:
- adding a +-value
- shifting the value left/right n positions
- And/Xor with a value
- -Change a one or all occurrences of a string to another
- -Take user input from Stdin with:
- Issue a prompt message
- limiting time to start replying and input to certain characters
- limiting length of input and terminating input when input full
- -Trim leading/trailing blanks from result
- -Convert to upper case
- -No limit on length of variables.
- -Display the environment with size, used and free totals and returns
- the free amount in a variable
- -Works with DOS 2.0+, 4DOS and should work in a OS/2 DOS box.
- Registration gets additional programs that:
- -Manipulate I/O ports. Can be used to test printer status, carrier
- detect, etc. rearrange bios port addresses.
- -Get file information, path, size, date, etc. Do a findfirst/findnext.
- -Reallocate the environment size. Release unused copies. Fix the size.
- -Maintain a lifo/fifo list in a variable.
- -Release the environment of TSR's that don't.
- -Commit system specs, drives, etc, to variables at boot.
- -Library routine for doing environment work.
-
- QUICK START
-
- ------------------------------- NOTE -------------------------------
- This program will create variables longer than 127. Care must
- be used when intermixing the use of the DOS SET command, since DOS
- will only process the first 127 positions and may leave an invalid
- variable in the environment. Also variables can contain characters
- which DOS may not handle correctly.
- --------------------------------------------------------------------
- If using 4DOS you must either rename ESET or disable the 4DOS
- command with SETDOS /I-ESET. Also to use the prepend operation (^)
- you have to change the 4DOS command separator character with SETDOS
- /Cc.
- --------------------------------------------------------------------
-
- To test if ESET will find the environments on your system:
- COMMAND /C ESET /DX Z=$C Z+=
- the display should be:
- [xxx] Z=1 xxx should be a hex number > 15
- [xxx] Z=1 the 2nd assignment insures it was set
-
- To set a variable: ESET name=value
- To clear a variable: ESET name=
- To display the contents of the environment: ESET
- To take user input into a variable: ESET name "prompt message"
- To edit a variable: ESET /E name ? 155
- To get current date: ESET NOW=$D
-
- PARAMETER DESCRIPTIONS
-
- ESET name=value
-
- Multiple sets of arguments can be supplied:
- ESET [sws] [vbl] [sws] [vbl] . . .
-
- All variable names are converted to upper case. Names cannot begin
- with a switch character.
-
- The switch character "/" used in these docs is actually replaced
- by the switch character defined in DOS.
-
- Switches may be given separately or in a string. ie: /C /D /CD
-
- To set a value containing blanks or <>| enclose the ENTIRE
- parameter in "". ie: ESET "NAME=Now is the time"
- Setting ESET NAME="Now is the time" would include the quotes as part
- of the variables value.
-
- If no parameters other than switches are given the contents of the
- named environment are displayed. There is no end of screen pause as
- this is designed primarily for saving the environment to a file.
-
- All output is to Stdout and may be redirected.
-
- Any token may be created from one or more environment variables.
- (ie: %Z% %Z%%X% %Z%--%X%) In BAT file use %%. If no closing % is found
- before the end of the token, ie: %%NAME one is inserted and no error
- is indicated. This can help to reduce the length of command line.
- Also on very long variables use %% so that DOS does not include it as
- part of the command line. The /M switch also effects where variables
- are copied from. Given ESET /M Z=%Y% then Y would be copied from the
- master environment.
- All variables are resolved including those within "". To include
- a % as part of a variable you have to use 2 %% [3 in BAT files].
- Included variables are not tested for variables.
-
- Default settings can be set in an environment variable equal to
- the program name. This works even if ESET is renamed.
-
-
- GENERAL SWITCHES
-
- /U the value is converted to upper case.
-
- /C a LF is output on STDOUT. This occurs immediately for each C
- encountered. Can be used to separate user input on separate lines.
- ie: ESET FNAME "Enter file name>" /C CNAME "Enter customer name" /C
- ESET does not normally end any display with a CRLF thus allowing you
- to control the display.
-
- /T the requested operation is performed and then all leading and
- trailing blanks are removed from the value.
-
- /D the results are displayed on stdout as name=value with one trailing
- space but no CRLF.
-
- /X the hex value of the return code for each operation is displayed on
- stdout as [xxx]. If less than 16 then it is an error code otherwise
- it is the displacement of the variable into the environment.
-
- /M the master environment is used instead of the local [secondary]
- shell's. If operating under the primary shell it has no effect.
- Remember when setting the master environment while under a secondary
- shell that the new value will not be available to normal DOS batch
- commands since the local environment was not affected. Use the /R
- switch to set both.
-
- /R after the operation is performed the resultant value is copied to
- the master environment. If operating under the primary shell it has
- no effect.
-
- /B processing is terminated with ERRORLEVEL 3 if any error has
- occurred up to this point.
- ie: ESET PATH*=/C:\ESET;/C:\ESET;/ /B
- would return ERRORLEVEL 3 if the PATH does not contain the directory
- C:\ESET
-
- /N processing is terminated with ERRORLEVEL 3 if no error has occurred
- up to this point.
- ie: ESET PATH*=/C:\ESET;/C:\ESET;/ /N PATH^=C:\ESET;
- would prepend the directory C:\ESET to the PATH if it does not already
- exists in it.
-
- Switches UMDXTR are toggles. Each occurrence reverses the state.
-
- If the value begins with a $ then ESET will perform certain special
- functions to create the value. To set a value beginning with a $ use
- two $. The $ codes are:
-
- $D - returns current date mm-dd-yyyy
- $T - returns current time hh:mm:ss
- $Sn1,n2,string - returns substring of variable starting at n1 for
- n2 positions. 1 = position 1.
- $+ [+/-]n2 - add integer n2 to variable
- $& [+/-]n2 - and integer n2 to variable
- $^ [+/-]n2 - xor integer n2 to variable
- $[ [+/-]n2 - shift variable left n2 bits
- $] [+/-]n2 - shift variable right n2 bits
- $C - returns a 0 if running under the primary command
- processor and a 1 if it is a secondary.
- $E - gets value of byte at 40:F0 which if you are using RELENV
- [available in the registered version] is the return code of
- last program termination.
-
- If the name ends in one of the following characters the special
- operation is performed with the value. To end a name in one of these
- use 2. [name**]
-
- - remove value from variable
- ^ prepend value to variable
- + append value to variable
- * value is in two parts separated by a delimiter equal to the
- first char. The first occurrence of the first part is
- replaced by the second part. ie: /yy/xx/ replaces yy with
- xx. Replacing a NULL string is the same as prepend.
- Replacing a NULL with a NULL will return ERRORLEVEL 0 if the
- VARIABLE exists and a 1 if not.
- @ same as * but changes all occurrences. Replacing a NULL
- string will make the variable fill up the unused space in the
- environment.
-
- ERRORLEVELS RETURNED
-
- 1 problem setting environment variable
- name* - old value not found
- name- - value not found
- processing continues
-
- 2 problem processing the command
- syntax error
- could not find the environment
- insufficient space in environment
- processing terminated
-
- 3 /B or /N switch was satisfied, processing terminated
-
- Function change-all [@] always returns code 0.
-
- variable $E is set to the ERRORLEVEL with the following exceptions:
- FOR USER INPUT
- 0-511 Ascii value of last key input. [3=Ctrl-C]
- extended Ascii codes are 256-511
- 512 is set for timeout
-
- when displaying the environment $E contains the amount of free space.
-
-
- USER INPUT
-
- ESET [switches] name prompt [valid-chars] [+-length] [time limit]
-
- Name is the variable name and can include one of the special
- operations from above [-+*^@], in which case the data input by the
- user will be used to perform the operation.
-
- Prompt is a string to be displayed. If it contains blanks or <>|
- then it must be enclosed in "". It cannot contain a ".
-
- Input is taken from Stdin and may be redirected.
-
- SWITCHES
-
- /E the current value of name is used as the default value which the
- user can edit. An additional data item is required which is the
- maximum length for the item. If the absolute value is not greater
- than the current length then the current length is used and the length
- cannot be increased. If it is positive then the cursor will be
- positioned length+2 position from the beginning of the field. If it
- is negative the cursor will be positioned 2 positions past the end of
- the input. Currently, the total length of the prompt + the length of
- the input must be less than the length of 2 screen lines.
-
- /A when the user enters a character into the last position, input is
- terminated and the code of that character is set in $E. Applies only
- when /E is used.
-
- /V An additional data item is required which specifies the valid
- input characters. If a blank or <>| is allowed the list must be
- enclosed in "". The blank must be given if allowed.
-
- /Lnn the user has nn seconds to start responding. After the first
- keystroke there is no time limit on completing. the first keystroke
- does not have to be a valid character, when using /V, to stop the
- timer. This must be last or only switch. [/EVL3 or /L5]
-
- Switches VEA are toggles. Each occurrence reverses the state.
-
- Ctrl-Z [eof] terminates all further input from STDIN but the command
- line is still processed.
- ie: ESET A ? B ? C ? <DATA.FIL
- if DATA.FIL only contains one line then variables B and C would be
- cleared.
- ie: ESET A ? <DATA.FIL
- if DATA.FIL contains more then one line the remainder of the file is
- ignored.
-
- The following control keys are available during keyboard input:
-
- Right and left cursor, backspace, delete, home, end, insert
-
- Ctrl-left and Ctrl-right move to the next word.
-
- Ctrl-home restores the default value.
-
- Ctrl-end clears from the cursor to the end of the input.
-
- Ctrl-C [break] terminates all further processing of the command line.
-
- Any other non-character key terminates input.
-
- TECHNICAL
-
- Because of the way the environment is manipulated an existing
- variable maintains the same sequential position within the
- environment. They are not moved to the end when they are changed.
- This may be of some use otherwise but I mention it mainly because they
- would not show on the display in the usual place.
-
- If using variables longer than 128 characters you should be sure
- and test them with your programs since some copy the environment into
- their own workspace and therefore may have problems with long ones.
- If you have trouble with a program locking up after using this, remove
- the long variable and test it again.
-
- Certain limitations, such as no " in a prompt string can be over
- come by setting a variable and using it.
- ie: ESET Y="huh?" Z %%Y would use the string "huh?" as the prompt.
-
- One common problem is getting the DOS message, "Bad command or
- file name", because the command is too long. This can be avoided by
- using %% for variables.
-
- Nested variables are available where DOS does the first
- replacement and ESET does the next.
- Given: Y contains the value %Z% and Z contains HI
- ESET Y=%%%%Z Z=HI
- Then: ESET A=%Y% in a BAT file would set A to HI.
-
- Mailing address:
-
- Wayne D. Mingee
- 314 N. Main St.
- Bridgewater, Va 22812
-
- Bug reports or suggestions may be sent to the above address or
- Messaages can be left at one of the following BBS.
-
- Mad Hacker 703-433-0824 Harrisonburg, VA
- Computer Connection 202-547-2008 Alexandria, VA