vbdpss.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Article Q50944, Example
                                                 Contents  Index  Back
─────────────────────────────────────────────────────────────────────────────
                           Knowledge Base Contents  Knowledge Base Index
 
 Using CALL INTERRUPT to Push Characters into Keyboard Buffer, Example
 
 The program shown below, KEYPSH.BAS, sets up a table containing all of
 the scan codes for ASCII character values 32 (a space) through 126
 (~), and defines the routine PUSHSTRING that will push the passed
 string of characters into the keyboard buffer.
 
 Code Example: KEYPSH.BAS
 ------------------------
 
 To try this example in VBDOS.EXE:
 
   1. From the File menu, choose New Project.
   2. Copy the code example to the Code window.
   3. Press F5 to run the program.
 
 ' To run this program in the environment, you must invoke the
 ' environment with the /L switch to load the default Quick library:
 ' VBDOS.EXE /L for Visual Basic 1.0 for MS-DOS
 '
 ' This program works on IBM AT and PS/2 class computers, but not on
 ' IBM PC class computers.
 
 DECLARE SUB pushstring (thestring$)
 ' Use the following include file for Visual Basic 1.0 for MS-DOS:
 REM $INCLUDE: 'VBDOS.BI'
 DIM SHARED scanarray(1 TO 93) AS INTEGER
 FOR i% = 1 TO 93  ' Initialize scan code array.
         READ scanarray(i%)
 NEXT
 CALL pushstring("<Key Push!>")
 INPUT a$
 PRINT a$
 ' Define Scan Codes for ASCII characters 32 (space) through 126 (~):
 
 REM      !   "  #  $  %  &   '   (   )  *   +   ,   -   .  /
 DATA 57, 2, 40, 4, 5, 6, 8, 40, 10, 11, 9, 13, 51, 12, 52, 53
 
 REM    0  1  2  3  4  5  6  7  8   9
 DATA  11, 2, 3, 4, 5, 6, 7, 8, 9, 10
 
 REM   :   ;   <   =   >   ?  @
 DATA 39, 39, 51, 13, 52, 53, 3
 
 REM   A   B   C   D   E   F   G   H   I   J   K   L   M
 DATA 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50
 
 REM   N   O   P   Q   R   S   T   U   V   W   X   Y   Z
 DATA 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
 
 REM   [   \  ]  ^   _   `
 DATA 26, 43, 27, 7, 12, 41
 
 REM   a   b   c   d   e   f   g   h   i   j   k   l   m
 DATA 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38, 50
 
 REM   n   o   p   q   r   s   t   u   v   w   x   y   z
 DATA 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44
 
 REM   {   |   }   ~
 DATA 26, 43, 27, 41
 
 SUB pushstring (thestring$)   ' Pushes string into keyboard buffer.
    DIM inregs AS regtype
    DIM outregs AS regtype
    stringlen = LEN(thestring$)
    IF stringlen > 15 THEN stringlen = 15  ' Maximum buffer size = 15.
    FOR i% = 1 TO stringlen
       inregs.ax = &H500    ' Subfunction to push character.
       ascvalue = ASC(MID$(thestring$, i%, 1))
       IF ascvalue >= 32 AND ascvalue <= 126 THEN
          ' Assign scan code to high byte.
          inregs.cx = scanarray(ascvalue - 31) * 256
          inregs.cx = inregs.cx + ascvalue   ' Add ASCII code.
          CALL interrupt(&H16, inregs, outregs) ' Keyboard interrupt.
       END IF
    NEXT
 END SUB