1.

Solve : Multi-Line Input Box In QuickBASIC?

Answer»

I need a way to allow the user to MOVE up, down, left, and right in a text box. I am using QuickBASIC. The QuickBASIC program is an example. This isn't critical but would really be nice. Thanks You don't give very much detail. I am guessing that by "text box" you mean a console window, since you are running "QuickBASIC". Do you mean Microsoft QBASIC or the fuller QuickBASIC programming environment?

It sounds like you would be wanting to monitor the up down, left, right arrow keys in a loop, testing for the value of INKEY$ and using that to trigger appropriate actions such as increment/decrement row and column variables (checking for boundary values)

The arrow keys return 2 bytes. The first is zero, CHR$(0), and the second is ... (decimal values)


72 Up ASC("H")
80 Down ASC("P")
75 Left ASC("K")
77 Right ASC("M")


example showing how to get keypress data

Code: [SELECT]DO
kbd$ = INKEY$ 'Get Key
IF kbd$ <> "" THEN
SELECT CASE kbd$ 'Select what button you hit
CASE CHR$(0) + "H"
REM *** Code to run if the user pressed UP ***
PRINT "Up"
CASE CHR$(0) + "P"
REM *** and so on ***
PRINT "Down"
CASE CHR$(0) + "K"
PRINT "Left"
CASE CHR$(0) + "M"
PRINT "Right"
CASE CHR$(13)
PRINT "You hit Enter"
CASE CHR$(27)
END
END SELECT
END IF
LOOP

I am running full QuickBASIC. (I can compile etc.) I want to let the user move the cursor all directions and type text.Quote from: Fleexy on May 15, 2010, 10:35:20 AM

I am running full QuickBASIC. (I can compile etc.) I want to let the user move the cursor all directions and type text.

Well, it should be obvious how to achieve this.
Quote from: Fleexy on May 15, 2010, 10:35:20 AM
I am running full QuickBASIC. (I can compile etc.) I want to let the user move the cursor all directions and type text.

Monitor keypresses in a loop, and if they are arrow keys, do those things that you need to do (update cursor position, check if you have reached the left, top, right, bottom edge, etc), and if they are not arrow keys, do whatever you need to do then (ALPHANUMERIC - print character at cursor position, update the text array where you might be storing input, move cursor position 1 to the right, check for reaching the edge) (esc or whatever - jump out of loop, save data, whatever)


Quote from: Salmon Trout on May 15, 2010, 01:37:24 PM
Monitor keypresses in a loop, and if they are arrow keys, do those things that you need to do (update cursor position, check if you have reached the left, top, right, bottom edge, etc), and if they are not arrow keys, do whatever you need to do then (alphanumeric - print character at cursor position, update the text array where you might be storing input, move cursor position 1 to the right, check for reaching the edge) (esc or whatever - jump out of loop, save data, whatever)

Thanks!


Discussion

No Comment Found