home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Pier Shareware 6
/
The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso
/
010
/
xset420.zip
/
DEMO.BAT
< prev
next >
Wrap
DOS Batch File
|
1994-09-15
|
13KB
|
338 lines
@echo off
if "%1" == "second_time" goto begin
if exist XSET.EXE goto OK_to_go
echo You must be in the directory containing XSET
exit
goto end
:OK_to_go
:: ┌───────────────────────────────────────────────────────────────────────┐
:: │ Run a new shell with environment big enough (10,000 bytes to be sure) │
:: └───────────────────────────────────────────────────────────────────────┘
:: run a new command.com with more environment space
if "%comspec%" == "" command/e:10000/c demo.bat second_time
if not "%comspec%" == "" %comspec%/e:10000/c demo.bat second_time
goto end
:begin
cls
echo ╔═════════════════════════════════════════════════╗
echo ║ ║
echo ║ ░░░▒▒▒▓▓▓ Welcome to XSET demo ▓▓▓▒▒▒░░░ ║
echo ║ ║
echo ╚═════════════════════════════════════════════════╝
echo:
echo Hello,
echo:
echo:
echo Although you always thought you cannot perform real programming with DOS
echo batch files, this demo will show you it is feasible; furthermore, it will
echo show you it is very easy to do.
echo:
echo What really lacks in DOS is a way to handle environment variables.
echo The only thing DOS allows you to do is to assign a variable to a value
echo and to use its value.
echo:
echo Did you ever dream to get a user's answer into an environment variable,
echo or the result of a calculation, or the output of a program ?
echo Did you ever try to find a way to write a batch file that will allow
echo a selective behaviour for different configurations (like different
echo processor types or day of the week,...) ?
echo:
pause
cls
echo So, why do YOU need XSET ?
echo:
echo 1. Because you are PC support (like me) and often have to write batch files
echo that will be used by a great number of people and they must be very
echo context-dependant and highly interactive (especially if users do not know
echo about DOS and they panic if they see 'Abort, Retry, Fail?').
echo:
echo 2. Because you need to work in different environments ( for example you are
echo are connected to different networks, or you swap between two development
echo environment - compilers,... ) and you have to maintain two sets of batch
echo files.
echo:
echo 3. Because you do not like to see your batch files waiting for you the whole
echo night because you forgot to insert a floppy into drive A: and locking the
echo computer instead of running your communication software.
echo:
echo 4. Because you simply want to interactively edit your path ( or any other
echo variable), save all your environment to restore it later,...
echo In other words, you want to have full control of your environment.
echo:
echo:
pause
cls
echo The main goal of XSET is to put ANYTHING YOU WANT into an environment variable
echo and to modify it LIKE YOU WANT; it also by-passes the internal limits of plain
echo DOS like the 128 characters limit (very useful if you need a very long path).
echo But XSET also provide a lot of built-in facilities like full floating-point
echo calculation, time and date handling, system information (kind of CPU, is a
echo disk ready,...), customized prompts (also in color) and much more !!!
echo:
echo XSET is fully compatible with MS-DOS, DR-DOS, 4DOS, NDOS, Windows & OS/2.
echo:
echo XSET is not only the most powerful environment variables manipulation program
echo you ever saw, but it also has a very easy and intuitive user interface (very
echo close to the DOS 'SET' command).
echo:
echo Example 1: to ask the user's name and store the result in a variable 'name'
echo XSET /PROMPT "Enter your name: " name
echo:
echo Example 2: to store the processor type in a variable 'cpu_kind'
echo XSET cpu_kind CPU
echo:
echo Example 3: to extract the 5 firsts characters of a string
echo XSET /LEFT 5 var="any string you want even with another variable %var%"
echo:
echo Type any key to get XSET help on-line...
pause > nul
xset
cls
echo Following is a demo which only goal is to show how powerful XSET is.
echo The demo itself is not very useful but it implements a kind of very
echo limited file manager.
echo None of the messages, colors, default values or behaviours are
echo hard-coded into the program; they all are given as parameters in
echo the batch file.
echo XSET is not limited to this kind of handling; I only had to choose
echo something that has a great level of interaction because it is better
echo for a demo but the most powerful features of XSET are generally used
echo for non- interactive procedures.
echo:
echo Note for people who have a monochrome monitor and a color video
echo board: The demo displays messages in color but you normally should
echo read everything correctly (you even will see highlight).
echo:
echo:
echo Because of the way the information are displayed on the screen, the
echo drawing may be very slow ( especially if you do not have a disk
echo cache installed). This is because the XSET program is called a lot
echo of times for the menu display (only to have fancy colors).
echo:
echo:
pause
cls
echo First of all, some system checks.
echo Note that all displayed results are actually stored into an environment
echo variable; the following message are using the normal DOS 'echo' command.
echo:
echo:
XSET _xtmp CPU
if "%CPU%" == "86" set _xtmp=086
echo CPU kind: 80%_xtmp%
:: the following trick would be useless if the 'FOR' command
:: would allow to perform several actions in a loop
:: (so we create and call a batch file)
echo XSET _xtmp DRIVETEST %%1 > _xtmp.bat
echo echo drive %%1: status: %%_xtmp%% >> _xtmp.bat
for %%d in (A B C X) do call _xtmp.bat %%d
del _xtmp.bat
XSET _xtmp TIME
echo Current time: %_xtmp%
XSET _xtmp DIR c:
echo current dir of drive C: \%_xtmp%
XSET _xtmp VOLLABEL c:
echo volume label of drive C: %_xtmp%
XSET _xtmp BYTEFREE c:
echo bytes free on drive C: %_xtmp%
XSET _xtmp FDATE c:\autoexec.bat
echo c:\autoexec.bat - date: %_xtmp%
XSET _xtmp FSIZE c:\autoexec.bat
echo c:\autoexec.bat - size: %_xtmp%
echo:
echo:
pause
:: -----------------------------------------------------
:demo
:: ┌─────────────────────────────────────────┐
:: │Get current drive & path into environment│
:: └─────────────────────────────────────────┘
XSET _xdrive FDRIVE *
XSET/MID 3 100 _xdir FDIR *
:: ┌──────────────────────────────────────────────┐
:: │ Store current path & add this directory to it│
:: └──────────────────────────────────────────────┘
XSET _xpath VARCOPY path
set path=%_xdrive%%_xdir%;
XSET/APPEND path varcopy _xpath
:: ┌──────────────────┐
:: │Set default values│
:: └──────────────────┘
set _xfile=*.*
set _xoptions=/P
XSET _xdate DATE
set _xpos=3
:: ┌─── Show menu on Screen ──────────────────────────────────────────────┐
:: │ │
:: ├─── This is purely examplative ───────────────────────────────────────┤
:: ├─── Experiment with dir, changing drive path options, ... ────────────┤
:: └──────────────────────────────────────────────────────────────────────┘
:menu
cls
set XSET=/BACKGROUND BLUE/COLOR YELLOW/WINDOW 3 1 75 17/BORDER
XSET/XPOS 5/YPOS 2/PROMPT "████████████████████ X S E T: Menu example ███████████████████"
set XSET=/BACKGROUND BLUE/COLOR WHITE/XPOS 7
XSET/YPOS 5/PROMPT"D Drive :"
XSET/PROMPT "P Path :"
XSET/PROMPT "F FileSpec :"
XSET/PROMPT "O Options :"
echo:
XSET/XPOS 5/PROMPT"─────────────────────────────────────────────────────────────────────"
echo:
set XSET=/BACKGROUND BLUE/COLOR WHITE/XPOS 27
XSET/PROMPT "1 List directory contents"
XSET/PROMPT "2 List File contents"
echo:
XSET/PROMPT "Q Quit menu"
:: ┌──────────────────────────────────────────────────────────────────────┐
:: ├── Showing drive, path, _xfile and _xoptions ─────────────────────────┤
:: └──────────────────────────────────────────────────────────────────────┘
XSET/YPOS 4/XPOS 60/COLOR GREEN/PROMPT"%_xdate%"
XSET _xtmp DRIVETEST %_xdrive%
set _xtmp=%_xdrive% (%_xtmp%)
set XSET=/BACKGROUND BLUE/COLOR LIGHTGRAY/XPOS 20
XSET/YPOS 5/PROMPT"%_xtmp%"
XSET/PROMPT "%_xdir%"
XSET/PROMPT "%_xfile%"
XSET/PROMPT "%_xoptions%"
set XSET=/XPOS %_xpos%/YPOS 20
XSET/UPPER/COLOR MAGENTA/PROMPT"Type a key to make a choice (1,2,3,D,P,F,O,Q)" _xkey KEY "123DPFOQ"
set XSET=
:: ┌────────────────────────────────────────────────────────────────────────┐
:: ├── Jump here after an option, if you do not have to redraw the screen ──┤
:: └────────────────────────────────────────────────────────────────────────┘
:waitkey
goto menu%_xkey%
:: ┌───────────────────────────────────────┐
:: │ CHOICE 1: List the directory contents│
:: └───────────────────────────────────────┘
:menu1
cls
dir %_xoptions% %_xdrive%%_xdir%%_xfile%
pause
goto menu
:: ┌─────────────────────────┐
:: │ CHOICE 2: List a file │
:: └─────────────────────────┘
:menu2
XSET _xtmp FPATH %_xdrive%%_xdir%%_xfile%
XSET/XPOS %_xpos%/COLOR HIGHLIGHT/PROMPT"Filename: "/DEFAULT _xtmp
if exist %_xtmp% goto fexist
XSET/XPOS %_xpos%/BLINK/COLOR RED/PROMT"Error: File does not exist."
pause
goto menu
:fexist
:: Test for wildcards
for %%f in (%_xtmp%) do set _xtmp2=%%f
if "_xtmp2" == "_xtmp" goto listf
XSET/XPOS %_xpos%/BLINK/COLOR RED/PROMT"Error: Only one file may be specified."
pause
goto menu
:listf
more < %_xtmp%
pause
goto menu
:: ┌─────────────────────────┐
:: │ CHOICE D: Change drive │
:: └─────────────────────────┘
:menuD
XSET/XPOS %_xpos%/COLOR YELLOW/PROMPT"Choose a drive (A-Z)"/UPPER _xtmp KEY "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
XSET/SEARCH"READABLE" _xtmp2 DRIVETEST %_xtmp%
if not "%_xtmp2%" == "" goto chdrv
xset _xtmp2 DRIVETEST %_xtmp%
XSET/XPOS %_xpos%/BLINK/COLOR RED/PROMPT"Error - drive status %_xtmp%: = %_xtmp2%"
pause
goto menu
:chdrv
set _xdrive=%_xtmp%:
%_xdrive%
:: Get current directory
XSET/MID 3 100 _xdir FDIR *
goto menu
:: ┌─────────────────────────────┐
:: │ CHOICE P: Change directory │
:: └─────────────────────────────┘
:menuP
set _xtmp=%_xdir%
echo:
echo:
XSET/XPOS %_xpos%/BORDER/PROMPT "New directory:"/DEFAULT _xtmp
XSET/SEARCH ":" _xtmp2 VARCOPY _xtmp
if not "%_xtmp2%" == "" goto menuP
:: remove trailing \ (if any)
XSET/REGEXP/CHANGE "\\$" "" _xtmp="%_xtmp%"
:: check if directory exist
if not exist %_xtmp%\nul goto chdirError
XSET _xdir VARCOPY _xtmp
cd %_xdir%
set _xdir=%_xdir%\
goto menu
:chdirError
XSET/XPOS %_xpos%/BLINK/COLOR RED/PROMT"Error: Directory not existing."
pause
goto menu
:: ┌─────────────────────────────┐
:: │ CHOICE F: Filename │
:: └─────────────────────────────┘
:menuF
set _xtmp=%_xfile%
XSET/XPOS %_xpos%/COLOR LIGHTBLUE/PROMPT"FileSpec: "/DEFAULT _xtmp
XSET/SEARCH ":" _xtmp2 VARCOPY _xtmp
if not "%_xtmp2%" == "" goto menuF
XSET/SEARCH "\" _xtmp2 VARCOPY _xtmp
if not "%_xtmp2%" == "" goto menuF
XSET _xfile VARCOPY _xtmp
goto menu
:: ┌─────────────────────────────┐
:: │ CHOICE O: Options │
:: └─────────────────────────────┘
:menuO
XSET/XPOS %_xpos%/COLOR GREEN/PROMPT"Dir options: "/DEFAULT _xoptions
goto menu
:menuQ
:end