'=========================================================================== ' Subject: ASCII TABLE Date: 11/95 (00:00) ' Author: Peter Norton Code: QB, QBasic, PDS ' Origin: DOS World Packet: TEXT.ABC '=========================================================================== 'filename: ascii.bas 'author: Peter Norton - Felton, CA 'source: _DOS World_ number 24, Nov.1995, pp 53-54 'for: QBasic 1.x '====================================================+ ' Note: Please extract ASCII.BAT from the bottom of | ' this file and place it in it's own file before | ' running this program. This program is invoked with | ' ASCII.BAT, so put it in a directory in your PATH | ' and edit the line that calls ASCII.BAS to reflect | ' where you put it, so that it will be found. | '====================================================+ DECLARE SUB chart () DECLARE SUB special (code!) DECLARE SUB decode (code!) DEF SEG = &HB800 'video segment address for pokes code$ = ENVIRON$("ASCII") 'variable set in batch file code = VAL(code$) COLOR 14, 1 IF code$ = "" THEN chart 'print chart and exit special code 'print special meaning IF code THEN decode code 'decode if number IF LEN(code$) = 1 THEN code = ASC(code$) decode code 'decode if single character END IF IF code = 0 THEN PRINT " Invalid parameter - "; code$; SHELL "ASCII /?" 'print usage message END IF SYSTEM '--------------8<-----cut here----->8---------------- SUB chart CLS A = 3 'a = cursor position for POKE FOR i = 1 TO 9 'i = ASCII code PRINT i; SPACE$(4); POKE A * 2, i 'position * 2 for attributes A = A + 7 NEXT i A = A + 1 FOR i = 10 TO 99 PRINT i; SPACE$(3); POKE A * 2, i A = A + 7 IF i MOD 11 = 0 THEN A = A + 3 'advance at end of line NEXT i A = A + 1 FOR i = 100 TO 255 PRINT i; SPACE$(2); POKE A * 2, i A = A + 7 IF i MOD 11 = 0 THEN A = A + 3 NEXT i COLOR 15 PRINT " Press any key to continue..."; DO LOOP WHILE INKEY$ = "" PRINT SYSTEM END SUB SUB decode (code) PRINT " Character "; CHR$(34); " "; CHR$(34); POKE (((CSRLIN - 1) * 80) + (POS(0) - 3)) * 2, code PRINT " ="; code; "Decimal, "; hexvalue$ = HEX$(code) IF LEN(hexvalue$) = 1 THEN hexvalue$ = "0" + hexvalue$ PRINT hexvalue$; " Hexadecimal" END SUB SUB special (code) SELECT CASE code CASE IS = 7 PRINT " Beep (Bell)"; CASE IS = 8 PRINT " Backspace"; CASE IS = 9 PRINT " Tab"; CASE IS = 10 PRINT " Line feed"; CASE IS = 12 PRINT " Page eject"; CASE IS = 13 PRINT " Carriage return"; CASE IS = 26 PRINT " End of file"; CASE IS = 27 PRINT " Escape"; CASE IS = 32 PRINT " Space"; END SELECT END SUB -----8<-------- ASCII.BAT -------------- @echo off echo. echo For advice on using this batch file, echo type: ASCII /? echo. if %1!==/?! goto help : top set ascii=%1 REM ====Edit the following line==== qbasic /run \basic\ascii.bas REM ======Edit the above line===== set ascii= if %2!==! goto end shift GOTO top : help echo. echo Syntax: %0 [codes...] [characters...] echo You may include any number of characters and codes, echo separating them with spaces, commas, or semicolons. echo. echo You may provide letter or number keys, decimal or hexadecimal echo numbers, and key combinations such as Ctrl+A. But you must echo precede hex numbers with &h or &H (for example, &H0A). echo. echo If you type ASCII at the DOS prompt, the program prints echo the entire ASCII chart on screen. : END