home *** CD-ROM | disk | FTP | other *** search
-
-
-
-
-
-
- SuperSET (Version 1.61)
-
-
- SuperSET is a DOS environment utility which does many of the same
- things the internal SET command does, and a few more.
-
- ABOUT THE SET COMMAND
-
- (If the DOS SET command holds no mysteries for you, please skip
- ahead to page 4.)
-
- SET is an internal DOS command which, as outlined in the IBM Disk
- Operating System(tm) manual (version 3.20), "inserts strings into
- the command processor's environment. A copy of the entire series
- of strings in the environment is made available to all commands
- and applications."
-
- This means that at boot time, or any time thereafter that
- COMMAND.COM is run, an area of the computer's random access
- memory (RAM, or "user memory") is reserved as a sort of board
- room where you and DOS can get together to agree on certain
- things. DOS uses the environment, even if you don't, by
- automatically generating a string giving the name and location of
- COMMAND.COM. This is necessary because COMMAND will relinquish a
- portion of its own memory if required by your programs and must
- be able to find itself on disk afterward to reload its missing
- code. If you enter "SET" from the "A>" prompt after booting from
- your original DOS diskette, you will see something like:
-
- A>set
- PATH=
- COMSPEC=A:\COMMAND.COM
-
- If you alter your DOS prompt via the PROMPT command to "$p$g", it
- will look like this:
-
- A:\>
-
- and your environment will look like this:
-
- PATH=
- COMSPEC=A:\COMMAND.COM
- PROMPT=$p$g
-
- The PATH is where DOS will look for any .COM, .EXE, or .BAT file
- you enter from the command line if it's not in your current
- directory. The "PATH=" string has no value (or perhaps I should
- say it has a null value), so DOS would give up looking for a
- program if it was not in the current directory. Why DOS bothers
- to put a null variable in the environment escapes me, but it
- does. You can eliminate the "PATH=" string from the environment
- all together by running:
-
- 1
-
-
-
-
-
-
-
- SET PATH=
-
- and it will be gone with no (apparent) adverse effects.
-
- Using the SET command (as well as the PATH and PROMPT commands),
- we can add environment strings, delete them, or replace them.
- The syntax for doing so is:
-
- SET [<name>=[<parameter>]]
-
- or, as I prefer to think of it:
-
- SET [<variable>=[<value>]]
-
- When run, the "<variable>" portion of the string will be capital-
- ized by DOS, but otherwise the string will appear as entered the
- next time you run SET by itself.
-
- A few programs, notably C language compilers, require that cer-
- tain strings be SET before they are run. DOS passes a copy of
- the environment to each program it runs, and these programs ex-
- tract user-specific information from this copy to "customize" the
- way they work. Here is an example used with Microsoft QuickC:
-
- set INCLUDE=c:\include
- set LIB=c:\lib
- set TMP=c:\tmp
-
- In this case, each of the programs associated with the QuickC
- compiler will know which directories on which drives certain
- programs are stored in by checking the values of INCLUDE, LIB,
- and TMP.
-
- Environment variables can be used in batch files for most ver-
- sions of DOS (excepting 3.0 -- I'd upgrade if I owned it), by
- using the "%<variable>%" construction. For example, consider the
- following segment of a batch file:
-
- set oldpath=%path%
- path c:\docs;c:\dict;c:\thes;c:\outliner;%path%
- cd wordproc
- myword
- cd\
- path %oldpath%
- set oldpath=
-
- In this case, the current value of "PATH=" from the environment
- is stored in a new variable called "OLDPATH". The PATH is
- changed to prepare for the requirements of the word processing
- program that is run next. Upon exiting the word processor, the
-
-
- 2
-
-
-
-
-
-
- PATH is restored to the value of OLDPATH, which is then deleted
- by the last line, and the environment is returned to its previous
- state.
-
- A problem users face when working with the environment (and,
- perhaps, a reason it is often largely ignored) is the stiffness
- of the SET command itself.
-
- If you view your environment as a sort of database of strings,
- which it is, the SET command does not rate well as a database
- manager. It allows appends, replacements and deletions, one at a
- time, and will generate complete listings of the current contents
- of the environment. For a very small data base, this may be
- enough, but it is possible to expand the DOS environment (up to
- 32 kilobytes in DOS 3.2 and up) to include many dozens of strings
- of various lengths. (For a quick course on achieving an environ-
- ment larger than the default size with old versions of DOS, lo-
- cate a copy of PC Magazine, April 14, 1987, Volume 6, Number 7
- which contains an article entitled "Expanding the DOS Environ-
- ment". DOS versions 2.0 to 3.1 are capable of working with en-
- vironment sizes up to 992 characters. The article refers to the
- (Microsoft) DOS SETENV utility, has an undocumented CONFIG.SYS
- command for DOS 3.0 and 3.1, and DEBUG patches for COMMAND.COM as
- well. Anyone with DOS versions 3.2 or greater can use the
- "SHELL=" with the "/E" parameter as outlined in their DOS
- manuals. I find an environment of 512 bytes adequate for any-
- thing I'd like to do.)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 3
-
-
-
-
-
-
- ABOUT SUPERSET
-
- And so we come to SuperSET. This utility, written in Turbo Pas-
- cal, is a management tool for your DOS environment. It does most
- of the same things SET does, and many more. It will, on demand,
- sort your environment alphabetically by variable name, allow you
- to prompt for new environment strings from a batch file, store
- your current drive, directory, the date and the time in the en-
- vironment, save your environment to a disk file or recall it from
- one, clear your environment entirely or selectively, display
- values for all or specific variables, create files with unique
- names for your batch files, and allow you to process a number of
- environment commands on a single command line.
-
- I have already noted the %<variable>% construction most DOS ver-
- sions use in batch files. If you try using this construction on
- the command line (that is, from the DOS prompt), it won't work,
- except with SuperSET. Whenever SuperSET encounters an even num-
- ber of per-cent signs in a command line instruction, it will per-
- form the appropriate substitutions. If there is an odd number of
- per-cent signs in the instruction, the first occurrence of '%'
- within the instruction is deleted, and the rest of the instruc-
- tion is treated without substitutions. Confused? Of course!
- You may never understand nor use this feature, but just for fun
- try this from the DOS prompt:
-
- C:\>sset 123=%%456% 456=789 %123%=123 @dsp
-
- You should get a nice display of your environment with the fol-
- lowing strings added:
-
- 123=%456%
- 456=789
- 789=123
-
- To make this feature useful in batch files (where DOS gets first
- shot at per-cent signs), a tilde ('~') may be substituted for any
- '%':
-
- @echo off
- rem Fakes a DOS "$p$g" prompt
- :DosPrompt
- sset @drv @dir @inp("~currdrv~~currdir~>"^doscom^c)
- if errorlevel 255 goto end
- if !%doscom%==! goto end
- call %doscom%
- goto DosPrompt
- :end
-
- The syntax for SuperSET is:
-
- [d:][path]SSET [<command> [<command>...]]
-
- 4
-
-
-
-
-
-
-
- where "command" is one of the following:
-
- 1. Not given.
-
- If SSET is entered without parameters, it will display the
- contents of the entire environment. Unlike the DOS SET com-
- mand, however, SuperSET displays the location of the en-
- vironment in RAM, the size of the environment, the number of
- characters and variables used, and the number of characters
- remaining for use. (See the @DSP function, below, for a way
- to emulate the SET command output.)
-
- See also: @DSP
-
- 2. <variable>=[<value>]
-
- Space permitting, if <value> is given then a string is ap-
- pended to the end of the environment in the form:
-
- <variable>=<value>
-
- <variable> will be converted to its upper case equivalent if
- need be. If <variable> is already in the environment, the
- original record of it will be deleted, together with its old
- value.
-
- If <value> is not given, then <variable> is deleted from the
- environment. An asterisk ("*") wild card is allowed at the
- end of each <variable>=, so a number of strings with names
- that begin the same way may be deleted in one command. For
- example:
-
- sset temp*=
-
- would delete environment strings with such names as TEMP,
- TEMP1, TEMP VAR, TEMPEST, and TEMPORARY.
-
- A major difference in the way SuperSET and SET handle as-
- signments of this sort is caused by SuperSET's ability to
- handle more than one command in a single command line. Be-
- cause SuperSET parses spaces as parameter separators, it is
- necessary to enclose multiple word parameters in quotation
- marks. Thus:
-
- set query=What is your name?
-
- can be emulated by:
-
- sset query="What is your name?"
-
-
-
- 5
-
-
-
-
-
-
- If you need to enter a quotation mark into the environment,
- use two quotation marks together in your command line:
-
- sset riddle="Who wrote ""The Lost Chord?""
-
- The DOS SET command, because it is contained in the resident
- portion of DOS and is therefore faster, should be used
- wherever practical for routine changes to the environment.
- (Incidentally, Sir Arthur Sullivan wrote "The Lost Chord.")
-
-
- See also: @ZAP
-
- 3. @BOT
-
- All subsequent commands will work with the environment
- created by the last PERMANENTLY loaded copy of COMMAND.COM.
- To see the effect of this, type the following at the DOS
- prompt:
-
- C:\>set this=that
- C:\>sset
- C:\>command
- C:\>sset
- C:\>sset @dsp @bot this=
- C:\>sset
- C:\>exit
- C:\>sset
-
- See also: @TOP
-
- 4. @DAT
-
- Places a variable called DATE into the environment whose
- value is the current date as reported by DOS. The date is
- stored in a format compatible with the DOS DATE command and
- will vary according to the version of DOS used and the value
- of the COUNTRY= line (if present) in your CONFIG.SYS file.
-
- See also: @TIM
-
- 5. @DIR
-
- The current directory will be placed in the environment, as-
- signed the variable name "CURRDIR".
-
- See also: @DRV
-
-
-
-
-
-
- 6
-
-
-
-
-
-
- 6. @DOW
-
- Places a variable called DAY OF WEEK into the environment
- whose value is the name (i.e., Sunday, Monday, etc.) of the
- current day as reported by DOS.
-
- 7. @DRV
-
- The current drive letter (and accompanying colon) will be
- placed in the environment, assigned the variable name
- "CURRDRV".
-
- The @DIR and @DRV functions are useful for batch files on
- your PATH that might be run from any directory or drive. If
- such a batch file changes drives or directories mid-
- operation, CURRDIR and CURRDRV will help to restore the user
- to his or her original location. Consider the following
- batch file:
-
- echo off
- cls
- sset @drv @dir
- c:
- cd \sk
- sk
- cd \
- %currdrv%
- cd %currdir%
-
- Assume you have Borland's SideKick in a directory on drive
- C: called \SK and you wanted to start it from your work
- directory , A:\WORK. This batch file, SK.BAT, resides in a
- directory listed in your PATH environment variable. Super-
- SET places the strings, "CURRDRV=A:" and "CURRDIR=\WORK" in
- the environment before the batch logs on to C:, changes the
- active directory there, and runs SideKick. "A:" is
- automatically substituted for %currdrv% on the next line,
- logging us back onto A:, and "\WORK" is substituted for
- %currdir% on the last line, giving us back our original
- directory.
-
- See also: @DIR
-
- 8. @DSP[(<variable>[^<variable>...])]
-
- Generates a list of existing environment strings. Without
- parameters, @DSP is identical in function to SuperSET
- without parameters. If a variable or variables are
- specified, a simple list of corresponding variables and
- values is displayed, in the same format used by the DOS SET
- command, although a note is generated for any variable named
- in the command line that is not in the environment. This is
-
- 7
-
-
-
-
-
-
- a quick way to determine whether or not a specific variable
- is in the environment without scanning a lengthy list. An
- asterisk ("*") wild card is allowed at the end of each
- <variable> (see item 2, above for more details regarding the
- functioning of wild cards).
-
- The command:
-
- sset @dsp(*)
-
- simulates (albeit slowly) the SET command run without
- parameters (although I can't imagine why you'd want to do
- this).
-
-
- 9. @FIL
-
- Adds a number of strings to the environment of the form:
-
- !FILLxxx=▓▓▓...▓▓▓
-
- where xxx is an hexadecimal number. You may want to issue
- this command prior to loading a program which allows you to
- shell to DOS. Such programs typically do not give you a
- full environment to work in when they load COMMAND.COM on
- top of themselves. Instead, they will give you your current
- environment strings and however many additional bytes it
- takes to round the environment size out to a multiple of 16.
- The @FIL function will ensure that enough space is taken up
- in your current environment (with a minimum of 3 free bytes,
- including the two "end-of-environment" markers) to guarantee
- a full-sized copy when you shell to a new one. To free the
- room up in the new copy, use:
-
- sset !fill*=
-
- having ensured, of course, that you won't simultaneously
- erase an important string that also begins with "!FILL".
- Remember to issue the same command when you quit your ap-
- plication to clear the unwanted strings from your root en-
- vironment.
-
- 10. @GET[(<filespec>)]
-
- Unless a different <filespec> is specified, appends all
- strings listed in a file in the root directory of the cur-
- rent drive called "ENVIRON.TXT" to the environment. This is
- the logical companion to the @SAV function, and uses files
- in the format specified for that function.
-
- See also: @SAV
-
-
- 8
-
-
-
-
-
-
- 11. @INP[([<prompt>^]<variable>[^<switch>])]
-
- If <prompt> exists, it will be displayed as entered on the
- user's screen. <prompt> may be up to 64 characters in
- length The cursor waits to the immediate right of <prompt>
- for user input, or at the left edge of the screen if no
- <prompt> is given. INP is the default variable name.
-
- The user's entry will be placed into the environment, as-
- signed to <variable>.
-
- One switch may be used. It must consist of a "/" followed
- by a single character (upper or lower case). Valid choices
- are:
-
- C Do a carriage return/line feed at end of entry.
- U Convert the whole entry to upper case.
- L Convert the whole entry to lower case.
- F Convert the first letter of the entry to upper
- case, and the rest to lower case.
- I Convert the first letter of each word in the entry
- to upper case and the rest to lower case.
-
- The following example uses @INP to prompt for a person's
- name in a batch file and issue an appropriate greeting:
-
- echo off
- cls
- sset @inp(User Name^Hello. What's your name? ^/i)
- :: Note the space after "name?" in the above line.
- :: If left out there would be no space between
- :: the question and answer.
- echo Greetings and felicitations, %User Name%.
-
- See also: @KEY
-
- 12. @KEY[([<prompt>^]<variable>[^<switch>[/h])]
-
- Works like @INP, above, but for single character input The
- user's next keystroke is returned to the environment. If
- this is a "control" character (ASCII 1 to 26) or [Esc]
- (ASCII 27), the environment entry will be a "#" followed by
- a decimal representation of the ASCII code. If the key
- pressed was a function or cursor key, the environment entry
- will be a decimal representation of the scan code of the key
- pressed. KEY is the default variable name.
-
- Two switches are allowed, consisting of "/" followed by a
- single character (upper or lower case). The first may be
- one of:
-
- U Convert the character to upper case (if required).
-
- 9
-
-
-
-
-
-
- L Convert the character to lower case (if required).
-
- The second, if used, must be:
-
- H Hide, or don't display the keystroke.
-
- See also: @INP
-
- 13. @MID(<string>,<start position>,<length>)
-
- Has the same effect on <string> as Turbo Pascal's COPY pro-
- cedure or BASIC's MID$ function. In other words, the func-
- tion returns a substring of <string> to the environment, as-
- signed to the variable name MIDSTRING. The value returned
- will be that portion of <string> which begins at <start
- position> and encompasses <length> characters. Thus, the
- command:
-
- sset @mid(albatross^3^3)
-
- A more complex example is:
-
- sset @tim @mid(~time~^1^5) time=~midstring~
-
- which returns the current hour and minute to the environment
- variable TIME instead of the usual @TIM function format.
-
- 14. @SAV[(<filespec>)]
-
- Unless a different <filespec> is specified, stores all en-
- vironment strings in a file in the root directory of the
- current drive called "ENVIRON.TXT". The file is a simple
- ASCII sequential file in which each line contains one en-
- vironment string and ends with a carriage return. It may be
- edited with any ASCII-only text editor (like QEdit, or even
- EDLIN), and any number of files created to suit a variety of
- requirements. If you aren't doing anything more with Super-
- SET than using @SAV (i.e., if there is nothing else on your
- command line), the DOS SET command will be faster:
-
- C:\>set > c:\environ.txt
-
- Here, the normal output from the SET command (identical to
- that of @SAV) is redirected to the file C:\ENVIRON.TXT.
-
- See also: @GET
-
- 15. @SRT
-
- Sorts all environment strings alphabetically by variable
- name.
-
-
- 10
-
-
-
-
-
-
- 16. @TIM
-
- Places a variable called TIME into the environment whose
- value is the current time as reported by DOS. The time is
- stored in a format compatible with the DOS TIME command and
- will vary according to the version of DOS used and the value
- of the COUNTRY= line (if present) in your CONFIG.SYS file.
-
- See also: @DAT
-
- 17. @TOP
-
- All subsequent commands will work with the environment
- created by the last loaded copy of COMMAND.COM. You should
- only need to use this function to switch back to your tem-
- porary environment after using @BOT previously on the same
- command line. To see the effect of this, type the following
- at the DOS prompt:
-
- C:\>set this=that
- C:\>sset
- C:\>command
- C:\>sset
- C:\>sset @dsp @bot this= @top @dsp
- C:\>exit
- C:\>sset
-
- See also: @BOT
-
- 18. @TRU[(<file name>)]
-
- THIS FUNCTION ONLY WORKS IN DOS VERSIONS 3.0 AND GREATER.
- If no parameter is given, then a path to the current direc-
- tory is returned to the environment. If a parameter is
- given, it will be capitalized and expanded to a full path
- name in the environment. In either case, the associated
- variable name will be TRUENAME. This function makes use of
- an undocumented DOS function (60h).
-
- 19. @UNA(<0..50>)
-
- Creates an environment variable, UNARY, which has a string
- of n 1s as its value where n is the value of the parameter.
- n must be an integer value in the range 0 to 50 (inclusive).
-
- This feature is included to permit FOR loops, and even
- nested FOR loops within batch files. Consider this simple
- example:
-
- @echo off
- sset counter= @una(%1)
- :looptop
-
- 11
-
-
-
-
-
-
- echo %1 %counter%1
- set counter=%counter%1
- if not !%counter%==!%unary% goto looptop
- shift
- set unary=
- set counter=
- if not !%1==! sset @una(%1)
- if not !%unary%==! goto looptop
- echo Done!
-
- which you might try running with the following command line
- parameters:
-
- 50 50 50 50 50 5
-
- This will produce 255 iterations of the "echo %1 %counter%1"
- command. A more complex example, one with a nested FOR
- loop, is the following:
-
- @echo off
- sset @inp("1st num: "^n1^/c) @inp("2nd num: "^n2^/c)
- sset @una(~n1~) n1=~unary~ @una(~n2~) n2=~unary~
- set unary=
- set c1=
- set c2=
- set mc=
- :loop1top
- :loop2top
- set mc=%mc%1
- echo Iterations through inner loop: %mc%
- set c2=%c2%1
- if not !%c2%==!%n2% goto loop2top
- set c2=
- set c1=%c1%1
- if not !%c1%==!%n1% goto loop1top
- set c1=
- set c2=
- set n1=
- set n2=
- set mc=
- echo Done!
-
- 20. @UNI[(<dos directory>)]
-
- THIS FUNCTION ONLY WORKS IN DOS VERSIONS 3.0 AND GREATER.
- Creates a 0-length file with a unique name and returns the
- file name to the environment variable UNIQUE. If a target
- directory is not specified, the file will be created in the
- root directory of the current disk. This may be useful in
- batch files which require the creation of temporary files.
- As a demonstration, try keying in the following batch file:
-
-
- 12
-
-
-
-
-
-
- @echo off
- sset @uni(dos)
- echo Now you see it, > %unique%
- type %unique%
- echo on
- dir %unique%
- @echo off
- del %unique%
- echo:
- echo Now you don't!
- echo on
- dir %unique%
- @echo off
- set unique=
-
- 21. @ZAP[(<variable>[^<variable>...][^/n])]│[(/n)]
-
- Erases all environment variables unless they are specifi-
- cally listed as parameters. Potentially dangerous, but very
- useful for wholesale changes to the environment. A warning
- message is displayed and a confirmation prompt presented
- when @ZAP is used, unless the "/n" parameter is given. An
- asterisk ("*") wild card is allowed at the end of each
- <variable> (see item 2, above for more details regarding the
- functioning of wild cards, and note that *= has the same ef-
- fect as @ZAP(/n)).
-
- For example, to erase all environment variables except
- COMSPEC, PATH, and PROMPT use
-
- sset @zap(comspec^path^prompt)
-
- or, if you are sure other variables won't match the
- wildcards, you might save some typing with something like:
-
- sset @zap(co*^p*)
-
- See also: <variable>=[<value>]
-
- MESSAGES
-
- SuperSET will generate an error message if there are syntax er-
- rors in the command line, if there is no room left in the en-
- vironment when an append is being attempted, when you are working
- with the environment set up by a copy of COMMAND.COM and when the
- file named in the @GET or @SAV functions can't be opened. As the
- latter function often precedes a @ZAP or some other drastic en-
- vironment change, an error here terminates the program. All of
- these errors will set the DOS ERRORLEVEL to 255 when the program
- exits, a value your batch files can test for. Other messages,
- regarding variable names not found in the environment, are
- presented for information only, and do not set ERRORLEVEL.
-
- 13
-
-
-
-
-
-
-
- Output from SuperSET may be redirected to a printer, a disk file,
- or another DOS "device", or piped through a command like MORE
- using the ">" and "|" characters respectively. You will likely
- want to use MORE if you've got a lengthy environment and you want
- to examine it screen by screen.
-
- There is one occasion, in batch file operation, where it is es-
- sential to use SET instead of SuperSET. That is when environment
- variables require setting in the middle of a "cascade" of ERROR-
- LEVEL checks. SuperSET, and any other program external to DOS,
- resets the ERRORLEVEL to 0 on entry.
-
- IMPORTANT DISTINCTIONS
-
- The DOS SET command affects the environment established only by
- the most recently loaded copy of COMMAND.COM. Many application
- programs permit users to "shell out" to DOS, by running a second
- instance (i.e., copy in memory) of COMMAND.COM. Changes made
- with SET to the shell environment disappear when the user types
- EXIT. If SuperSET is run on such occasions without the @BOT
- function, it will affect the newly created environment (if suffi-
- ciently large for the operations selected). SuperSET issues a
- warning message if you are working with a temporary environment.
-
- An interesting feature of the SET command (not incorporated into
- SuperSET for a variety of reasons) is its ability to expand the
- environment. SET can only accomplish this by the addition of
- strings beyond the "end" of the current environment and ONLY IF
- no other programs (like TSRs) are sitting on top of the environ-
- ment in memory. Since the environment size for the first
- (permanent) copy of COMMAND.COM is usually determined by the
- SHELL statement in CONFIG.SYS, this is really only a problem with
- temporary environments. To compensate for SuperSET's deficiency
- in this area, refer to the @FIL function, described above.
-
- SuperSET Version 1.61 is Copyright (c), 1991, by Richard Linley.
- Please distribute it, in unaltered form and accompanied by this
- help file, to anyone you like. The program is presented "as is"
- and guarantees nothing. Watch for upgrades. If you have sug-
- gestions or requests for new features, please write to:
-
- Richard Linley
- 641 Sussex Blvd.
- Kingston, Ontario
- Canada
- K7M 5A9
-
-
-
-
-
-
- 14
-