Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Correcting the code
#5
(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#

This should do what you're asking for.
The only change made was in the 4th line from the bottom.

Code: (Select All)
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 H$ = STR$(N#): EXIT WHILE
    _LIMIT 30
WEND
H# = VAL(H$): PRINT H#
Reply


Messages In This Thread
Correcting the code - by Chris - 10-27-2023, 07:19 PM
RE: Correcting the code - by bplus - 10-27-2023, 08:28 PM
RE: Correcting the code - by SMcNeill - 10-27-2023, 09:31 PM
RE: Correcting the code - by Chris - 10-28-2023, 06:34 AM
RE: Correcting the code - by SMcNeill - 10-28-2023, 01:46 PM
RE: Correcting the code - by Stuart - 10-28-2023, 10:43 AM
RE: Correcting the code - by Chris - 10-28-2023, 11:34 AM
RE: Correcting the code - by Chris - 10-28-2023, 11:49 AM
RE: Correcting the code - by bplus - 10-28-2023, 12:55 PM
RE: Correcting the code - by Chris - 10-28-2023, 02:13 PM
RE: Correcting the code - by bplus - 10-28-2023, 02:46 PM
RE: Correcting the code - by SMcNeill - 10-28-2023, 06:18 PM
RE: Correcting the code - by Chris - 10-28-2023, 07:44 PM
RE: Correcting the code - by bplus - 10-28-2023, 07:47 PM
RE: Correcting the code - by SMcNeill - 10-28-2023, 09:48 PM
RE: Correcting the code - by bplus - 10-28-2023, 07:51 PM



Users browsing this thread: 2 Guest(s)