home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
dbutil.zip
/
KEY-IN.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1987-02-14
|
4KB
|
158 lines
* KEY-IN.CMD
*
* This file will patch a running dBASE application to
* allow examination of the last keyboard key-press by
* PEEK (KEY:IN). Used for aborting a DO WHILE LOOP
* without terminating program execution.
*
* Written by: Gene Head
* 2860 NW Skyline Drive
* Corvallis, Oregon 97330
* (503) 758-0279
*
* Last up-date: 12/4/83
*
* APPLICATION: I wanted to show text files whose lines are saved
* as continuous records, each record of one 80-character field
* was a single line of text. There is no way in dBASE of aborting
* output without terminating the program. Using PATCH-IT.CMD
* the text file was displayed until a control-C was typed from
* the keyboard using the following dBASE code:
*
* USE TEXT:FILE
* DO WHILE .NOT. EOF .AND. PEEK(KEY:PRESS) <> 3
* ? TRIM(TEXT:LINE)
* ENDDO
*
* SYNOPSIS: Whenever a key is pressed the direct console IO
* routine in dBASE II saves the character at a memory location.
* This location can't be directly checked because it is set to zero
* the next time the console is polled and no character is
* waiting. So we install one addtional storage byte where the input
* key is stored but NOT changed until another key is pressed.
*
* There is no room to make the patch in-line so I chose to use
* the RAM dedicated to the custom screen handeling, specifically
* the characters used when you QUIT dBASE II. Thes characters are
* saved and can be restored if desired.
*
* This patch can be made permanent using DDT if you desire and you
* have the extra room in the screen IO RAM.
*
* The old code looks like this:
*
* MVI E,0FFH ;DO DIRECT CONSOLE IO
* MVI C,6
* CALL 5
* ORA A
* RZ
* JUMP:CODE STA VECTOR:1,VECTOR:2
* RET
*
* The new code looks like this:
*
* MVI E,0FFH ;DO DIRECT CONSOLE IO
* MVI C,6
* CALL 5
* ORA A
* RZ
* JUMP:CODE JUMP PATCH ;JUMP TO NEW CODE AREA
* RET
*
* PATCH STA VECTOR:1,VECTOR:2 ;SAVE TO THE ORIGINAL LOCATION
* STA KEY:PRESS ;SAVE TO THE NEW LOCATION ALSO
* RET ;RETURN
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* PATCH-IT.MEM holds the variables if we have already
* determined the location of the IO routine
* Find the old code
SET TALK OFF
STORE FILE('KEY-IN.MEM') TO PATCHED
IF .NOT. PATCHED
* Define start and end of search area
* This window may need to be expanded to find the patch
STORE 14000 TO START
STORE 20000 TO END
DO WHILE START < END
* Look for first matching byte
IF PEEK(START) = 30
* Check next four bytes for exact match
IF PEEK(START+1) = 255 .AND. PEEK(START+2) = 14;
.AND. PEEK(START+3) = 6 .AND. PEEK(START+9) = 50
* START+9 IS NOT A TYPO
* Set found flag
STORE T TO FOUND
* Save the location of the patch and the vectors
STORE START + 09 TO JUMP:PATCH
STORE PEEK(START + 10) TO VECTOR:1
STORE PEEK(START + 11) TO VECTOR:2
* Clear the DO-LOOP
STORE END TO START
ENDIF Exact match
ENDIF First byte match
* Skip to next byte
STORE START+1 TO START
ENDDO While START < END
RELEASE END, START
SAVE TO KEY-IN.MEM
ELSE
* IF THE MEMORY FILE IS HERE USE IT
RESTORE FROM KEY-IN.MEM
ENDIF FILE('KEY-IN.MEM')
* VERIFY PATCH AREA
STORE JUMP:PATCH-9 TO START
* Check next four bytes for exact match
IF PEEK(START+1) = 255 .AND. PEEK(START+2) = 14;
.AND. PEEK(START+3) = 6 .AND. PEEK(START+9) = 50
* START+9 IS NOT A TYPO
ELSE
ERASE
?
? 'BAD PATCH DATA. DELETE FILE "KEY-IN.MEM" AND TRY AGAIN.'
CANCEL
ENDIF
* Now that we know where to patch let's actually do the patching. . .
* SAVE SCREEN OUTPUT AFTER 'QUIT' DATA IF YOU PLAN TO UN-PATCH LATER
STORE 321 TO ADDRESS
STORE ADDRESS+7 TO KEY:PRESS
STORE PEEK(ADDRESS+1) TO K1
STORE PEEK(ADDRESS+2) TO K2
STORE PEEK(ADDRESS+3) TO K3
STORE PEEK(ADDRESS+4) TO K4
STORE PEEK(ADDRESS+5) TO K5
STORE PEEK(ADDRESS+6) TO K6
STORE PEEK(ADDRESS+7) TO K7
* WRITE THE PATCH CODE
POKE ADDRESS, 50,VECTOR:1, VECTOR:2, 50,72,1, 201
* WRITE THE NEW EXECUTION PATH
POKE JUMP:PATCH, 195, 65, 1
RELEASE ALL EXCEPT K*
ENDIF
* To Un-Patch if necessary:
* POKE KEY:PRESS-7, K1,K2,K3,K4,K5,K6,K7