BBS: Inland Empire Archive Date: 02-06-93 (13:02) Number: 394 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...
DS> I am trying to develop a variation of the foreign language vocabulary
DS> drill program which involves printing Hebrew and Arabic on the screen
DS> and accepting input in these languages.
Try this bit of code:
'Accepts left to right single-line input. Traps Enter, Escape &
'Backspace
DECLARE FUNCTION Left2Right$ (S$, R%, C%)
DEFINT A-Z
CLS
ColStart = 79
RowStart = 2
S$ = ""
NewPos = ColStart
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 LEN(S$) > 0 THEN
LOCATE , POS(0) + 1
PRINT " ";
NewPos = POS(0) - 1
S$ = RIGHT$(S$, LEN(S$) - 1) 'Shorten string by 1 unless
END IF ' length is already 0.
CASE 32 TO 255
PRINT K$;
S$ = S$ + K$
NewPos = POS(0) - 2
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
PRINT Left2Right$(S$, 20, 1)
END
FUNCTION Left2Right$ (S$, R, C)
LOCATE R, C, 0
IF LEN(S$) THEN
Left2Right$ = ""
FOR x = LEN(S$) TO 1 STEP -1
Left2Right$ = Left2Right$ + MID$(S$, x, 1)
NEXT x
PRINT Left2Right$
ELSE
PRINT "You didn't type anything!"
END IF
END FUNCTION
... OFFLINE 1.43 * IBM: IBM's worst nightmare.
--- 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