BBS: Inland Empire Archive Date: 02-08-93 (17:35) Number: 306 From: VICTOR YIU Refer#: NONE To: ERIC MAYS Recvd: NO Subj: GETINPUT 2/2 Conf: (2) Quik_Bas
>>>>>> Continued from last message... IF LEN(I$) = 1 THEN ' branch according to len. of input Update = True ' set flag to update SELECT CASE ASC(I$) CASE IS >= 32 ' a normal char: just add it to string IF (NOT Insert) OR (LEN(Out$) < MaxLen) THEN ' within limits? ' able to add anymore? IF Cursor > 0 THEN ' has user typed anything? ' Out$ = LEFT$(Out$, Cursor - 1) + I$ + MID$(Out$, Cursor) ' Out$ = LEFT$(Out$, Cursor - 1) + I$ + MID$(Out$, Cursor + 1) Out$ = LEFT$(Out$, Cursor - 1) + I$ + MID$(Out$, Cursor - (NOT Insert)) ELSE Out$ = I$ ' create new string END IF Cursor = Cursor + 1 ' advance cursor position ELSE Alarm ' can't add, so beep at them Update = False ' don't update END IF CASE 8 ' backspace IF LEN(Out$) AND (Cursor > 1) THEN 'can we backspace? Out$ = LEFT$(Out$, Cursor - 2) + MID$(Out$, Cursor) 'remove 1 char. before cursor Cursor = Cursor - 1 ' adjust cursor ELSE Alarm Update = False END IF CASE 13 ' enter EXIT DO CASE 27 ' escape IF LEN(Out$) > 0 THEN ' has user typed anything? LOCATE , StartX, 0 ' yes, so clear the string PRINT SPACE$(LEN(Out$) + 1); Out$ = "" Cursor = 1 ' resetting cursor position Update = False ' don't update: no reason to ELSE EXIT DO ' if nothing, just exit END IF END SELECT ELSE ' extended ASCII code SELECT CASE I$ CASE LeftK$ IF Cursor > 1 THEN Cursor = Cursor - 1 ' move cursor left ELSE Alarm END IF CASE RightK$ IF Cursor < LEN(Out$) + 1 THEN Cursor = Cursor + 1 ' move cursor right ELSE Alarm END IF CASE Delete$ IF LEN(Out$) > 0 AND (Cursor < LEN(Out$)) THEN Out$ = LEFT$(Out$, Cursor - 1) + MID$(Out$, Cursor + 1) Update = True ELSE Alarm END IF CASE CLeft$ ' move to previous word IF Cursor > 2 THEN Temp = Cursor - 1 ' assume starting position DO ' start loop Temp = Temp - 1 ' adjust pointer IF ASC(MID$(Out$, Temp)) = 32 THEN ' space? Temp = Temp + 1 ' yes, so move cursor to EXIT DO ' next word & exit END IF LOOP UNTIL Temp = 1 ' just in case for no spaces Cursor = Temp 'adjust cursor ELSE Cursor = 1 END IF CASE CRight$ IF Cursor <= LEN(Out$) THEN 'only if not end of line Temp = INSTR(Cursor, Out$, SpaceBar$) ' find next space IF Temp = 0 THEN ' any spaces at all? Cursor = LEN(Out$) + 1 ' no, so just put at ' end of line ELSE Cursor = Temp + 1 ' yes, put after space END IF ELSE Cursor = LEN(Out$) + 1 END IF CASE Home$ Cursor = 1 CASE End$ Cursor = LEN(Out$) + 1 CASE Insert$ Insert = NOT Insert ' if user pressed the insert ' key, just toggle flag END SELECT END IF LOOP LOCATE , , 0, 0, 16 ' restore cursor to invisible big block PRINT ' go to next line GetInput$ = Out$ ' assign function to value END FUNCTION ' exit -!!!!!!!!!-8<-!!!!!!!!!!!!-8<-!!!!- that's it! Hope it helps! Victor P.S. Watch out for word-wrapped lines... ... My spelling? Oh, it's just line noise. --- Blue Wave/RA v2.10 [NR] * Origin: Hard Disc Cafe / Houston Texas / (713) 589-2690 / (1:106/30.0)
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