BBS: Inland Empire Archive Date: 02-10-93 (22:53) Number: 400 From: JIM LITTLE Refer#: NONE To: CASEY PEARSON Recvd: NO Subj: QuickBasic Program # 2/2 Conf: (2) Quik_Bas
>>> Continued from previous message
'valid character, with insert on
text = LEFT$(text, curletter - 1) + keystroke + RIGHT$(text, LEN(text) -
curletter = curletter + 1
IF curletter > topletter + right - left THEN
topletter = topletter + 1
END IF
PrintLine topletter, text, left, right
ELSEIF ASC(keystroke) >= 32 AND ASC(keystroke) <= 127
AND NOT insert AND (cu
'valid character, with insert off
MID$(text, curletter, 1) = keystroke
IF curletter = LEN(text) THEN 'add a null
character to the end (will b
text = text + CHR$(255)
END IF
curletter = curletter + 1
IF curletter > topletter + right - left THEN
topletter = topletter + 1
PrintLine topletter, text, left, right
ELSE
PRINT keystroke;
END IF
ELSEIF keystroke = CHR$(13) THEN
flag = cOK
finished = True
END IF
LOOP UNTIL finished
text = LEFT$(text, LEN(text) - 1) 'strip null character from end
PrintLine 1, text, left, right
END SUB
SUB PrintLine (topletter%, text$, left%, right%)
'prints a line of text, starting with topletter, within bounds of
' left and right
LOCATE , left
PRINT MID$(text, topletter, right - left + 1); SPC(right - POS(0) + 2);
END SUB
I haven't included GetStroke, since there is a lot of keyboard trapping
involved so those #@$! extended keys can be returned. (Does anyone
know a better way? PLEASE? (In QBasic, no less))
However, here's the essentials:
SUB GetStroke (keystroke$)
'turn keys 11-24 on
greykey = "" 'global variable -- set equal to k____ by
subroutines in main mod
DO
keystroke = INKEY$
LOOP WHILE keystroke = "" AND greykey = ""
'essentially, loops until normal key pressed. If extended key pressed, then
' key trapping branches to subroutines in main module, and greykey is set
' to appropriate constant.
IF greykey <> "" THEN 'special key pressed
keystroke = greykey
END IF
'turn keys 11-24 off
END SUB
Well, I hope this helps.. Good luck in your efforts.
-Jim
* SLMR 2.1a * This is a funny tagline.
--- WM v2.06/91-0012
* Origin: Com-Dat BBS Hillsboro, OR. HST (503) 681-0543 (1:105/314)

Books at Amazon:
Back to BASIC: The History, Corruption, and Future of the Language
Hackers: Heroes of the Computer Revolution (including Tiny BASIC)
Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution
The Advent of the Algorithm: The Idea that Rules the World
Moths in the Machine: The Power and Perils of Programming
Mastering Visual Basic .NET