QB64 IDE bug and an SNL moment...
#10
Au contraire!

Press any key then type in something you want added to the list.
Code: (Select All)
FOR i = 1 TO 50
    REDIM _PRESERVE c$(i)
    c$(i) = LTRIM$(STR$(i))
NEXT
WIDTH 80, 25
idx = -1: GOSUB dsp

DO
    _LIMIT 60
    WHILE _MOUSEINPUT
        mw = mw + _MOUSEWHEEL
    WEND
    IF mw <> oldmw THEN
        adj = SGN(mw - oldmw): mw = 0
        IF idx > 0 AND adj < 0 OR idx <= UBOUND(c$) - (_HEIGHT - 1) AND adj > 0 THEN GOSUB dsp
    END IF
    oldmw = mw
    b$ = INKEY$
    IF LEN(b$) THEN
        LOCATE 1, 10: LINE INPUT "Add what to list? "; ans$
        IF LEN(ans$) THEN
            REDIM _PRESERVE c$(UBOUND(c$) + 1)
            c$(UBOUND(c$)) = ans$
            idx = -1: GOSUB dsp
        END IF
    END IF
LOOP

dsp:
CLS
IF idx < 0 THEN
    idx = UBOUND(c$) - (_HEIGHT - 2)
    IF idx <= 1 THEN idx = 0
ELSE
    idx = idx + adj
END IF
LOCATE 1, 1
i = idx: j = 0
DO
    i = i + 1
    j = j + 1: LOCATE j, 1
    PRINT c$(i)
LOOP UNTIL CSRLIN = _HEIGHT - 1 OR i = UBOUND(c$)
RETURN

So you can add without worry of counting. Also, for testing, you don't need to change a DIM statement plus the array statement. Another plus is this method allows you to use ubounds() instead of a terminal counter.

Pete
Reply


Messages In This Thread
QB64 IDE bug and an SNL moment... - by Pete - 11-12-2022, 03:09 AM
RE: QB64 IDE bug and an SNL moment... - by Pete - 11-12-2022, 03:22 AM
RE: QB64 IDE bug and an SNL moment... - by Pete - 11-12-2022, 03:32 AM
RE: QB64 IDE bug and an SNL moment... - by Pete - 11-12-2022, 05:54 AM
RE: QB64 IDE bug and an SNL moment... - by jcm - 11-16-2022, 05:10 PM



Users browsing this thread: 2 Guest(s)