home *** CD-ROM | disk | FTP | other *** search
/ Phoenix CD 2.0 / Phoenix_CD.cdr / 16c / yesnope.zip / YEPNOPE.PAS < prev   
Pascal/Delphi Source File  |  1986-07-29  |  3KB  |  104 lines

  1. Program YepNope;
  2.  
  3. {Turbo Pascal 3.01
  4.  
  5. This program is for use in a batch file.  It will set the error level
  6. for testing  and conditional branching.  An answer of Y will set the
  7. error level to 1, otherwise it will return zero.  It uses the parameter you
  8. give it as a prompt when it is called.  For example, if you include the
  9. command line "YEPNOPE Do you wish to load sidekick"  in your batch file, the
  10. screen will display "Do you wish to load sidekick [Y/N] ? ".  If you answer
  11. Y then your next line should test the error level for a value of 1, and branch
  12. (or not) as appropriate.
  13.  
  14. The following would be an example of a typical use in a batch file:
  15.  
  16.      YEPNOPE Do you wish to load sidekick
  17.      IF ERRORLEVEL NOT 1 GOTO NOTSK
  18.      SK
  19.      ERRLEV0
  20.        REM ERRLEV0.COM is a simple machine language program to reset the
  21.        REM DOS error level to zero.  Most programs do not change it,
  22.        REM and you don't want to leave it at one.  ERRLEV0.COM is 6 bytes.
  23.      :NOTSK
  24.      REM DO SOMETHING ELSE
  25.      SOMETHING ELSE
  26.      SOMETHING ELSE
  27.      ETC.
  28.  
  29. Note that you may have 10 words as the prompt, inserted as parameters in the
  30. command line.  Each may be up to 12 characters long.  Of course, anything
  31. longer than about 75 characters will wrap on the screen, so you should think
  32. about this.  One other point.  Errorlevel is a maximum value in MS-Dos.
  33. If errorlevel 1 is true, so is errorlevel 0, and if errorlevel 2 is true,
  34. so is errorlevel 1 and errorlevel 0, and so on.
  35.  
  36. The following is a script to create ERRLEV0.COM with DEBUG:
  37.  
  38. At the DOS command line type, DEBUG ERRLEV0.COM
  39. You should then see:
  40.  
  41.  
  42. File not found
  43. -
  44.  
  45. The "-" is the debug prompt.  Enter the following.  (Do not enter the
  46. XXXX:XXXX numbers); they are displayed by debug.
  47.  
  48. Now type the following:
  49.  
  50.  
  51. -a100                   ;Command to assemble the program at 100H
  52. XXXX:0100 mov ah,4c     ;Dos function to set program errorlevel on termination
  53. XXXX:0102 mov al,00     ;Errorlevel code to return to Dos
  54. XXXX:0104 int 21        ;Dos function call interrupt
  55. XXXX:0106               ;Enter only a carriage return here
  56. -rcx                    ;Enter "rcx" to get the CX register
  57. CX 0000                 ;Register CX contains length of program, here 0.
  58. :6                      ;enter the number 6, carriage return
  59. -w                      ;enter "w", the command to write the program to disk
  60. Writing 0006 bytes      ;you should see this
  61. -q                      ;enter "q" (for quit), and a carriage return
  62.  
  63. Debug will now exit to the DOS prompt, and ERRLEV0.COM should be present on
  64. disk.
  65.  
  66. ERRLEV0.COM is very simple.  It does nothing but exit, setting its error
  67. level at 0.
  68.  
  69. The following is the Turbo Pascal Code for YEPNOPE.
  70.  
  71.                            Rick Housh
  72.                            5811 W. 85th Terr.
  73.                            Overland Park, Ks. 66207
  74.  
  75.                            Compuserve PIN 72466,212                        }
  76.  
  77.  
  78. var
  79.  
  80. i : integer;
  81. ans : char;
  82.  
  83. Str : array [1..10] of string[12];
  84. BigStr : String[255];
  85.  
  86. begin
  87.   Bigstr := '';
  88.   for i := 1 to ParamCount do
  89.     begin
  90.       str[i] := '';
  91.       str[i] := paramstr(i);
  92.       BigStr := BigStr + ' ' +str[i];
  93.     end;
  94.   BigStr := BigStr + ' [Y/N] ? ';
  95.   Write(BigStr);
  96.   Repeat
  97.     begin
  98.       Read(kbd,ans);
  99.       ans := Upcase(ans);
  100.     end;
  101.   until (ans = 'Y') or (ans = 'N');
  102.   WriteLn(ans);
  103.   If ans = 'Y' then halt(1) else halt(0);
  104. end.