Page 1 of 1

How do I limit user input

Posted: Thu Jun 15, 2017 4:16 am
by leostout
I searched around here before asking, but I've also googled this and am coming up empty handed. Perhaps it's in the way I am searching, I don't know, but anyhow...

So as you are probably aware, when coding in Qbasic (or any basic for that matter) if you don't have a way to stop user input after so many characters, then some clown down the road is going to continue typing nonsense into your input line, just to watch it scroll to the next line and so on, until your page disappears and the program crashes.

So, I am trying to figure out how to stop user input after they type, say 10 characters (for example). I know there's a way to do this. I believe it has something to do with the LEN statement, possibly RIGHT$, but I cannot seem to figure it out. If someone would be so kind as to give me the code, I would be forever grateful and offer sacrifices to whatever god you worship with one of my fatted calves. Thanks! :D

Re: How do I limit user input

Posted: Mon Jun 19, 2017 3:05 am
by Cobramil
This link application (Quick-Basic) below has an "ENTRADA" subprogram that receives input from the keyboard. Accepts only one line no longer than 79 characters.
The ENTRADA subprogram requires the CMND, MOUSE, CLICK subprograms.

https://1drv.ms/u/s!AiHVG0VYRSnqhR-V1N5x_D42GjGh
Quick-Basic should be called with the lib library (QBX/L).

Legend of variables:
DECLARE SUB ENTRADA (LNH%, CLN%, TMNH!, TIPO$, COR!, IMPT$, CRT$, AB!, CMD%, CJ$)
LNH% → Cursor line
CLN% → Cursor column
TMNH! → Input Size
TIPO$ → Input type (& = alphanumeric, ± = numeric (+ and -), + = numeric (+), D = date Six-digit date with no separator signs.)
COR! → Character and background color (x.y)
IMPT$ → Returns the content entered
CRT$ → Returns the last command key pressed
AB! → Base year to verify legitimacy of dates (Last 2 digits). If the date entered is greater than the base year, then the "ENTRADA" understands that the century is the previous one, but if the date entered is equal to or less than the base year, then the "ENTRADA" understands that the century is the current . This was done on the occasion of the millennium bug, because the year is referred to with only two digits.
CMD% → Number of the line of function keys that will be displayed at the bottom of the screen. These functions are declared in the CMND subroutine.
CJ$ → Rectangles for mouse click. This is the upper-left corner and the lower right-hand corner of rectangles, which must be declared by four pairs of two digits and one digit that corresponds to the return of the mouse if it is clicked in the rectangle and which at the same time corresponds to the return of each, preceded by the zero character, If they are pressed.
; <F1>
< <F2>
= <F3>
> <F4>
? <F5>
@ <F6>
A <F7>
B <F8>
C <F9>
D <F10>
à <F11>
å <F12>

Sorry for the bad English, because I used the translator google, since I do not speak this language.

Re: How do I limit user input

Posted: Tue Jun 20, 2017 5:08 am
by leostout
Excellent. Thank you very much. This worked great!