BBS: Inland Empire Archive Date: 02-06-93 (15:01) Number: 395 From: RICK PEDLEY Refer#: NONE To: DAVID SOLLY Recvd: NO Subj: Cursor action Conf: (2) Quik_Bas
On 02-05-93 David Solly wrote to All...
.... and here's a slightly different method that assembles the
string only when the user has ended an input, by reading the
characters directly off the screen:
DECLARE FUNCTION BuildStr$ (R%, C%, N%)
DEFINT A-Z
CLS
ColStart = 79
RowStart = 2
NewPos = ColStart
NumChars = 0
DO
LOCATE RowStart, NewPos, 1, 6, 7
K$ = ""
K$ = INKEY$
IF LEN(K$) THEN
LOCATE , , 0 'Immediately turn cursor off -- then
K = ASC(RIGHT$(K$, 1)) ' fiddle with its position.
SELECT CASE K
CASE 13, 27 'Enter or Escape.
EXIT DO
CASE 8 'Backspace.
IF NumChars > 0 THEN
LOCATE , POS(0) + 1
PRINT " ";
NewPos = POS(0) - 1
NumChars = NumChars - 1
END IF
CASE 32 TO 255
PRINT K$;
NumChars = NumChars + 1 'Don't build a string yet,
NewPos = POS(0) - 2 ' just count char's.
IF NewPos < 1 THEN EXIT DO 'Cursor is already at left
CASE ELSE ' margin - single line input.
BEEP 'Reject any other keys.
END SELECT
END IF
LOOP
S$ = BuildStr$(RowStart, ColStart, NumChars)
'Just to test result:
LOCATE 20, 1: PRINT S$
END
FUNCTION BuildStr$ (R, C, N)
S$ = ""
FOR x = C - N - (N > 0) TO C
S$ = S$ + CHR$(SCREEN(R, x))
NEXT x
BuildStr$ = S$
END FUNCTION
... OFFLINE 1.43 * At Borger King we do it our way -- your way is irrelevant.
--- Maximus 2.01wb
* Origin: The BULLpen BBS * Intel 14.4EX (613)549-5168 (1:249/140)

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