Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 308
» Latest member: Donaldvem
» Forum threads: 1,741
» Forum posts: 17,901

Full Statistics

Latest Threads
The QB64 IDE shell
Forum: Utilities
Last Post: JasonPag
09-16-2024, 05:37 PM
» Replies: 9
» Views: 764
Importance regarding Ches...
Forum: Utilities
Last Post: JasonPag
09-01-2024, 06:34 PM
» Replies: 0
» Views: 31
Chess and Analysis and En...
Forum: Utilities
Last Post: JasonPag
08-28-2024, 02:37 PM
» Replies: 0
» Views: 32
DAY 009:_PutImage
Forum: Keyword of the Day!
Last Post: grymmjack
09-02-2023, 02:57 PM
» Replies: 54
» Views: 2,034
Fall Banner Contest?
Forum: Site Suggestions
Last Post: grymmjack
08-31-2023, 11:50 PM
» Replies: 36
» Views: 1,262
ColorPicker - Function th...
Forum: Dav
Last Post: Dav
08-31-2023, 11:04 PM
» Replies: 3
» Views: 316
Goals(1) = New Tile()
Forum: Works in Progress
Last Post: RhoSigma
08-31-2023, 09:45 PM
» Replies: 3
» Views: 127
micro(A)v11
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:14 PM
» Replies: 90
» Views: 3,589
Updating The Single Most ...
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 09:13 PM
» Replies: 7
» Views: 254
QBJS Image Question
Forum: QBJS, BAM, and Other BASICs
Last Post: bplus
08-31-2023, 05:49 PM
» Replies: 5
» Views: 155

 
  Idea similar to _exit
Posted by: eoredson - 09-26-2022, 04:26 AM - Forum: Help Me! - Replies (12)

Hi,

I had an idea..

Since _exit traps Control-Break which is int x1B
then why not trap _print with PrintScreen which is int x05

Erik.

Print this item

  QB64 Phoenix Edition v3.2.1 Released!
Posted by: DSMan195276 - 09-26-2022, 04:11 AM - Forum: Announcements - Replies (14)

QB64 Phoenix Edition v3.2.1!
https://github.com/QB64-Phoenix-Edition/...tag/v3.2.1

Bug Fixes

  • #172, #182 - Fixed using audio commands in a
    $CONSOLE:ONLY
    program - @mkilgore
  • #178, #182 - Fixed using device commands in a
    $CONSOLE:ONLY
    program - @mkilgore
  • #175, #180 - Fix incorrect dithering applied to images loaded as a 256 color image - @a740g
    • This applies to images with less than or exactly 256 colors.
    • Images with more than 256 colors will still have dithering applied if they are loaded as a 256 color image.
  • #184 - Fixed setup_lnx.sh to always install
    make
    - @AtomicSlaughter


Full Changelog: https://github.com/QB64-Phoenix-Edition/...0...v3.2.1

Print this item

  Help with Help
Posted by: PhilOfPerth - 09-26-2022, 01:21 AM - Forum: General Discussion - Replies (19)

Anyone else having problems with the Help function on the IDE?
I'm currently unable to get the alphabetical list of keywords ("Sorry an error..."). I've tried a few variations on accessing it, but the "By Usage" page seems to be the only one I can use.   Huh

Print this item

  Pascal's Triangle and nth roots.
Posted by: Pete - 09-25-2022, 06:26 PM - Forum: General Discussion - Replies (2)

So to finish off my nth root calculator with long division, I needed to incorporate Pascal's Triangle in the binominal expansion algorithm.

Code: (Select All)
DIM AS DOUBLE i, j, r, z
INPUT "root: "; r
FOR i = 1 TO r + 1
    z = 1
    FOR j = 1 TO i
        PRINT z;
        z = z * (i - j) \ j
    NEXT
    PRINT
NEXT


WORKING MODEL FOR NON-DECIMAL ROOTS. NOTE: NO DECIMAL POINT YET in output. I will be adding that later...

Code: (Select All)
$CONSOLE:ONLY
LINE INPUT "Whole number: "; n$
LINE INPUT "Root: "; r$
r = VAL(r$)
nu&& = INSTR(n$, ".") - 1: IF nu&& < 0 THEN nu&& = LEN(n$)
h&& = (r - (r - nu&& MOD r)) + 1
t$ = MID$(n$, 1, h&& - 1): d$ = "0"
limit&& = 16
' Calculate Pascal's Triangle.
REDIM p$(r + 1)
FOR i1&& = 1 TO r + 1
    p&& = 1
    FOR j1&& = 1 TO i1&&
        p$(j1&&) = LTRIM$(STR$(p&&))
        p&& = p&& * (i1&& - j1&&) \ j1&&
    NEXT
NEXT

DO
    oldx$ = "0"
    lcnt&& = lcnt&& + 1
    FOR j = 1 TO 10
        x$ = "0"
        FOR i&& = 1 TO r
            REM PRINT "(10 ^"; (i&& - 1); "*"; p$(i&&); "* d ^"; i&& - 1; " * j ^"; (r + 1 - i&&); ") + ";
            REM x = x + 10 ^ (i&& - 1) * VAL(p$(i&&)) * d ^ (i&& - 1) * j ^ (r + 1 - i&&)
            tmp$ = "1"
            FOR k% = 1 TO i&& - 1
                tmp$ = sm_mult$(tmp$, "10")
            NEXT
            tmp$ = sm_mult$(tmp$, p$(i&&))
            tmp2$ = "1"
            FOR k% = 1 TO i&& - 1
                tmp2$ = sm_mult$(tmp2$, d$)
            NEXT
            IF d$ = "0" AND k% = 1 THEN tmp2$ = "1" ' zero^0 = 1
            tmp3$ = sm_mult$(tmp$, tmp2$)
            tmp$ = "1"
            FOR k% = 1 TO r + 1 - i&&
                tmp$ = sm_mult$(tmp$, LTRIM$(STR$(j)))
            NEXT
            tmp2$ = sm_mult$(tmp3$, tmp$)
            x$ = sm_add(x$, tmp2$)
        NEXT
        IF LEN(x$) > LEN(t$) OR LEN(x$) = LEN(t$) AND x$ > t$ THEN EXIT FOR
        oldx$ = x$
    NEXT
    d$ = d$ + LTRIM$(STR$(j - 1))
    IF LEFT$(d$, 1) = "0" THEN d$ = MID$(d$, 2) ' Remove leading zero.
    tmp1$ = sm_sub$(t$, oldx$)
    tmp2$ = MID$(n$, h&&, r) + STRING$(r - LEN(MID$(n$, h&&, r)), "0")
    t$ = tmp1$ + tmp2$
    IF LEFT$(t$, 1) = "0" THEN t$ = MID$(t$, 2) 'Remove leading zero.
    h&& = h&& + r
    IF t$ = STRING$(LEN(t$), "0") AND h&& >= LEN(n$) OR lcnt&& = limit&& THEN EXIT DO
LOOP
    sm_rt$ = d$
PRINT "Answer: "; sm_rt$: PRINT
RUN

SUB sm_greater_lesser (stringmatha$, stringmathb$, gl%)
    compa$ = stringmatha$: compb$ = stringmathb$ ' So original variables do not get changed.
    DO
        WHILE -1 ' Falx loop.
            IF gl% = 2 THEN EXIT WHILE ' For bypassing sign and decimal adjustments when only positive non-decimal numbers are being evaluated.
            ' Remove trailing zeros after a decimal point.
            IF INSTR(compa$, ".") THEN
                DO UNTIL RIGHT$(compa$, 1) <> "0" AND RIGHT$(compa$, 1) <> "." AND RIGHT$(compa$, 1) <> "-"
                    compa$ = MID$(compa$, 1, LEN(compa$) - 1)
                LOOP
            END IF
            IF INSTR(compb$, ".") THEN
                DO UNTIL RIGHT$(compb$, 1) <> "0" AND RIGHT$(compb$, 1) <> "." AND RIGHT$(compb$, 1) <> "-"
                    compb$ = MID$(compb$, 1, LEN(compb$) - 1)
                LOOP
            END IF

            IF MID$(compa$, 1, 2) = "-0" OR compa$ = "" OR compa$ = "-" THEN compa$ = "0"
            IF MID$(compb$, 1, 2) = "-0" OR compb$ = "" OR compb$ = "-" THEN compb$ = "0"

            ' A - and +
            j% = 0: k% = 0
            IF LEFT$(compa$, 1) = "-" THEN j% = -1
            IF LEFT$(compb$, 1) = "-" THEN k% = -1
            IF k% = 0 AND j% THEN gl% = -1: EXIT DO
            IF j% = 0 AND k% THEN gl% = 1: EXIT DO

            j&& = INSTR(compa$, ".")
            k&& = INSTR(compb$, ".")

            ' A starting decimal and non-decimal.
            IF j&& = 0 AND k&& = 1 THEN
                IF compa$ = "0" THEN gl% = -1 ELSE gl% = 1
                EXIT DO
            END IF
            IF k&& = 0 AND j&& = 1 THEN
                IF compb$ = "0" THEN gl% = 1 ELSE gl% = -1
                EXIT DO
            END IF

            ' remove decimals and align.
            j2&& = 0: k2&& = 0
            IF j&& <> 0 OR k&& <> 0 THEN
                IF j&& THEN compa$ = MID$(compa$, 1, INSTR(compa$, ".") - 1) + MID$(compa$, INSTR(compa$, ".") + 1): j2&& = LEN(compa$) - j&& + 1
                IF k&& THEN compb$ = MID$(compb$, 1, INSTR(compb$, ".") - 1) + MID$(compb$, INSTR(compb$, ".") + 1): k2&& = LEN(compb$) - k&& + 1
                compa$ = compa$ + STRING$(k2&& - j2&&, "0")
                compb$ = compb$ + STRING$(j2&& - k2&&, "0")
            END IF
            EXIT WHILE
        WEND

        ' Remove leading zeros if any.
        DO UNTIL LEFT$(compa$, 1) <> "0"
            compa$ = MID$(compa$, 2)
        LOOP
        IF compa$ = "" THEN compa$ = "0"
        DO UNTIL LEFT$(compb$, 1) <> "0"
            compb$ = MID$(compb$, 2)
        LOOP
        IF compb$ = "" THEN compb$ = "0"

        ' Both positive or both negative whole numbers.

        SELECT CASE LEN(compa$)
            CASE IS < LEN(compb$)
                gl% = -1
            CASE IS = LEN(compb$)
                IF compa$ = compb$ THEN
                    gl% = 0
                ELSEIF compa$ > compb$ THEN gl% = 1
                ELSEIF compa$ < compb$ THEN gl% = -1
                END IF
            CASE IS > LEN(compb$)
                gl% = 1
        END SELECT
        EXIT DO
    LOOP
END SUB

SUB sm_add_subtract_router (stringmatha$, operator$, stringmathb$, runningtotal$)
    DIM AS _INTEGER64 a, c, s
    a1$ = stringmatha$: b1$ = stringmathb$
    s = 18: i&& = 0: c = 0

    a$ = stringmatha$: b$ = stringmathb$: op$ = operator$

    IF op$ = "-" THEN
        IF LEFT$(b$, 1) = "-" THEN b$ = MID$(b$, 2) ELSE b$ = "-" + b$
    END IF

    IF INSTR(a$, ".") <> 0 OR INSTR(b$, ".") <> 0 THEN
        decimal% = -1
        IF INSTR(a$, ".") <> 0 THEN
            dec_a&& = LEN(MID$(a$, INSTR(a$, ".") + 1))
            a$ = MID$(a$, 1, INSTR(a$, ".") - 1) + MID$(a$, INSTR(a$, ".") + 1)
        END IF
        IF INSTR(b$, ".") <> 0 THEN
            dec_b&& = LEN(MID$(b$, INSTR(b$, ".") + 1))
            b$ = MID$(b$, 1, INSTR(b$, ".") - 1) + MID$(b$, INSTR(b$, ".") + 1)
        END IF
        ' Line up decimal places by inserting trailing zeros.
        IF dec_b&& > dec_a&& THEN
            j&& = dec_b&&
            a$ = a$ + STRING$(dec_b&& - dec_a&&, "0")
        ELSE
            j&& = dec_a&&
            b$ = b$ + STRING$(dec_a&& - dec_b&&, "0")
        END IF
    END IF

    IF LEFT$(a$, 1) = "-" OR LEFT$(b$, 1) = "-" THEN
        IF LEFT$(a$, 1) = "-" AND LEFT$(b$, 1) = "-" THEN
            sign$ = "": a$ = MID$(a$, 2): b$ = MID$(b$, 2)
        ELSE
            IF LEFT$(a$, 1) = "-" THEN a$ = MID$(a$, 2): sign_a$ = "-"
            IF LEFT$(b$, 1) = "-" THEN b$ = MID$(b$, 2): sign_b$ = "-"

            IF LEFT$(a1$, 1) = "-" THEN a1_x$ = MID$(a1$, 2) ELSE a1_x$ = a1$
            IF LEFT$(b1$, 1) = "-" THEN b1_x$ = MID$(b1$, 2) ELSE b1_x$ = b1$

            sm_greater_lesser a1_x$, b1_x$, gl%

            IF gl% < 0 THEN
                IF LEN(sign_b$) THEN sign$ = "-": SWAP a$, b$
            ELSE
                IF LEN(sign_a$) THEN sign$ = "-": SWAP sign_a$, sign_b$
            END IF
        END IF
    END IF

    z$ = ""
    ' Addition and subtraction of digits.
    DO
        i&& = i&& + s
        x1$ = MID$(a$, LEN(a$) - i&& + 1, s)
        x2$ = MID$(b$, LEN(b$) - i&& + 1, s)
        IF LEN(x2$) > LEN(x1$) THEN SWAP x1$, x2$
        a = VAL(sign_a$ + x1$) + VAL(sign_b$ + x2$) + c
        IF x1$ + x2$ = "" AND c = 0 THEN EXIT DO
        c = 0
        IF a > VAL(STRING$(s, "9")) THEN a = a - 10 ^ s: c = 1
        IF a < 0 THEN a = a + 10 ^ s: c = -1 ' a will never be less than 0.
        tmp$ = LTRIM$(STR$(a))
        z$ = STRING$(LEN(x1$) - LEN(tmp$), "0") + tmp$ + z$
    LOOP

    IF decimal% THEN
        z$ = MID$(z$, 1, LEN(z$) - j&&) + "." + MID$(z$, LEN(z$) - j&& + 1)
    END IF

    ' Remove any leading zeros.
    DO
        IF LEFT$(z$, 1) = "0" THEN z$ = MID$(z$, 2) ELSE EXIT DO
    LOOP

    IF z$ = "" OR z$ = "0" THEN z$ = "0" ELSE z$ = LEFT$(sign$, 1) + z$

    runningtotal$ = z$

    sign$ = "": sign_a$ = "": sign_b$ = "": i&& = 0: j&& = 0: decimal% = 0: c = 0
END SUB

FUNCTION sm_add$ (stringmatha$, stringmathb$)
    operator$ = "+"
    sm_add_subtract_router stringmatha$, operator$, stringmathb$, runningtotal$
    sm_add$ = runningtotal$
END FUNCTION

FUNCTION sm_sub$ (stringmatha$, stringmathb$)
    operator$ = "-"
    sm_add_subtract_router stringmatha$, operator$, stringmathb$, runningtotal$
    sm_sub$ = runningtotal$
END FUNCTION

FUNCTION sm_mult$ (stringmatha$, stringmathb$)
    DIM AS _INTEGER64 a, c, aa, cc, s, ss
    z$ = "": sign$ = "": mult&& = 0: h&& = 0: i&& = 0: j&& = 0: c = 0: decimal% = 0
    zz$ = "": ii&& = 0: jj&& = 0
    s = 8: ss = 18

    a$ = stringmatha$: b$ = stringmathb$

    IF INSTR(a$, "-") <> 0 OR INSTR(b$, "-") <> 0 THEN
        IF INSTR(a$, "-") <> 0 AND INSTR(b$, "-") <> 0 THEN
            a$ = MID$(a$, 2): b$ = MID$(b$, 2)
        ELSE
            IF INSTR(a$, "-") <> 0 THEN a$ = MID$(a$, 2) ELSE b$ = MID$(b$, 2)
            sign$ = "-"
        END IF
    END IF

    IF INSTR(a$, ".") <> 0 OR INSTR(b$, ".") <> 0 THEN
        decimal% = -1
        IF INSTR(a$, ".") <> 0 THEN
            dec_a&& = LEN(MID$(a$, INSTR(a$, ".") + 1))
            a$ = MID$(a$, 1, INSTR(a$, ".") - 1) + MID$(a$, INSTR(a$, ".") + 1)
        END IF
        IF INSTR(b$, ".") <> 0 THEN
            dec_b&& = LEN(MID$(b$, INSTR(b$, ".") + 1))
            b$ = MID$(b$, 1, INSTR(b$, ".") - 1) + MID$(b$, INSTR(b$, ".") + 1)
        END IF
    END IF

    IF LEN(a$) < LEN(b$) THEN SWAP a$, b$ ' Needed so x1$ is always the largest for leading zero replacements.
    ' Multiplication of digits.
    DO
        h&& = h&& + s: i&& = 0
        x2$ = MID$(b$, LEN(b$) - h&& + 1, s)
        DO
            i&& = i&& + s
            x1$ = MID$(a$, LEN(a$) - i&& + 1, s)
            a = VAL(x1$) * VAL(x2$) + c
            c = 0
            tmp$ = LTRIM$(STR$(a))
            IF LEN(tmp$) > s THEN c = VAL(MID$(tmp$, 1, LEN(tmp$) - s)): tmp$ = MID$(tmp$, LEN(tmp$) - s + 1)
            z$ = STRING$(LEN(x1$) - LEN(tmp$), "0") + tmp$ + z$
        LOOP UNTIL i&& >= LEN(a$) AND c = 0

        jj&& = jj&& + 1

        IF jj&& > 1 THEN
            ii&& = 0: cc = 0
            aa$ = holdaa$
            bb$ = z$ + STRING$((jj&& - 1) * s, "0")
            ' Addition only of digits.
            DO
                ii&& = ii&& + ss
                xx1$ = MID$(aa$, LEN(aa$) - ii&& + 1, ss)
                xx2$ = MID$(bb$, LEN(bb$) - ii&& + 1, ss)
                IF LEN(xx1$) < LEN(xx2$) THEN SWAP xx1$, xx2$
                aa = VAL(xx1$) + VAL(xx2$) + cc
                IF xx1$ + xx2$ = "" AND cc = 0 THEN EXIT DO ' Prevents leading zeros.
                cc = 0
                IF aa > VAL(STRING$(ss, "9")) THEN aa = aa - 10 ^ ss: cc = 1
                tmp$ = LTRIM$(STR$(aa))
                zz$ = STRING$(LEN(xx1$) - LEN(tmp$), "0") + tmp$ + zz$
            LOOP

            DO WHILE LEFT$(zz$, 1) = "0"
                IF LEFT$(zz$, 1) = "0" THEN zz$ = MID$(zz$, 2)
            LOOP
            IF zz$ = "" THEN zz$ = "0"

            holdaa$ = zz$
        ELSE
            holdaa$ = z$ + STRING$(jj&& - 1, "0")
        END IF

        z$ = "": zz$ = ""

    LOOP UNTIL h&& >= LEN(b$)

    z$ = holdaa$

    IF decimal% THEN
        DO UNTIL LEN(z$) >= dec_a&& + dec_b&&
            z$ = "0" + z$
        LOOP

        z$ = MID$(z$, 0, LEN(z$) - (dec_a&& + dec_b&& - 1)) + "." + MID$(z$, LEN(z$) - (dec_a&& + dec_b&&) + 1)

        DO UNTIL RIGHT$(z$, 1) <> "0" AND RIGHT$(z$, 1) <> "."
            z$ = MID$(z$, 1, LEN(z$) - 1)
        LOOP
    END IF

    IF STRING$(LEN(z$), "0") = z$ OR z$ = "" OR z$ = "0" THEN z$ = "0" ELSE z$ = sign$ + z$

    decimal% = 0: sign$ = ""

    runningtotal$ = z$
    sm_mult$ = z$
END FUNCTION

FUNCTION sm_div$ (stringmatha$, stringmathb$)
    hold_stringmatha$ = stringmatha$: hold_stringmathb$ = stringmathb$
    q$ = "": divisor$ = stringmathb$: dividend$ = stringmatha$
    DO ' Falx loop.
        'Strip off neg(s) and determine quotent sign.
        IF LEFT$(divisor$, 1) = "-" THEN divisor$ = MID$(divisor$, 2): q$ = "-"
        IF LEFT$(dividend$, 1) = "-" THEN dividend$ = MID$(dividend$, 2): IF q$ = "-" THEN q$ = "" ELSE q$ = "-"

        ' Quick results for divisor 1 or 0.
        IF dividend$ = "0" THEN q$ = "0": EXIT DO
        IF divisor$ = "1" THEN q$ = dividend$: EXIT DO
        IF divisor$ = "0" THEN q$ = "Division by zero not possible.": EXIT DO

        ' Determine decimal direction. -1 to left, +1 to right.
        gl% = 0: sm_greater_lesser divisor$, dividend$, gl%
        IF betatest% AND gl% = 1 THEN PRINT divisor$; " > "; dividend$; " Move decimal to the left"
        IF betatest% AND gl% = 0 THEN PRINT divisor$; " = "; dividend$
        IF betatest% AND gl% = -1 THEN PRINT divisor$; " < "; dividend$; " Move deciml to the right."
        IF gl% = 1 THEN ' Divisor is larger than dividend so decimal moves to the left.
            div_decimal% = -1 ' Move decimal point to the left.
        ELSEIF gl% = -1 THEN
            div_decimal% = 1 ' Move decimal point to the right.
        ELSE
            ' Divisor and dividend are the same number.
            q$ = q$ + "1": EXIT DO
        END IF
        divisor_ratio_dividend% = gl%

        ' Strip off decimal point(s) and determine places in these next 2 routines.
        dp&& = 0: dp2&& = 0: j2&& = 0
        temp&& = INSTR(divisor$, ".")
        IF temp&& THEN
            divisor$ = MID$(divisor$, 1, temp&& - 1) + MID$(divisor$, temp&& + 1)
            IF temp&& = 1 THEN
                DO UNTIL LEFT$(divisor$, 1) <> "0" ' Strip off any leading zeros on divisor only.
                    divisor$ = MID$(divisor$, 2)
                    dp&& = dp&& + 1
                LOOP
                dp&& = dp&& + 1
            ELSE
                dp&& = -(temp&& - 2)
            END IF
        ELSE
            dp&& = -(LEN(divisor$) - 1)
        END IF
        temp&& = INSTR(dividend$, ".")
        IF temp&& THEN
            dividend$ = MID$(dividend$, 1, temp&& - 1) + MID$(dividend$, temp&& + 1)
            IF temp&& = 1 THEN
                DO UNTIL LEFT$(dividend$, 1) <> "0" ' Strip off any leading zeros on divisor only.
                    dividend$ = MID$(dividend$, 2)
                    dp2&& = dp2&& + 1
                LOOP
                dp2&& = dp2&& + 1
            ELSE
                dp2&& = -(temp&& - 2)
            END IF
        ELSE
            dp2&& = -(LEN(dividend$) - 1)
        END IF
        IF betatest% THEN COLOR 11: PRINT "Divisor decimal moves "; LTRIM$(STR$(dp&&)); ". Dividend decimal moves"; LTRIM$(STR$(dp2&&)); ". Quotent decimal ABS("; LTRIM$(STR$(dp&&)); " - "; LTRIM$(STR$(dp2&&)); ") =";: COLOR 14: PRINT ABS(dp&& - dp2&&);: COLOR 11: PRINT "+ any adjustment.": COLOR 7
        dp&& = ABS(dp&& - dp2&&)

        IF betatest% THEN PRINT "Divisor 1st# = "; MID$(divisor$, 1, 1); "  Remainder 1st# = "; MID$(dividend$, 1, 1)

        ' Adjust decimal place for instances when divisor is larger than remainder the length of the divisor.
        j% = 0
        IF MID$(divisor$, 1, 1) > MID$(dividend$, 1, 1) THEN
            j% = 1
            IF betatest% THEN PRINT "Larger divisor, so move quotent decimal one place back to: ";: COLOR 14: PRINT LTRIM$(STR$(dp&&)): COLOR 7
        ELSEIF MID$(divisor$, 1, 1) = MID$(dividend$, 1, 1) THEN
            IF LEN(divisor$) = LEN(dividend$) THEN
                IF divisor$ > dividend$ THEN j% = 1
            ELSE
                IF LEN(divisor$) > LEN(dividend$) THEN
                    temp$ = dividend$ + STRING$(LEN(divisor$) - LEN(dividend$), "0")
                ELSE
                    temp$ = MID$(dividend$, 1, LEN(divisor$))
                END IF
                IF divisor$ > temp$ THEN j% = 1
            END IF
            IF betatest% THEN
                IF j% THEN PRINT "Larger divisor than dividend at LEN(divisor$), so move quotent decimal one place back to: ";: COLOR 14: PRINT LTRIM$(STR$(dp&&)): COLOR 7
                IF j% = 0 THEN PRINT "Smaller divisor than dividend at LEN(divisor$), so no quotent decimal place adjustment needed. Quotent decimal place = ";: COLOR 14: PRINT LTRIM$(STR$(dp&&)): COLOR 7
            END IF
        ELSE
            j% = 0
            IF betatest% THEN PRINT "Smaller divisor, so no quotent decimal place adjustment needed. Quotent decimal place = ";: COLOR 14: PRINT LTRIM$(STR$(dp&&)): COLOR 7
        END IF
        IF j% THEN dp&& = dp&& - div_decimal%

        origdividend$ = dividend$
        ' Determine length of divisor and dividend to begin initial long divison step.
        gl% = 2: sm_greater_lesser divisor$, MID$(dividend$, 1, LEN(divisor$)) + STRING$(LEN(divisor$) - LEN(dividend$), "0"), gl%
        divisor_ratio_dividend% = gl%
        IF gl% = 1 AND MID$(dividend$, 1, 1) <> "0" THEN
            dividend$ = MID$(dividend$, 1, LEN(divisor$) + 1) + STRING$(LEN(divisor$) + 1 - LEN(dividend$), "0")
        ELSE
            dividend$ = MID$(dividend$, 1, LEN(divisor$)) + STRING$(LEN(divisor$) - LEN(dividend$), "0")
        END IF

        ' Long divison loop. Mult and subtraction of dividend and remainder.
        k&& = 0
        IF betatest% THEN PRINT "Begin long divison loop..."
        DO
            SELECT CASE MID$(divisor$, 1, 1)
                CASE IS < MID$(dividend$, 1, 1)
                    adj_rem_len% = 0
                CASE IS = MID$(dividend$, 1, 1)
                    gl% = 2: sm_greater_lesser divisor$, MID$(dividend$, 1, LEN(divisor$)), gl%
                    IF gl% = 1 THEN adj_rem_len% = 1 ELSE adj_rem_len% = 0
                CASE IS > MID$(dividend$, 1, 1)
                    adj_rem_len% = 1
            END SELECT
            IF j2&& = 0 THEN j2&& = LEN(divisor$) + adj_rem_len%
            DO
                IF LEN(divisor$) > LEN(dividend$) THEN
                    w3&& = 0: runningtotal$ = dividend$: stringmathb$ = "0"
                    IF betatest% THEN PRINT: COLOR 3: PRINT "Divisor is larger so "; dividend$; " \ "; divisor$; " =";: COLOR 5: PRINT w3&&: COLOR 7
                    EXIT DO
                END IF
                IF LEN(divisor$) = LEN(dividend$) THEN
                    gl% = 2: sm_greater_lesser divisor$, dividend$, gl%
                    IF gl% = 1 THEN
                        w3&& = 0: runningtotal$ = dividend$: stringmathb$ = "0"
                        IF betatest% THEN COLOR 9: PRINT "Length of divisor is the same as remainder but remainder is smaller so w3&& = ";: COLOR 5: PRINT "0": COLOR 7
                        EXIT DO
                    END IF
                END IF
                SELECT CASE LEN(dividend$)
                    CASE IS > 2
                        w3&& = VAL(MID$(dividend$, 1, 2 + adj_rem_len%)) \ VAL(MID$(divisor$, 1, 2))
                        IF betatest% THEN PRINT MID$(dividend$, 1, 2 + adj_rem_len%); " \ "; MID$(divisor$, 1, 2); " =";
                    CASE ELSE
                        w3&& = VAL(MID$(dividend$, 1, 1 + adj_rem_len%)) \ VAL(MID$(divisor$, 1, 1))
                        IF betatest% THEN PRINT MID$(dividend$, 1, 1 + adj_rem_len%); " \ "; MID$(divisor$, 1, 1); " =";
                END SELECT
                IF betatest% THEN COLOR 5: PRINT " " + LTRIM$(STR$(w3&&));: COLOR 7: PRINT ". Begin mult est. at or one above this number."
                IF w3&& < 9 THEN w3&& = w3&& + 1 ELSE IF w3&& = 10 THEN w3&& = 9
                DO
                    stringmatha$ = divisor$: stringmathb$ = LTRIM$(STR$(w3&&))
                    runningtotal$ = sm_mult$(divisor$, LTRIM$(STR$(w3&&)))
                    gl% = 2: sm_greater_lesser runningtotal$, dividend$, gl%
                    IF gl% <= 0 OR w3&& = 0 THEN EXIT DO
                    IF betatest% THEN COLOR 8: PRINT "Mult loop:"; w3&&; "* "; divisor$; " = "; runningtotal$: COLOR 7
                    w3&& = w3&& - 1
                LOOP
                stringmatha$ = dividend$: stringmathb$ = runningtotal$
                sm_add_subtract_router dividend$, "-", stringmathb$, runningtotal$
                EXIT DO
            LOOP
            IF betatest% THEN PRINT LTRIM$(STR$(w3&&)); " * "; divisor$; " = "; stringmathb$; " | "; stringmatha$; " - "; stringmathb$; " = "; runningtotal$; " Remainder and drop-down = ";
            j2&& = j2&& + 1
            drop$ = "0": MID$(drop$, 1, 1) = MID$(origdividend$, j2&&, 1)
            IF runningtotal$ <> "0" THEN remainder$ = runningtotal$ ELSE remainder$ = ""
            dividend$ = remainder$ + drop$
            w3$ = LTRIM$(STR$(w3&&))
            temp$ = ""
            IF div_decimal% = -1 THEN
                IF dp&& AND k&& = 0 THEN
                    q$ = q$ + "." + STRING$(dp&& - 1, "0")
                    IF w3&& = 0 THEN w3$ = ""
                END IF
            END IF
            IF div_decimal% >= 0 THEN
                IF dp&& = k&& THEN
                    temp$ = "."
                END IF
            END IF
            q$ = q$ + w3$ + temp$
            IF betatest% AND remainder$ = "" THEN betatemp$ = CHR$(34) + CHR$(34) ELSE IF betatest% THEN betatemp$ = remainder$
            IF betatest% AND MID$(origdividend$, j2&&, 1) = "" THEN betatemp2$ = CHR$(34) + CHR$(34) ELSE IF betatest% THEN betatemp2$ = MID$(origdividend$, j2&&, 1)
            IF betatest% THEN PRINT dividend$; " ("; betatemp$; " +  "; drop$; ") at:"; j2&&; "of "; origdividend$; "  Loop"; k&& + 1; "Quotent = ";: COLOR 14, 4: PRINT q$;: COLOR 7, 0: PRINT: SLEEP
            ' Check to terminate
            IF div_decimal% = -1 THEN
                ' Decimal to left.
                IF remainder$ = "" AND MID$(origdividend$, j2&&, 1) = "" OR LEN(q$) >= limit&& THEN EXIT DO
            ELSE
                ' Decimal to right.
                IF remainder$ = "" AND MID$(origdividend$, j2&&, 1) = "" AND k&& >= dp&& OR LEN(q$) >= limit&& THEN EXIT DO
            END IF

            IF INKEY$ = " " THEN EXIT DO
            k&& = k&& + 1
        LOOP
        EXIT DO
    LOOP
    IF RIGHT$(q$, 1) = "." AND divisor$ <> "0" THEN runningtotal$ = MID$(q$, 1, LEN(q$) - 1) ELSE runningtotal$ = q$
    sm_div$ = runningtotal$
    stringmatha$ = hold_stringmatha$: stringmathb$ = hold_stringmathb$
END FUNCTION

Pete

Print this item

  Cannot convert expression type to symbol
Posted by: eoredson - 09-25-2022, 06:10 AM - Forum: Help Me! - Replies (4)

I have this sample code:

  Common Shared Test() As String * 260

which in the status area displays

  Cannot convert expression type to symbol

and I had to drill down to the function declaration using process of elimination to find.

Problem: the error does not state the line number it is in!

could this be fixed in a future mod of Qb64??

Thanks, Erik.

Print this item

  Re-inventing Debug
Posted by: PhilOfPerth - 09-24-2022, 11:56 PM - Forum: General Discussion - Replies (17)

Somewhere in the system, there’s a Debug that used to be available for finding and fixing coding errors, but it seems to be no
 longer usable or available.
I would like to see one re-produced that could be used by pleb- coders (like me) easily and effectively, to help find some of 
those elusive bugs we all encounter. I’m not capable of this kind of project, but here are the “bare bones” for an algorithm that 
I believe would be close to what we need:

1.     The declarant that starts the debug feature, _Debug  which is placed before executable code.
2.     Coders place a breakpoint, maybe * or BP, at any points they wish to see the state of their variables.
3.     When run, when the program reaches a BP, it pauses execution, and switches to another screen that displays (only) the 
variables that have changed since the last BP, with their new state.
4.     Pressing a key clears the new screen, returns the original screen and resumes the programme.
5.     A closing key is needed for when coding is complete, that removes all BPs and the Debug declarant.
 
Whatever is produced, it needs to be simple to use, flexible, and easily accesssed.

This may seem like re-inventing the wheel, but some of our wheels are a bit flat-bottomed or even triangular at the moment!
Rolleyes  Any takers?

Print this item

  html stripper
Posted by: random1 - 09-23-2022, 09:02 PM - Forum: General Discussion - Replies (4)

Hi all

Awhile back I posted about a html stripper, old site. If I remember correctly there was 
a file located in a folder that came with qb64 but can't remember the name or how to
use it.  Anyway, maybe someone can chime in and give me the lowdown.

R1

Print this item

  Tvaders
Posted by: James D Jarvis - 09-23-2022, 07:57 PM - Forum: Works in Progress - Replies (15)

A text-mode space invaders-style game.
It's still got a few rough edges and there's a planned game feature not yet coded (shields) but there's enough of a game to share here as a work in progress.

move left with "a" or "<"  
move right with "d" or ">"
to fire press the spacebar

It plays to level 16 currently.

Code: (Select All)
'Tvaders  1-d01
'by James D. Jarvis   ,   you are of course free to modify and share this code as you like
'
'a text-mode qb64 retro-shooter
'
'$dynamic
Screen _NewImage(100, 35, 0)
_Title "Tvaders 1"
Type spritetype
    s As String
    w As Integer 'i wanted to make this a byte but i want to be a tiny bit backwards compatible for folks with different versions
    sx As Integer
    sy As Integer
    hdg As Integer
End Type
Dim Shared a(16) As spritetype
Dim Shared ps As spritetype
Dim Shared ss(10) As spritetype
Dim Shared b(100) As spritetype
Dim Shared aspace(100, 35)
Dim Shared a$, gflag$
Dim Shared shotmax, shotspeed, shottimer, aliencount, aliendelay, alientimer, alive, level, score
Dim Shared boltmax, bolttimer, boltspeed, alienfire, shields
_ControlChr Off
Randomize Timer
Read a$
Read ship$
Read bolt$
Read shot$
ps.s = ship$
ps.w = 8
ps.sx = 32
ps.sy = 31
a(1).s = a$
a(1).w = 8
a(1).sx = 1
a(1).sy = 3
a(1).hdg = 1
For n = 1 To 100
    b(n).s = bolt$
    b(n).w = 1
    b(n).sx = 0
    b(n).sy = 0
Next n
For n = 1 To 10
    ss(n).s = shot$
    ss(n).w = 2
    ss(n).sx = 0
    ss(n).sy = 0
Next n
gflag$ = "GAMEON"
shotmax = 3
shotspeed = 10
shottimer = 0
aliencount = 1
aliendelay = 20
alientimer = 0
alive = aliencounter
level = 1
boltmax = 100
bolttimer = 0
boltspeed = 9


startlevel level
Do
    _Limit 60
    handleshots
    handlealiens
    handlezaps

    Cls
    Locate 1, 1
    Print "LEVEL : "; level
    Locate 1, 40
    Print "Shields : "; shields
    Locate 1, 70
    Print "SCORE : "; score
    Locate 2, 1
    Print "ALive "; alive
    If gflag$ = "BOOM" Then doboom
    For bc = 1 To 100
        If b(bc).sx > 0 Then splat b(bc).s, b(bc).w, b(bc).sx, b(bc).sy
    Next bc

    For ac = 1 To aliencount
        If a(ac).sx > 0 Then
            splat a(ac).s, a(ac).w, a(ac).sx, a(ac).sy

        End If
    Next ac

    splat ps.s, ps.w, ps.sx, ps.sy
    For s = 1 To shotmax
        If ss(s).sx <> 0 Then splat ss(s).s, ss(s).w, ss(s).sx, ss(s).sy
    Next s

    kk$ = InKey$
    If LCase$(kk$) = "a" Or kk$ = "," Or kk$ = "<" Then ps.sx = ps.sx - 1
    If LCase$(kk$) = "d" Or kk$ = "." Or kk$ = ">" Then ps.sx = ps.sx + 1
    If kk$ = " " Then fire ps.sx + 3
    If ps.sx < 1 Then ps.sx = 1
    If ps.sx > 92 Then ps.sx = 92
    If alive < 1 Then nextlevel level
    _Display
Loop Until kk$ = Chr$(27) Or gflag$ = "GAMEOVER"


System

'sprites were orignally drawn in ascii tilemaker and stripped out of the data file without the color data for use here
Data "ÛÛÛÛÛÛÛÛ Û0  0Û ÛÛÛÛÛÛÛÛ ^ ^^ ^ "
Data "   ²²      ÎΠ    ²²²²  ²²^²²^²²"
Data "/\/"
Data "##^^"


Sub fire (fx)
    shotfound = 0
    noshots = 0
    Do
        noshots = noshots + 1
        If ss(noshots).sx = 0 Then shotfound = noshots
    Loop Until shotfound > 0 Or noshots = shotmax
    If shotfound > 0 Then
        ss(shotfound).sx = fx
        ss(shotfound).sy = ps.sy - 2
    End If
End Sub

Sub zap (zx, zy)
    zapfound = 0
    zapcount = 0
    Do
        zapcount = zapcount + 1
        If b(zapcount).sx = 0 Then zapfound = zapcount
    Loop Until zapfound > 1 Or zapcount = boltmax
    If zapcount > 0 Then
        b(zapcount).sx = zx + 4
        b(zapcount).sy = zy + 3
    End If

End Sub
Sub handlezaps
    bolttimer = bolttimer + 1
    If bolttimer = boltspeed Then
        bolttimer = 0
        For n = 1 To 100
            If b(n).sx > 0 Then
                b(n).sy = b(n).sy + 1
                If b(n).sy = 33 Then
                    b(n).sx = 0
                    b(n).sy = 0
                End If
                If b(n).sy = 31 Then
                    For xx = ps.sx To ps.sx + 7
                        If b(n).sx = xx Then playerhit$ = "BOOM"
                        If playerhit$ = "BOOM" Then
                            For rr = 1 To 20
                                _Limit 150
                                For d = 1 To 300
                                    _PrintString (2 + Int(Rnd * 98), 5 + Int(Rnd * 30)), "*"
                                Next d
                                _PrintString (b(n).sx + Int(Rnd * 3), b(n).sy + Int(Rnd * 3)), "BOOM!"
                                gflag$ = "BOOM"
                                _Display

                            Next rr
                        End If
                    Next xx
                End If
            End If
        Next n
    End If
End Sub


Sub handleshots
    shottimer = shottimer + 1
    If shottimer = shotspeed Then
        hittag$ = "miss"
        For s = 1 To shotmax
            For aa = 1 To aliencount
                If a(aa).sx > 0 Then
                    sl = Len(a(aa).s)
                    sh = sl / a(aa).w
                    For y = 1 To sh
                        For x = 1 To a(aa).w
                            If a(aa).sx + x - 1 = ss(s).sx And a(aa).sy + y - 1 = ss(s).sy And hittag$ = "miss" Then hittag$ = "hit"
                        Next x
                    Next
                End If

                If hittag$ = "hit" Then
                    ss(s).sx = 0
                    a(aa).sx = 0
                    alive = alive - 1
                    hittag$ = "miss"
                    score = score + 100
                    Beep
                End If
            Next aa


            ss(s).sy = ss(s).sy - 2
            If ss(s).sy < 1 Then
                ss(s).sx = 0
                ss(s).sy = 0
            End If
        Next s
        shottimer = 0
    End If
End Sub

Sub handlealiens
    alientimer = alientimer + 1
    If alientimer > 32000 Then alientimer = 1
    For n = 1 To aliencount
        If a(n).sx > 0 And (alientimer Mod aliendelay = 0) Then

            a(n).sx = a(n).sx + a(n).hdg
            If a(n).sx > 92 Then
                a(n).sx = 92
                a(n).sy = a(n).sy + 2
                a(n).hdg = a(n).hdg * -1
            End If
            If a(n).sx < 1 Then
                a(n).sx = 1
                a(n).sy = a(n).sy + 2
                a(n).hdg = a(n).hdg * -1
            End If
            If 1 + Int(Rnd * 100) <= alienfire Then zap a(n).sx, a(n).sy

            If a(n).sy = 31 Then

                For xx = ps.sx To ps.sx + 7
                    If a(n).sx = xx Then playerhit$ = "BOOM"
                    If playerhit$ = "BOOM" Then
                        For rr = 1 To 20
                            _Limit 150
                            For d = 1 To 300
                                _PrintString (2 + Int(Rnd * 98), 5 + Int(Rnd * 30)), "*"
                            Next d
                            _PrintString (a(n).sx + Int(Rnd * 3), a(n).sy + Int(Rnd * 3)), "BOOM!"
                            gflag$ = "BOOM"
                            _Display

                        Next rr
                    End If
                Next xx


            End If

        End If
    Next
End Sub




Sub splat (SA$, ww As Integer, sx As Integer, sy As Integer)
    sl = Len(SA$)
    sh = sl / ww
    For y = 1 To sh
        _PrintString (sx, sy - 1 + y), Mid$(SA$, (y - 1) * ww + 1, ww)
    Next
End Sub

Sub startlevel (level)
    For bb = 1 To 100
        b(bb).sx = 0
        b(bb).sy = 0
    Next bb


    Select Case level
        Case 1
            aliencount = 1
            alive = 1
            aliendelay = 20
            a(1).s = a$
            a(1).w = 8
            a(1).sx = 46
            a(1).sy = 3
            a(1).hdg = 1
            shields = 0
            score = 0
            alienfire = 0
        Case 2
            aliencount = 3
            alive = 3
            aliendelay = 20
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).sx = n * 12 + 30
                a(n).sy = 3
                a(n).hdg = 1
            Next n
            shields = 3
            alienfire = 2
        Case 3
            aliencount = 5
            alive = 5
            aliendelay = 19
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).sx = n * 11 + 20
                a(n).sy = 4
                a(n).hdg = 1
            Next n
            shields = shields + 2
            alienfire = 4
        Case 4
            aliencount = 6
            alive = 6
            aliendelay = 19
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).sx = n * 15
                a(n).sy = 5
                a(n).hdg = 1
            Next n
            shields = shields + 2
            alienfire = 6
        Case 5
            aliencount = 7
            alive = 7
            aliendelay = 18
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = 1
            Next n
            For n = 1 To 5
                a(n).sx = n * 15
                a(n).sy = 1
            Next n
            For n = 6 To 7
                a(n).sx = (n - 5) * 35
                a(n).sy = 5
            Next n

            shields = shields + 2
            alienfire = 6
        Case 6
            aliencount = 8
            alive = 8
            aliendelay = 18
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = 1
            Next n
            For n = 1 To 3
                a(n).sx = n * 25
                a(n).sy = 3
            Next n
            For n = 4 To aliencount
                a(n).sx = (n - 3) * 12
                a(n).sy = 7
            Next n

            shields = shields + 2
            alienfire = 8
        Case 7
            aliencount = 9
            alive = 9
            aliendelay = 17
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = 1
            Next n
            For n = 1 To 3
                a(n).sx = n * 12
                a(n).sy = 3
            Next n
            For n = 4 To 6
                a(n).sx = (n - 3) * 12 + 30
                a(n).sy = 7
                a(n).hdg = -1
            Next n
            For n = 7 To 9
                a(n).sx = (n - 6) * 12
                a(n).sy = 11
            Next n


            shields = shields + 2
            alienfire = 8
        Case 8
            aliencount = 10
            alive = 10
            aliendelay = 17
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = Int(Rnd * 2) - 1
                If a(n).hdg = 0 Then a(n).hdg = 1
                a(n).sx = 12 + Int(Rnd * 8) * 8
                a(n).sy = 1 + Int(Rnd * 3) * 4
            Next n

            shields = shields + 2
            alienfire = 9
        Case 9
            aliencount = 11
            alive = 11
            aliendelay = 16
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = -2
            Next n
            For n = 1 To 5
                a(n).sx = n * 12 + 12
                a(n).sy = 3

            Next n
            For n = 6 To aliencount
                a(n).sx = (n - 5) * 8
                a(n).sy = 7
            Next n
            shields = shields + 2
            alienfire = 9
        Case 10
            aliencount = 12
            alive = 12
            aliendelay = 16
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = Int(Rnd * 4) - 2
                If a(n).hdg = 0 Then a(n).hdg = 1
                a(n).sx = 12 + Int(Rnd * 8) * 8
                a(n).sy = 1 + Int(Rnd * 3) * 4
            Next n


            shields = shields + 1
            alienfire = 10
        Case 11
            aliencount = 13
            alive = 13
            aliendelay = 15
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = -2
            Next n

            For n = 1 To 7
                a(n).sx = n * 12
                a(n).sy = 1 + Int(Rnd * 3) * 4
            Next n

            For n = 8 To aliencount
                a(n).sx = (n - 7) * 12
                a(n).sy = 13
            Next n


            shields = shields + 1
            alienfire = 1
        Case 12
            aliencount = 14
            alive = 14
            aliendelay = 14


            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
            Next n

            For n = 1 To 7
                a(n).sx = n * 9
                a(n).sy = 1
                a(n).hdg = -2
            Next n

            For n = 8 To aliencount
                a(n).sx = (n - 7) * 9
                a(n).sy = 11
                a(n).hdg = 2
            Next n



            shields = shields + 1
            alienfire = 11
        Case 13
            aliencount = 15

            alive = 15
            aliendelay = 13
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
            Next n

            For n = 1 To 10
                a(n).sx = (n * 9) - 8
                a(n).sy = 2
                a(n).hdg = -2
            Next n

            For n = 11 To aliencount
                a(n).sx = (n - 10) * 9
                a(n).sy = 9
                a(n).hdg = 3
            Next n


            shields = shields + 1
            alienfire = 12
        Case 14
            aliencount = 16
            alive = 16
            aliendelay = 12
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
            Next n

            For n = 1 To 8
                a(n).sx = (n * 9) - 8
                a(n).sy = 2
                a(n).hdg = -3
            Next n

            For n = 9 To aliencount
                a(n).sx = (n - 8) * 9
                a(n).sy = 11
                a(n).hdg = 3
            Next n

            shields = shields + 1
            alienfire = 13
        Case 15
            aliencount = 16
            alive = 16
            aliendelay = 10
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
            Next n

            For n = 1 To 9
                a(n).sx = (n * 9) - 8
                a(n).sy = 4
                a(n).hdg = -3
            Next n

            For n = 10 To 14
                a(n).sx = (n - 9) * 9 + 4
                a(n).sy = 9
                a(n).hdg = 3
            Next n
            For n = 15 To aliencount
                a(n).sx = (n - 14) * 20 + 40
                a(n).sy = 13
                a(n).hdg = 4
            Next n



            shields = shields + 1
            alienfire = 14
        Case 16
            aliencount = 16
            alive = 16
            aliendelay = 8
            For n = 1 To aliencount
                a(n).s = a$
                a(n).w = 8
                a(n).hdg = Int(Rnd * 8) - 4
                If a(n).hdg = 0 Then a(n).hdg = 4
            Next n

            For x = 0 To 3
                For y = 1 To 4
                    a(x * 4 + y).sx = x * 20
                    a(x * 4 + y).sy = y * 5
                Next y
            Next x



            shields = shields + 1
            alienfire = 15

    End Select
End Sub

Sub nextlevel (level)
    If level < 17 Then
        score = score + level * 1000
        Locate 10, 10
        Cls
        _KeyClear
        Print "*********************************************************"
        Print "*                                                       *"
        Print "*                 COMPLETED LEVEL                       *"
        Print "*                                                       *"
        Print "*                 PRESS ANY KEY                         *"
        Print "*                                                       *"
        Print "*               TO START NEXT LEVEL                     *"
        Print "*                                                       *"
        Print "*                                                       *"
        Print "*********************************************************"
        _Display
        any$ = Input$(1)
        level = level + 1
        If level < 17 Then startlevel level
        If level = 17 Then gameflag$ = "GAMEOVER"

    End If
    If level = 17 Or gameflag$ = "GAMEOVER" Then
        Cls
        Locate 10, 10
        _KeyClear
        Print "*********************************************************"
        Print "*                                                       *"
        Print "                    CONGRATULATIONS !                    "
        Print "*                                                       *"
        Print "              You Have Defeated the ALIENs!              "
        Print "*                                                       *"
        Print
        Print "           FINAL SCORE : "; score
        Print
        Print "*                 PRESS Y to Play again                 *"
        Print "                                                         "
        Print "*                                                       *"
        Print "*********************************************************"
        _Display
        any$ = Input$(1)
        If any$ = "y" Or any$ = "Y" Then
            gfla$ = "GAMEON"
            startlevel 1

        Else
            Cls

            gflag$ = "GAMEOVER"
        End If

    End If

End Sub
Sub doboom


    _KeyClear
    Locate 10, 10: Print "*********************************************************"
    Locate 11, 10: Print "* ÛÛÛÛÛÛÛÛ                                              *"
    Locate 12, 10: Print "   Û0  0Û          B O O M !                             "
    Locate 13, 10: Print "* ÛÛÛÛÛÛÛÛ                                              *"
    Locate 14, 10: Print "   ^ ^^ ^    You Were Defeated by the ALIENs!              "
    Locate 15, 10: Print "*                                                       *"
    Locate 16, 10: Print
    Locate 17, 10: Print "           FINAL SCORE : "; score
    Locate 18, 10: Print
    Locate 19, 10: Print "*                 PRESS Y to Play again       ÛÛÛÛÛÛÛÛ  *"
    Locate 20, 10: Print "       ÛÛÛÛÛÛÛÛ                                Û0  0Û    "
    Locate 21, 10: Print "*       Û0  0Û                                ÛÛÛÛÛÛÛÛ   *"
    Locate 22, 10: Print "*********************************************************"
    _Display
    any$ = Input$(1)
    If any$ = "y" Or any$ = "Y" Then
        gflag$ = "GAMEON"
        startlevel 1

    Else
        Cls

        gflag$ = "GAMEOVER"
    End If

End Sub

Print this item

  The TUI (Text User Interface) program
Posted by: BDS107 - 09-23-2022, 06:28 PM - Forum: Help Me! - Replies (6)

Somewhere on (I think) a forum I found the QB64 program TUI.
I really don't remember where I found it, but I still wanted to take a look at TUI.
Is there a "manual" for this Text User Interface somewhere?
Some lines of this code:

Code: (Select All)
tui "set highintensity=true"
statusbar = tui("add type=label;name=statusbar;caption= Ready.;x=1;y=25;w=80;h=1;fg=0;bg=3")

tui "set defaults;fg=0;bg=7;fghover=7;bghover=0;fghotkey=15"

filemenu = tui("add type=menubar;parent=0;name=filemenu;caption=&File")
tui "set defaults;parent=filemenu"
filemenunew = tui("add type=menuitem;name=filemenunew;caption=&New  Ctrl+N")
tui "add type=menuitem;caption=-"
filemenuexit = tui("add type=menuitem;name=filemenuexit;caption=E&xit")

Print this item

  my kid and the microbit
Posted by: James D Jarvis - 09-23-2022, 01:53 PM - Forum: General Discussion - No Replies

My youngest kid just got to fiddle with a microbit in school this week in STEM lab class and rushed home and wrote a space invaders game in smalltalk and javascript in an emulator to try in class. They are a nifty little gadget. The kid liked it so much we ordered one online last night (with a fancy power supply so it can work without being plugged into another device, well....a battery attachment.)  

I of course looked into it and sure enough some folks are programming for them in BASIC. Anyone here know anything else about microbits and BASIC?

Print this item