home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 September / Simtel20_Sept92.cdr / msdos / batutl / battutor.arc / FUNKY.ASM < prev    next >
Assembly Source File  |  1983-08-28  |  6KB  |  180 lines

  1.                PAGE 60,132
  2. TITLE  FUNKY.COM  VER.2.1  7-AUG-83  19:30
  3. comment *
  4.  
  5.                         FUNKY.COM
  6.  
  7.  
  8.         VERSION 2.0     7-AUG-83
  9.  
  10.         Written by      Warren Craycroft
  11.                         6236 Oakdale Ave.
  12.                         Oakland, CA  94605
  13.  
  14.  
  15.         (C)  1983  by Warren Craycroft.  Permission is granted to copy and
  16.         distribute this program, including source code, provided that no
  17.         charge shall be made except for a reasonable charge for the media
  18.         and handling, and that this notice shall remain intact in all copies.
  19.  
  20.  
  21. *
  22. comment *
  23.         This program is a utility that can be used with DOS 2.0
  24.         to allow an n-way branch (typically a menu selection) during
  25.         execution of a batch file.  The program does this by
  26.         testing the user's one key response and returning to DOS an
  27.         "errorlevel" code corresponding to the EXTENDED keycode.
  28.         This errorlevel code can then be tested by the
  29.         batch file program using the IF ERRORLEVEL n  statement.
  30.  
  31.         When FUNKY is run in a batch file, an appropriate menu
  32.         has been displayed for the user via REM or ECHO statements.
  33.         The user answers with any key that generates an EXTENDED keycode.
  34.         Examples of such keys are the following:
  35.  
  36.                 the function keys F1 - F10
  37.  
  38.                 the shifted function keys
  39.  
  40.                 the Alt-function keys
  41.  
  42.                 the cursor control keys
  43.  
  44.                 most Alt-alphanumeric keys
  45.  
  46.         If a key that does not generate an EXTENDED code is struck, then this
  47.         program tests for the ESC key, and returns one of two codes:
  48.  
  49.                 if the non-extended key is ESC,  errorlevel = 0
  50.  
  51.                 for any other non-extended key,  errorlevel = 255
  52.  
  53.         No other error-checking is done by FUNKY.  The subsequent Batch
  54.         File IF tests must determine whether the keystroke response is
  55.         within the extended keycode range, or is an ESC key or other
  56.         "regular" key.  Some examples of extended keycodes are as follows:
  57.  
  58.                 F1 ... F10              59 ... 68
  59.  
  60.                 Shifted F1 ... F10      84 ... 93
  61.  
  62.                 Control F1 ... F10      94 ... 103
  63.  
  64.                 Alt     F1 ... F10      104 ... 113
  65.  
  66.  
  67.  
  68.         A complete list of extended codes and the keys that generate them can
  69.         be found in the IBM Tech Reference, Revised 1982, Table 26, P. 3-14
  70.  
  71.         Remember that the subsequent IF clauses are "greater than or equal
  72.         to"  and  "less than", so the order of the IF tests is important.
  73.  
  74.                 IF ERRORLEVEL N         means   if errorlevel >= n
  75.  
  76.                 IF NOT ERRORLEVEL N     means   if errorlevel < n
  77.  
  78.  
  79.                 INCLUDE THESE FILES WHEN ASSEMBLING:
  80.  
  81.                         PARSER.INC
  82.                         QDISPLAY.INC
  83.                         QGETKEY.INC
  84.                         Q_CMDS.INC
  85.  
  86.  
  87. *
  88. ;
  89. ;               constant equates
  90. ;
  91. ESC_CHAR        EQU     1BH             ;ascii ESC keycode
  92. BEL_CHAR        EQU     07              ;ascii BEL code
  93. CR              EQU     0DH             ;ascii carriage return
  94. LF              EQU     0AH             ;ascii  line feed
  95. BLANK_CHAR      EQU     20H             ;ascii blank keycode
  96. ;
  97. ;       declare a relocatable segment.  Follow the .COM file requirements
  98. ;       by ORG'ing to 100H and making all segment register references relative
  99. ;       to CS (no relocatable values MOV'ed into segment registers).
  100. ;
  101. ;
  102. COM_CODE      SEGMENT
  103. ;
  104.                 ORG     80H             ;Program Segment Prefix command line
  105. PSP_CMD_LINE    LABEL   BYTE
  106.  
  107.                 ORG     100H            ;for COM file
  108. ;
  109.                 ASSUME  CS:COM_CODE,DS:COM_CODE  ;tell assembler values in
  110.                                         ;CS and DS upon entering this code
  111. ;
  112. ;       parse command line in PSP for commands inside slashes
  113. ;
  114. ;       leave CX pointing to first character after leading delimiters if no
  115. ;       slashes, or first char after second slash
  116. ;
  117. START           PROC    FAR             ;FAR is meaningless; no RET's
  118. ;
  119. ;       address of PSP's unformatted command line into SI
  120. ;
  121.                 MOV     SI,OFFSET PSP_CMD_LINE
  122. ;
  123. INCLUDE         PARSER.INC
  124. INCLUDE         QDISPLAY.INC
  125. INCLUDE         QGETKEY.INC
  126. ;
  127. ;       AL = user's answering keystroke.  Test it for extended code
  128. ;
  129.                 OR      AL,AL           ;is the keycode zero?
  130.                 JZ      EXTENDED        ;jump if yes, it's an extended code
  131.                                         ;DOS gives extended code on 2nd call
  132. ;
  133. ;       not an extended keycode.  FUNKY looks for only one "regular" key,
  134. ;       the ESC key:
  135. ;
  136. ;               if the non-extended key is ESC, errorlevel = 0
  137. ;
  138. ;               for any other non-extended key, errorlevel = 255
  139. ;
  140.                 MOV     AH,AL           ;non-extended keycode into AH
  141.                 SUB     AL,AL           ;return zero in AL if ESC key
  142.                 CMP     AH,ESC_CHAR     ;is it ESC?
  143.                 JE      EXIT            ;if yes, return zero errorlevel
  144.                 DEC     AL              ;else return 255 errorlevel for ...
  145.                 JMP     EXIT            ;... any other non-extended key
  146. ;
  147. ;       an "extended keycode flag" was received on first call to DOS
  148. ;       so call again to get the actual extended code
  149. ;
  150. EXTENDED:       MOV     AH,8            ;else extended keycode was typed
  151.                 INT     21H             ;get extended code with 2nd call
  152. ;
  153. ;       AL contains the extended keycode.  Examples are
  154. ;
  155. ;               F1 ... F10              59 ... 68
  156. ;
  157. ;               Shifted F1 ... F10      84 ... 93
  158. ;
  159. ;               Alt  F1 ... F10         104 ... 113
  160. ;
  161. ;       Return this code as the errorlevel
  162. ;
  163. ;       The batch file that called FUNKY should then branch appropriatly
  164. ;       using IF tests.
  165. ;
  166. EXIT:           MOV     AH,4CH          ;DOS fn call for exit
  167.                 INT     21H             ;(DOS Manual, p. D-49)
  168. START           ENDP
  169. PAGE
  170. INCLUDE         Q_CMDS.INC
  171. PAGE
  172. ;
  173. ;        variable data area
  174. ;
  175. USERS_ATTRIB    DB      1 DUP(?)        ;temp storage of character attrib
  176. ;
  177. COM_CODE        ENDS
  178.                 END     START
  179. \; c:\; d:\
  180.                 s