BBS: Inland Empire Archive Date: 02-11-93 (11:52) Number: 398 From: MARK BUTLER Refer#: NONE To: RUSTY GORDON Recvd: NO Subj: EditLine 1/2 Conf: (2) Quik_Bas
Once upon a time Rusty Gordon uttered these sage words to All:
RG> ....how do I put a limit to the number of characters the
RG> user can enter as in the sample below:
RG> Enter Feature Name 北北北北北北北.
I don't know about short but this'll work...
==========================8< Cut Here 8<=============================
DEFINT A-Z
DECLARE SUB EditLine (a$, exitCode)
DECLARE FUNCTION ScanCode ()
CLS
LOCATE 12, 1
PRINT "Enter a 9 character string: ";
a$ = SPACE$(9)
COLOR 0, 7
CALL EditLine(a$, exitCode)
COLOR 7, 0
PRINT
PRINT
PRINT "a$ = "; a$
PRINT "exitCode ="; exitCode
'*** 'exitCode%' will help you to discren whether the user wants
'*** go back up to the field above, or the field below the current,
'*** or abort without change etc etc.
SUB EditLine (a$, exitCode) STATIC
CONST FALSE = 0, TRUE = NOT FALSE
CONST BACKSPACE = 8
CONST CTRLLEFTARROW = -115
CONST CTRLRIGHTARROW = -116
CONST CTRLY = 25
CONST CTRLQ = 17
CONST DELETEKEY = -83
CONST DOWNARROW = -80
CONST ENDKEY = -79
CONST ENTER = 13
CONST ESCAPE = 27
CONST HOME = -71
CONST INSERTKEY = -82
CONST LEFTARROW = -75
CONST RIGHTARROW = -77
CONST TABKEY = 9
CONST UPARROW = -72
row = CSRLIN
col = POS(0)
length = LEN(a$)
ptr = 0
insirt = TRUE
quit = FALSE
original$ = a$
DO
LOCATE row, col, 0
PRINT a$;
IF insirt THEN
LOCATE row, col + ptr, 1, 6, 7
ELSE
LOCATE row, col + ptr, 1, 1, 7
END IF
kee = ScanCode
SELECT CASE kee
CASE INSERTKEY
IF insirt THEN
insirt = FALSE
ELSE
insirt = TRUE
END IF
CASE BACKSPACE
IF ptr THEN
a$ = a$ + " "
a$ = LEFT$(a$, ptr - 1) + MID$(a$, ptr + 1)
ptr = ptr - 1
END IF
CASE DELETEKEY
a$ = a$ + " "
a$ = LEFT$(a$, ptr) + MID$(a$, ptr + 2)
CASE UPARROW
exitCode = 1
quit = TRUE
CASE DOWNARROW
exitCode = -1
quit = TRUE
CASE LEFTARROW
IF ptr THEN
ptr = ptr - 1
END IF
CASE RIGHTARROW
IF ptr < length - 1 THEN
ptr = ptr + 1
==========================8< Cut Here 8<=============================
>>> continued to the next message
--- timEd/B7 * This is your eggs on fried drugs..er..uh..aw forget it.
* Origin: Terminal Oasis, Portland OR (1:105/330.5)

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