home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix CD 2.0
/
Phoenix_CD.cdr
/
16c
/
yesnope.zip
/
YEPNOPE.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1986-07-29
|
3KB
|
104 lines
Program YepNope;
{Turbo Pascal 3.01
This program is for use in a batch file. It will set the error level
for testing and conditional branching. An answer of Y will set the
error level to 1, otherwise it will return zero. It uses the parameter you
give it as a prompt when it is called. For example, if you include the
command line "YEPNOPE Do you wish to load sidekick" in your batch file, the
screen will display "Do you wish to load sidekick [Y/N] ? ". If you answer
Y then your next line should test the error level for a value of 1, and branch
(or not) as appropriate.
The following would be an example of a typical use in a batch file:
YEPNOPE Do you wish to load sidekick
IF ERRORLEVEL NOT 1 GOTO NOTSK
SK
ERRLEV0
REM ERRLEV0.COM is a simple machine language program to reset the
REM DOS error level to zero. Most programs do not change it,
REM and you don't want to leave it at one. ERRLEV0.COM is 6 bytes.
:NOTSK
REM DO SOMETHING ELSE
SOMETHING ELSE
SOMETHING ELSE
ETC.
Note that you may have 10 words as the prompt, inserted as parameters in the
command line. Each may be up to 12 characters long. Of course, anything
longer than about 75 characters will wrap on the screen, so you should think
about this. One other point. Errorlevel is a maximum value in MS-Dos.
If errorlevel 1 is true, so is errorlevel 0, and if errorlevel 2 is true,
so is errorlevel 1 and errorlevel 0, and so on.
The following is a script to create ERRLEV0.COM with DEBUG:
At the DOS command line type, DEBUG ERRLEV0.COM
You should then see:
File not found
-
The "-" is the debug prompt. Enter the following. (Do not enter the
XXXX:XXXX numbers); they are displayed by debug.
Now type the following:
-a100 ;Command to assemble the program at 100H
XXXX:0100 mov ah,4c ;Dos function to set program errorlevel on termination
XXXX:0102 mov al,00 ;Errorlevel code to return to Dos
XXXX:0104 int 21 ;Dos function call interrupt
XXXX:0106 ;Enter only a carriage return here
-rcx ;Enter "rcx" to get the CX register
CX 0000 ;Register CX contains length of program, here 0.
:6 ;enter the number 6, carriage return
-w ;enter "w", the command to write the program to disk
Writing 0006 bytes ;you should see this
-q ;enter "q" (for quit), and a carriage return
Debug will now exit to the DOS prompt, and ERRLEV0.COM should be present on
disk.
ERRLEV0.COM is very simple. It does nothing but exit, setting its error
level at 0.
The following is the Turbo Pascal Code for YEPNOPE.
Rick Housh
5811 W. 85th Terr.
Overland Park, Ks. 66207
Compuserve PIN 72466,212 }
var
i : integer;
ans : char;
Str : array [1..10] of string[12];
BigStr : String[255];
begin
Bigstr := '';
for i := 1 to ParamCount do
begin
str[i] := '';
str[i] := paramstr(i);
BigStr := BigStr + ' ' +str[i];
end;
BigStr := BigStr + ' [Y/N] ? ';
Write(BigStr);
Repeat
begin
Read(kbd,ans);
ans := Upcase(ans);
end;
until (ans = 'Y') or (ans = 'N');
WriteLn(ans);
If ans = 'Y' then halt(1) else halt(0);
end.