Home » CEEFAX disks » telesoftware15.adl » 21-02-89/Ask_Key\DO

21-02-89/Ask_Key\DO

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » CEEFAX disks » telesoftware15.adl
Filename: 21-02-89/Ask_Key\DO
Read OK:
File size: 0542 bytes
Load address: 0000
Exec address: FFFFFFFF
File contents
                                    ASK_KEY

                                 by Barry Wood



A simple but useful utility to allow you to create interactive batch files.
Follow the ASK_KEY command with a list of permissable keys, and when one of them
is pressed ERRORLEVEL will return a number corresponding to the selected item.
There may be any number of keys in the list.

Example usage:

ASK_KEY yn

Here ASK_KEY will be loaded and wait until either the Y or N keys are pressed.
Otherwise it will do nothing unless aborted by a Control+C. The state of Caps
Lock is irrelevant as the key list and the keyboard input are converted to upper
case.

When a valid key has been pressed, ASK_KEY returns to your batch file with
ERRORLEVEL set to a number N, where the Nth key in the list was pressed. So in
the above example, pressing Y would set ERRORLEVEL to 1, and N would set it to
2.

The only other number which may be returned is 0 which is passed back if there
was no or more than one key list.

There is a demonstration batch file ASK_DEMO.BAT in the Toolkit directory. Run
it and then load it into a word processor to see the utility in action.

The C source code is included as ASK_KEY.C

Hint: If ASK_KEY.COM is to be used frequently on a floppy-based system, put it
in a ram disc for faster loading.

00000000  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000020  20 20 20 20 41 53 4b 5f  4b 45 59 0d 0a 0d 0a 20  |    ASK_KEY.... |
00000030  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
00000050  62 79 20 42 61 72 72 79  20 57 6f 6f 64 0d 0a 0d  |by Barry Wood...|
00000060  0a 0d 0a 0d 0a 41 20 73  69 6d 70 6c 65 20 62 75  |.....A simple bu|
00000070  74 20 75 73 65 66 75 6c  20 75 74 69 6c 69 74 79  |t useful utility|
00000080  20 74 6f 20 61 6c 6c 6f  77 20 79 6f 75 20 74 6f  | to allow you to|
00000090  20 63 72 65 61 74 65 20  69 6e 74 65 72 61 63 74  | create interact|
000000a0  69 76 65 20 62 61 74 63  68 20 66 69 6c 65 73 2e  |ive batch files.|
000000b0  0d 0a 46 6f 6c 6c 6f 77  20 74 68 65 20 41 53 4b  |..Follow the ASK|
000000c0  5f 4b 45 59 20 63 6f 6d  6d 61 6e 64 20 77 69 74  |_KEY command wit|
000000d0  68 20 61 20 6c 69 73 74  20 6f 66 20 70 65 72 6d  |h a list of perm|
000000e0  69 73 73 61 62 6c 65 20  6b 65 79 73 2c 20 61 6e  |issable keys, an|
000000f0  64 20 77 68 65 6e 20 6f  6e 65 20 6f 66 20 74 68  |d when one of th|
00000100  65 6d 0d 0a 69 73 20 70  72 65 73 73 65 64 20 45  |em..is pressed E|
00000110  52 52 4f 52 4c 45 56 45  4c 20 77 69 6c 6c 20 72  |RRORLEVEL will r|
00000120  65 74 75 72 6e 20 61 20  6e 75 6d 62 65 72 20 63  |eturn a number c|
00000130  6f 72 72 65 73 70 6f 6e  64 69 6e 67 20 74 6f 20  |orresponding to |
00000140  74 68 65 20 73 65 6c 65  63 74 65 64 20 69 74 65  |the selected ite|
00000150  6d 2e 0d 0a 54 68 65 72  65 20 6d 61 79 20 62 65  |m...There may be|
00000160  20 61 6e 79 20 6e 75 6d  62 65 72 20 6f 66 20 6b  | any number of k|
00000170  65 79 73 20 69 6e 20 74  68 65 20 6c 69 73 74 2e  |eys in the list.|
00000180  0d 0a 0d 0a 45 78 61 6d  70 6c 65 20 75 73 61 67  |....Example usag|
00000190  65 3a 0d 0a 0d 0a 41 53  4b 5f 4b 45 59 20 79 6e  |e:....ASK_KEY yn|
000001a0  0d 0a 0d 0a 48 65 72 65  20 41 53 4b 5f 4b 45 59  |....Here ASK_KEY|
000001b0  20 77 69 6c 6c 20 62 65  20 6c 6f 61 64 65 64 20  | will be loaded |
000001c0  61 6e 64 20 77 61 69 74  20 75 6e 74 69 6c 20 65  |and wait until e|
000001d0  69 74 68 65 72 20 74 68  65 20 59 20 6f 72 20 4e  |ither the Y or N|
000001e0  20 6b 65 79 73 20 61 72  65 20 70 72 65 73 73 65  | keys are presse|
000001f0  64 2e 0d 0a 4f 74 68 65  72 77 69 73 65 20 69 74  |d...Otherwise it|
00000200  20 77 69 6c 6c 20 64 6f  20 6e 6f 74 68 69 6e 67  | will do nothing|
00000210  20 75 6e 6c 65 73 73 20  61 62 6f 72 74 65 64 20  | unless aborted |
00000220  62 79 20 61 20 43 6f 6e  74 72 6f 6c 2b 43 2e 20  |by a Control+C. |
00000230  54 68 65 20 73 74 61 74  65 20 6f 66 20 43 61 70  |The state of Cap|
00000240  73 0d 0a 4c 6f 63 6b 20  69 73 20 69 72 72 65 6c  |s..Lock is irrel|
00000250  65 76 61 6e 74 20 61 73  20 74 68 65 20 6b 65 79  |evant as the key|
00000260  20 6c 69 73 74 20 61 6e  64 20 74 68 65 20 6b 65  | list and the ke|
00000270  79 62 6f 61 72 64 20 69  6e 70 75 74 20 61 72 65  |yboard input are|
00000280  20 63 6f 6e 76 65 72 74  65 64 20 74 6f 20 75 70  | converted to up|
00000290  70 65 72 0d 0a 63 61 73  65 2e 0d 0a 0d 0a 57 68  |per..case.....Wh|
000002a0  65 6e 20 61 20 76 61 6c  69 64 20 6b 65 79 20 68  |en a valid key h|
000002b0  61 73 20 62 65 65 6e 20  70 72 65 73 73 65 64 2c  |as been pressed,|
000002c0  20 41 53 4b 5f 4b 45 59  20 72 65 74 75 72 6e 73  | ASK_KEY returns|
000002d0  20 74 6f 20 79 6f 75 72  20 62 61 74 63 68 20 66  | to your batch f|
000002e0  69 6c 65 20 77 69 74 68  0d 0a 45 52 52 4f 52 4c  |ile with..ERRORL|
000002f0  45 56 45 4c 20 73 65 74  20 74 6f 20 61 20 6e 75  |EVEL set to a nu|
00000300  6d 62 65 72 20 4e 2c 20  77 68 65 72 65 20 74 68  |mber N, where th|
00000310  65 20 4e 74 68 20 6b 65  79 20 69 6e 20 74 68 65  |e Nth key in the|
00000320  20 6c 69 73 74 20 77 61  73 20 70 72 65 73 73 65  | list was presse|
00000330  64 2e 20 53 6f 20 69 6e  0d 0a 74 68 65 20 61 62  |d. So in..the ab|
00000340  6f 76 65 20 65 78 61 6d  70 6c 65 2c 20 70 72 65  |ove example, pre|
00000350  73 73 69 6e 67 20 59 20  77 6f 75 6c 64 20 73 65  |ssing Y would se|
00000360  74 20 45 52 52 4f 52 4c  45 56 45 4c 20 74 6f 20  |t ERRORLEVEL to |
00000370  31 2c 20 61 6e 64 20 4e  20 77 6f 75 6c 64 20 73  |1, and N would s|
00000380  65 74 20 69 74 20 74 6f  0d 0a 32 2e 0d 0a 0d 0a  |et it to..2.....|
00000390  54 68 65 20 6f 6e 6c 79  20 6f 74 68 65 72 20 6e  |The only other n|
000003a0  75 6d 62 65 72 20 77 68  69 63 68 20 6d 61 79 20  |umber which may |
000003b0  62 65 20 72 65 74 75 72  6e 65 64 20 69 73 20 30  |be returned is 0|
000003c0  20 77 68 69 63 68 20 69  73 20 70 61 73 73 65 64  | which is passed|
000003d0  20 62 61 63 6b 20 69 66  20 74 68 65 72 65 0d 0a  | back if there..|
000003e0  77 61 73 20 6e 6f 20 6f  72 20 6d 6f 72 65 20 74  |was no or more t|
000003f0  68 61 6e 20 6f 6e 65 20  6b 65 79 20 6c 69 73 74  |han one key list|
00000400  2e 0d 0a 0d 0a 54 68 65  72 65 20 69 73 20 61 20  |.....There is a |
00000410  64 65 6d 6f 6e 73 74 72  61 74 69 6f 6e 20 62 61  |demonstration ba|
00000420  74 63 68 20 66 69 6c 65  20 41 53 4b 5f 44 45 4d  |tch file ASK_DEM|
00000430  4f 2e 42 41 54 20 69 6e  20 74 68 65 20 54 6f 6f  |O.BAT in the Too|
00000440  6c 6b 69 74 20 64 69 72  65 63 74 6f 72 79 2e 20  |lkit directory. |
00000450  52 75 6e 0d 0a 69 74 20  61 6e 64 20 74 68 65 6e  |Run..it and then|
00000460  20 6c 6f 61 64 20 69 74  20 69 6e 74 6f 20 61 20  | load it into a |
00000470  77 6f 72 64 20 70 72 6f  63 65 73 73 6f 72 20 74  |word processor t|
00000480  6f 20 73 65 65 20 74 68  65 20 75 74 69 6c 69 74  |o see the utilit|
00000490  79 20 69 6e 20 61 63 74  69 6f 6e 2e 0d 0a 0d 0a  |y in action.....|
000004a0  54 68 65 20 43 20 73 6f  75 72 63 65 20 63 6f 64  |The C source cod|
000004b0  65 20 69 73 20 69 6e 63  6c 75 64 65 64 20 61 73  |e is included as|
000004c0  20 41 53 4b 5f 4b 45 59  2e 43 0d 0a 0d 0a 48 69  | ASK_KEY.C....Hi|
000004d0  6e 74 3a 20 49 66 20 41  53 4b 5f 4b 45 59 2e 43  |nt: If ASK_KEY.C|
000004e0  4f 4d 20 69 73 20 74 6f  20 62 65 20 75 73 65 64  |OM is to be used|
000004f0  20 66 72 65 71 75 65 6e  74 6c 79 20 6f 6e 20 61  | frequently on a|
00000500  20 66 6c 6f 70 70 79 2d  62 61 73 65 64 20 73 79  | floppy-based sy|
00000510  73 74 65 6d 2c 20 70 75  74 20 69 74 0d 0a 69 6e  |stem, put it..in|
00000520  20 61 20 72 61 6d 20 64  69 73 63 20 66 6f 72 20  | a ram disc for |
00000530  66 61 73 74 65 72 20 6c  6f 61 64 69 6e 67 2e 0d  |faster loading..|
00000540  0a 1a                                             |..|
00000542
21-02-89/Ask_Key\DO.m0
21-02-89/Ask_Key\DO.m1
21-02-89/Ask_Key\DO.m2
21-02-89/Ask_Key\DO.m4
21-02-89/Ask_Key\DO.m5