(10-28-2023, 06:34 AM)Chris Wrote: Thank You very much, it works, but a small correction is still needed. As I wrote earlier, after pressing only the Enter key, the H# variable cannot have the value zero (0). After entering the value zero (0) it is ok, after entering any number it is ok, but when I press only the Enter key it takes the value zero (0) and that is not good. I am asking for an amendment so that after pressing only the Enter key, the H# variable takes the value N#, i.e. H# = N#. The value of N# is calculated before the loop. If you fix it, it will be great. I removed unnecessary lines. Thank you.
H$ = "": B$ = ""
WHILE LEN(H$) < 7
B$ = ""
WHILE B$ = ""
B$ = INKEY$
_LIMIT 30
WEND
IF B$ = Chr$(27) THEN END
IF B$ = "-" THEN
IF H$ = "" THEN H$ = "-" ELSE BEEP
ENDIF
IF INSTR("0123456789", B$) THEN H$ = H$ + B$
IF B$ = CHR$(13) THEN EXIT WHILE
_LIMIT 30
WEND
H# = VAL(H$): PRINT H#
Ahhh.. I was misunderstanding how you set up the rules to begin with. See if this isn't what you're looking for:
Code: (Select All)
Do
Print "Input the correct value, by the rules! =>";
Do
a$ = Input$(1)
Select Case a$
Case "0" To "7"
If Len(num$) < 7 Then
Print a$;: num$ = num$ + a$
Else
finished = -1 'the 7 digit sequence is to be approved automagically
End If
Case Chr$(8) 'backspace
If Len(num$) > 0 Then
L = Pos(0) - 1
num$ = Left$(num$, Len(num$) - 1)
Locate , L: Print " "; 'erase the character
Locate , L: 'move the cursor back a spot
End If
Case Chr$(13) 'enter
If Len(num$) Then finished = -1 'if less than 7 digits, enter confirms
Case Chr$(27) 'escape
System
End Select
Loop Until finished
Print
Print "Your number as entereed was: "; num$
finished = 0: num$ = "" 'reset the variables
Loop 'forever and ever and ever... or until you hit the big red X to close the program.
Note, I also added the ability to hit backspace to erase a character, in case you mess up on the entry.