r/QBprograms • • Apr 25 '22

message to users Arrays can be a good way to make the most out of a name shared for differing values.

1 Upvotes

QBasic and QB64 have this thing called arrays, they are useful for FOR...NEXT statements, but after thinking about it, it's also useful for reducing character count in programming code.

here's one way we can illustrate:

LeonardCohen = 264
Suzanne = 100
Susan = 74
Thomas = 76
Sue = 45
Daniel = 45
Susanna = 89
Madonna = 62
Madge = 30
JudyCollins = 121
Somers = 289
Ciani = 6.4
Greenville = 264
SaultSteMarie = 17
Westmount = 138
GrangeHall = 101.75
Yankovic = 27
MrRogers = 143
Tully = 174
Susanville = 36
Marquette = 28
MP3 = 192
Ruby = 1994
VinceVega = 622
NarcoticsAnonymous = 12
BillGates = 95
WeirdAl = 27
Sault = 129
BillMurray = 264
Lewiston = 162
Nunica = 231
Gaylord = 75
Shoen = 2.29
DeWitt = 87
BobEvans = 7
Lassen = 395
GrandTraverse = 72
Adams = 74
Southfield = 696
PhilKatz = 10000000000
LosAngeles = 405
Memphis = 19
Williamston = 117
Fresno = 99
Mackinac = 75
Allendale = 231
Midland = 47
Ravenna = 8
Rudyard = 63
Ladder = 7
Jackason = 127

character count: 935

Well, now, let's see what will happen if we re-organize these as an array:

DIM a(99)
a(1) = 264
a(2) = 100
a(3) = 74
a(4) = 76
a(5) = 45
a(6) = 45
a(7) = 89
a(8) = 62
a(9) = 30
a(10) = 121
a(11) = 289
a(12) = 6.4
a(13) = 264
a(14) = 17
a(15) = 138
a(16) = 101.75
a(17) = 27
a(18) = 143
a(19) = 174
a(20) = 36
a(21) = 28
a(22) = 192
a(23) = 1994
a(24) = 622
a(25) = 12
a(26) = 95
a(27) = 27
a(28) = 129
a(29) = 264
a(30) = 162
a(31) = 231
a(32) = 75
a(33) = 2.29
a(34) = 87
a(35) = 7
a(36) = 395
a(37) = 72
a(38) = 74
a(39) = 696
a(40) = 10000000000
a(41) = 405
a(42) = 19
a(43) = 117
a(43) = 99
a(44) = 75
a(45) = 231
a(46) = 47
a(47) = 8
a(48) = 63
a(49) = 7
a(50) = 127

character count: 800

well, the array setup is 135 characters shorter than the one with random names in it.

I made this post because I'm just trying to give QB programmers some tips on reducing character count when applying variables to the program. I have this tendency to name variables after celebrities I'm a big fan of, or geographical locations I am fond of touring. But then there's also the idea of keeping them anonymous using arrays while at the same time reducing character count. After all, I could quote a tradition of a 12-step program:

"anonymity is the spiritual foundation of all our traditions, ever reminding us to place principles before personalities."

Well, there's one principle I applied here, strategies to reduce character count in some programming code.

Yup, I just came up with this narrative and thought I'd share it as some programming advice. Another reason why I am trying to brainstorm ways to reduce character count, is because I found out that comment posts on Reddit have a 40,000 character limit, so it's important to make sure our QB programs conform to that limit somehow, in a way it's kinda like data compression, whether it be MP3 as a reason to mention Suzanne Vega, or ZIP as a reason to mention Phil Katz, or H.264 as a reason to mention Leonard Cohen (even though he wasn't some father of a computer file format, but it's his ordinal birthday that interests me). But if you look at it another way, even celebrities can stay anonymous in QB programs if you try out this DIM variable(number of increments) trick using a single-character for a variable to make an array out of.

I've spent some time working on a video game adaptation of the movie Desperately Seeking Susan since I'm sorta a Madonna fan here who also likes to write QB programs, so I kept checking the character count of that program to make sure it complies with the 40k character limit that Reddit has for it's posts, and I started to think that maybe other programmers might need advice like this too.

so thank you for reading.


r/QBprograms • • Dec 12 '25

QuickBasic SLOPE GAUGE

Thumbnail reddit.com
0 Upvotes

r/QBprograms • • Apr 05 '22

QB64 A program where the window turns red when you copy new text onto the clipboard

0 Upvotes
_TITLE "Detecting clipboard changes." 'designed for QB64
PALETTE 4, 36
PALETTE 5, 63
PALETTE 6, 36
TIMER ON
ON TIMER(.8) GOSUB check
a = _NEWIMAGE(43, 5, 0)
SCREEN a, 1, 1
COLOR 15, 2
PALETTE 2, 10
CLS
PRINT
PRINT "     WAITING FOR CLIPBOARD TO CHANGE      " ' program is still a bit glitchy.
SCREEN , 3, 3
PALETTE 5, 63
COLOR 0, 5
CLS
PRINT " Where is Leonard Cohen when you need him? " ' included a little easter egg.
PRINT "         Click window to continue"
PALETTE 6, 36 ' 36 just so happens to be the route number for a road that goes to Susanville.
COLOR , 6 ' and, 36 is also the exit number off I-96 for Leonard Street in Grand Rapids, MI
'      and, as a fun Cohen-cidence, it is also the index color for the
FOR LC = 1 TO 43 ' red stripe of the California flag.
    LOCATE 5, LC ' Leonard Cohen's initials used as a variable.
    PRINT " "; ' red stripe appears at bottom.
NEXT ' below is a hidden reference to something involved in Leonard Cohen's past life.
Verdal$ = CHR$(83) + CHR$(85) + CHR$(90) + CHR$(65) + CHR$(78) + CHR$(78) + CHR$(69)
SCREEN , 2, 2
COLOR 15, 4
PALETTE 4, 36
CLS
PRINT
PRINT "      NEW CLIPBOARD  STRING DETECTED      "
PRINT "           CLICK TO ACKNOWLEDGE      "
a$ = _CLIPBOARD$
DO
    SCREEN , 1, 1
    b$ = a$
    WHILE a$ = b$
    WEND
    SCREEN , 2, 2
    IF INSTR(UCASE$(a$), Verdal$) THEN SCREEN , 3, 3 ' a fun easter egg.
    m = 0
    WHILE m = 0
        WHILE _MOUSEINPUT
            IF _MOUSEBUTTON(1) THEN m = 1
            IF _MOUSEBUTTON(2) THEN m = 1
            IF _MOUSEBUTTON(3) THEN m = 1
        WEND
        IF INKEY$ <> "" THEN m = 1
    WEND
LOOP
check:
a$ = _CLIPBOARD$
RETURN

r/QBprograms • • Dec 15 '24

QuickBasic COLOR LINE CLOCK

Thumbnail reddit.com
0 Upvotes

r/QBprograms • • Feb 03 '26

QB64 ASCII psychedelia with background fade effect

0 Upvotes
' works with QB64
'
DIM lt AS LONG
DEF SEG = &HB800
DO
    t1 = ABS((INT(TIMER * 1000) MOD 512) - 255)
    lt = _RGB32(t1, t1, t1)
    _PALETTECOLOR 0, lt
    COLOR INT(RND * 16)
    a = INT(RND * 80 * 25)
    POKE (a * 2) + 1, INT(RND * 15)
    POKE a * 2, INT(RND * 256)
LOOP

r/QBprograms • • Feb 01 '26

QB64 CHECK LIST PROGRAM

0 Upvotes
'
'           *********   CHECK LIST PROGRAM     ************
'
' made for QB64
'
' a program where one can make a list of items, and check them
' as a û symbol (green text), or as X (red text) on the screen.
'
' the CONSOLE is used for input while the other program window
' can be used to display what's being CHECKED!!!!!!
'
' a good program to use for presentations especially when you have
' a second monitor to use with the computer.
'
' text size is dependent on the window scaling and pixel sizes.
'
$RESIZE:STRETCH
$CONSOLE
_CONSOLE ON
_TITLE "Check list program"
PRINT
_DEST _CONSOLE
PRINT "Checklist program"
PRINT
PRINT "Enter item names in the console here."
PRINT
PRINT
PRINT "Choose the window dimensions"
PRINT "enter a number between 150 and 1500 for horizontal"
WHILE x < 150 OR x > 1500
    INPUT x
WEND
PRINT "enter a number between 100 and 1000 for vertical"
WHILE y < 100 OR y > 1000
    INPUT y
WEND
SCREEN _NEWIMAGE(x, y, 13)
_DEST _CONSOLE
PRINT
PRINT "when entering numbers...."
PRINT "10 for CHECK, 12 for NO CHECK"
PRINT "0 to clear screen"
PRINT "any other number will just change the text color"
PRINT
_DEST 0
PRINT
DO
    _DEST _CONSOLE
    INPUT "Enter text "; a$
    _DEST 0
    COLOR 15
    PRINT "  "; a$;
    _DEST _CONSOLE
    INPUT "Enter number "; c
    _DEST 0
    LOCATE CSRLIN, 1
    COLOR c
    PRINT "  "; a$;
    SELECT CASE c
        CASE 10
            PRINT " û"
        CASE 12
            PRINT " X"
        CASE 0
            CLS
            PRINT
            _DEST _CONSOLE
            CLS
        CASE ELSE
            PRINT
    END SELECT
LOOP

r/QBprograms • • Feb 21 '22

When I made a PLAY command rendition of Leonard Cohen's Suzanne song, this is when I discovered that PLAY command music note "n0" is SILENT on QuickBasic 4.5, so QB64 is recommended for this one.

Thumbnail self.leonardcohen
1 Upvotes

r/QBprograms • • Feb 26 '22

GW-BASIC A Hello World program which references the letters of the alphabet via colors and music!

1 Upvotes
10 WIDTH 40, 25 'written in QB64, but compatible with GW-BASIC.
20 PRINT
30 PRINT ' This here is a Hello World program with a few more features.
40 PRINT ' This one references the ordinal (nth) letters of the alphabet
50 PRINT "   ";
60 COLOR 8 'The colors are referential,
70 PRINT "H ";
80 PLAY "t150 n8" 'and so are the n# notes of the PLAY command!
90 COLOR 5
100 PRINT "E ";
110 PLAY "n5"
120 COLOR 12
130 PRINT "L ";
140 PLAY "n12"
150 PRINT "L ";
160 PLAY "n12"
170 COLOR 15
180 PRINT "O   ";
190 PLAY "t60 n15"
200 COLOR 23
210 PRINT "W ";
220 PLAY "t120 n23"
230 COLOR 15
240 PRINT "O ";
250 PLAY "n15"
260 COLOR 18
270 PRINT "R ";
280 PLAY "n18"
290 COLOR 12
300 PRINT "L ";
310 PLAY "n12"
320 COLOR 4
330 PRINT "D "
340 PLAY "t60 n4"
350 PRINT
360 PRINT
370 PRINT "press any key to quit"
380 WHILE INKEY$ = ""
490 WEND
500 COLOR 7
510 WIDTH 80, 25 'restore to normal DOS-style text mode

r/QBprograms • • Feb 25 '22

QB64 A Hello World program with randomly colored ASCII characters, debut post of r/QBart, a spinoff sub

Thumbnail self.qbart
1 Upvotes

r/QBprograms • • Mar 05 '22

QB64 A program that toggles color bits using the CAPS LOCK, NUM LOCK, and SCROLL LOCK keys

2 Upvotes

This is my first program to make use of the SCROLL LOCK key, actually the first to make use of any LOCK key, and it actually takes advantage of all LOCK keys.

SCREEN 0 ' this program runs on QB64 2.0.2 or higher
i = 0
COLOR 15
LOCATE 3, 34
PRINT "COLOR BOX BELOW" ' we're gonna see some colors here!
LOCATE 20, 5
PRINT "CAPS LOCK = "; ' CAPS LOCK is a very common LOCK key
COLOR 9
PRINT "BLUE BIT   ";
COLOR 15
PRINT "NUM LOCK = "; '   NUM LOCK is commonly used in programs!
COLOR 10
PRINT "GREEN BIT   ";
COLOR 15
PRINT "SCROLL LOCK = "; ' might as well make some use of the lesser used SCROLL LOCK key!
COLOR 12
PRINT "RED BIT"
b = 1
DO
    IF INKEY$ = " " THEN b = b + 1 ' too back there's no fourth LOCK series key to toggle this with.
    IF _NUMLOCK = 0 THEN c = c + 2 ' in most cases, NUM LOCK toggles the numeric keypad.
    IF _CAPSLOCK = 0 THEN c = c + 1 ' CAPS LOCK usually forces capitol letters without SHIFT pressed down.
    IF _SCROLLLOCK = 0 THEN c = c + 4 ' SCROLL LOCK is a legacy LOCK key that has less use than other LOCK keys
    IF b = 9 THEN b = 1 '              but this time SCROLL LOCK can be useful for color toggling
    IF b / 2 = INT(b / 2) THEN i = 8
    IF b / 2 <> INT(b / 2) THEN i = 0
    COLOR c + i
    LOCATE 6
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    PRINT "                     ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ"
    COLOR 15
    LOCATE 22
    PRINT "     PRESS SPACEBAR TO SWICH BETWEEN BRIGHT AND DARK      COLOR VALUE = " + LTRIM$(STR$(c + i)) + "  "
    c = 0 'refreshes color value math
LOOP

r/QBprograms • • May 23 '22

QB64 QB CODE CLIPBOARD STABLIZER (0.1 BETA VERSION), use this program to modify QB code to appear in CODE MODE in Reddit comments!

2 Upvotes
' ==================================================
'   QB CODE CLIPBOARD STABLIZER (0.1 BETA VERSION)
' ==================================================
'
' made for QB64
'
' in this program, we will indent each line of code
' in the QB program you have written, but first you
' gotta copy the code to the clipboard for this to
' take effect.
'
' This here is the BETA VERSION, it's stable,
' it's reliable, but a little bit more work could
' be done to keep the character length of the code
' in balance for CODE MODE comments, since Reddit
' has a 40,000 character limit for it's posts.
'
' This program itself will be the first example of
' QB code that is optimized for appearing as CODE
' on a text post on Reddit.
'
'
'
_TITLE "QB CODE CLIPBOARD STABLIZER (0.1 BETA VERSION)"
RESTORE codefooter ' just thought I'd include a hidden message in this.
FOR a = 1 TO 732
    READ c
    footer$ = footer$ + CHR$(c)
NEXT
COLOR 14
intro:
PRINT "                QB CODE CLIPBOARD STABLIZER (0.1 BETA VERSION)"
PRINT
PRINT " This here is a utility which will prepare QB64 code for sharing in"
PRINT " Reddit posts.  Actually, it's also useful for preparing comments for"
PRINT " CODE MODE in general.  The reason why this utility has been made is,"
PRINT " because you can imagine how much time it would take to add four spaces"
PRINT " to each line prior to sharing it in a Reddit post."
PRINT
PRINT " When using Reddit, making posts of QBasic or QB64 code will often have errors"
PRINT " with it's text formatting if you don't add four spaces prior to using other"
PRINT " ASCII/Unicode characters for the code you want to share, so this four-space"
PRINT " indentation technique is kinda geared toward users who use old.reddit.com."
PRINT " but users who use the new style Reddit will also need some tips for sharing"
PRINT " code like this too.    When using the new style Reddit,   it is advised"
PRINT " to enable the CODE BLOCK feature,    or use MARKDOWN MODE to insert code"
PRINT " that has four-space indents for each line, since use of the CODE BLOCK will"
PRINT " add four additional spaces on the indent which means that one can end up with"
PRINT " eight spaces when four is the minimum.  Again, MARKDOWN MODE is advised for"
PRINT " those using the New Reddit layout.  But it's also advised to use"
PRINT " old.reddit.com to make Reddit posts of QB64 code as well."
PRINT
PRINT "                          press any key to continue..."
WHILE INKEY$ = ""
WEND
CLS
PRINT
PRINT " ...continued"
PRINT
PRINT " Just as a fair warning, copying QB code to the FANCY PANTS mode"
PRINT " for making Reddit comments will disrupt the spacing of some code for some"
PRINT " programs, again, it is advised that you use either MARKDOWN MODE, a CODE BLOCK,"
PRINT " or use old.reddit.com to share pre-indented QB code."
PRINT
PRINT " Another thing to know, sometimes if you copy QB64 code, some sections don't"
PRINT " get indented automatically.  Typing DO at the top can automatically indent"
PRINT " code, but this program here has a more ideal approach for typing code since"
PRINT " some programs with SUBs, not to be confused with subreddits on Reddit, but"
PRINT " rather, some subroutines which QBasic and QB64 use for programs, will often"
PRINT " not indent automatically, and the similar feature such as FUNCTIONs won't"
PRINT " indent automatically with the DO command at the top either, so we have this"
PRINT " special utility to indent each line of code for sharing in MARKDOWN MODE of"
PRINT " the new Reddit layout, or for the standard text prompts of the old Reddit."
PRINT
PRINT " press any key to contune"
WHILE INKEY$ = ""
WEND
CLS
PRINT
PRINT "...continued"
PRINT
PRINT " But before we get started, you should copy the code of your QB64 program"
PRINT " to the clipboard before you proceed.  This program will add some indents"
PRINT " to the beginning of each line of code to make it's more suitable for sharing"
PRINT " on Reddit."
PRINT
PRINT " Do you need to read this all again?"
PRINT
PRINT " press SPACEBAR for NO, pess any other key for YES"
yesno = 0
WHILE yesno = 0
    SELECT CASE INKEY$
        CASE " "
            yesno = 1
        CASE ""
            LOCATE
        CASE ELSE
            GOTO intro
    END SELECT
WEND
PRINT
PRINT
PRINT
PRINT " thank you for your patience, and thank you for understanding the narraitve."
PRINT " for how to use the commenting feature on Reddit, and how this program works."
PRINT
PRINT "Now, let's fix up the code for sharing on Reddit."
PRINT
PRINT " press any key to proceed"
WHILE INKEY$ = ""
WEND
PRINT
PRINT
PRINT
DO
    IF LEN(_CLIPBOARD$) < 50 THEN
        PRINT "your clipboard string has less than 50 character on it."
        PRINT
        PRINT "are you sure that this is just a short program, or is there"
        PRINT "some other text in the clipboard?"
        PRINT
        PRINT "press the PASTE button on a text editor to check."
        PRINT
        PRINT "press any key to proceed when ready"
        WHILE INKEY$ = ""
        WEND
        PRINT
        PRINT
    END IF
    PRINT "Processing..."
    s = 1
    FOR a = 1 TO LEN(_CLIPBOARD$)
        IF s = 1 THEN
            clip$ = RTRIM$(clip$)
            IF MID$(_CLIPBOARD$, a, 4) <> " " THEN clip$ = clip$ + "    "
        END IF
        s = 0
        b$ = MID$(_CLIPBOARD$, a, 1)
        clip$ = clip$ + b$
        IF MID$(_CLIPBOARD$, a, 1) = CHR$(10) THEN s = 1
    NEXT
    clip$ = clip$ + CHR$(13) + CHR$(10) + CHR$(13) + CHR$(10) + footer$
    _CLIPBOARD$ = clip$
    SOUND 500, 2
    PRINT
    PRINT "All done, now check the PASTE button on your text editor."
    PRINT
    PRINT "Press any key to start another round"
    WHILE INKEY$ = ""
    WEND
    WHILE clip$ = _CLIPBOARD$
        PRINT
        PRINT "..."
        PRINT
        PRINT "your clipboard text is identical to the one that just got created."
        PRINT
        PRINT "please change the clipboard text to repeat process."
        PRINT
        PRINT "press any key when ready."
        WHILE INKEY$ = ""
        WEND
    WEND
    clip$ = ""
    PRINT
    PRINT "---------------------------------------------------"
    PRINT
LOOP
codefooter: ' here you see a hidden message encoded as ASCII values.
' this is an easter egg for the clipboard text.
DATA 32,32,32,32,39,32,42,42,42,42,42,42,42,42,42,42,42,42,42,42
DATA 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
DATA 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
DATA 13,32,32,32,32,39,32,84,104,97,110,107,32,121,111,117,32,102,111,114
DATA 32,117,115,105,110,103,32,116,104,105,115,32,112,114,111,103,114,97,109,46
DATA 13,32,32,32,32,39,13,32,32,32,32,39,32,84,104,105,115,32,99,111
DATA 100,101,32,104,97,115,32,98,101,101,110,32,112,114,111,99,101,115,115,101
DATA 100,32,98,121,32,97,32,81,66,54,52,32,112,114,111,103,114,97,109,32
DATA 119,114,105,116,116,101,110,13,32,32,32,32,39,32,98,121,32,82,101,100
DATA 100,105,116,32,117,115,101,114,32,47,117,47,83,117,112,114,101,109,111,90
DATA 97,110,110,101,13,32,32,32,32,39,32,109,111,100,101,114,97,116,111,114
DATA 32,97,110,100,32,102,111,117,110,100,101,114,32,111,102,32,116,104,101,32
DATA 47,114,47,81,66,112,114,111,103,114,97,109,115,32,115,117,98,114,101,100
DATA 100,105,116,46,13,32,32,32,32,39,32,45,45,45,45,45,45,45,45,45
DATA 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45
DATA 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45
DATA 45,45,45,45,45,13,32,32,32,32,39,32,87,101,32,104,111,112,101,32
DATA 116,104,97,116,32,116,104,105,115,32,112,114,111,103,114,97,109,32,103,105
DATA 118,101,115,32,121,111,117,32,97,32,98,101,116,116,101,114,32,101,120,112
DATA 101,114,105,101,110,99,101,13,32,32,32,32,39,32,119,105,116,104,32,112
DATA 111,115,116,105,110,103,32,97,110,100,32,99,111,109,109,101,116,105,110,103
DATA 32,111,110,32,82,101,100,100,105,116,32,13,32,32,32,32,39,45,45,45
DATA 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45
DATA 45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45
DATA 45,45,45,45,45,45,45,45,45,45,45,45,45,13,32,32,32,32,39,32
DATA 116,104,105,115,32,116,101,120,116,32,119,97,115,32,115,105,109,112,108,121
DATA 32,97,100,100,101,100,32,104,101,114,101,32,116,111,32,116,104,97,110,107
DATA 32,117,115,101,114,115,32,102,111,114,13,32,32,32,32,39,32,117,115,105
DATA 110,103,32,116,104,101,32,112,114,111,103,114,97,109,44,115,111,32,121,111
DATA 117,32,99,97,110,32,114,101,109,111,118,101,32,116,104,105,115,32,116,104
DATA 97,110,107,32,121,111,117,13,32,32,32,32,39,32,109,101,115,115,97,103
DATA 101,32,119,104,101,110,32,121,111,117,32,97,114,101,32,114,101,97,100,121
DATA 32,116,111,32,115,104,97,114,101,32,116,104,105,115,32,99,111,100,101,32
DATA 111,110,32,82,101,100,100,105,116,46,13,32,32,32,32,39,32,42,42,42
DATA 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
DATA 42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42,42
DATA 42,42,42,42,42,42,42,42,42,42,42,13


RETURN

r/QBprograms • • Aug 31 '25

GW-BASIC A little 80s PC beeper music in GW-BASIC

Thumbnail
youtube.com
4 Upvotes

r/QBprograms • • Oct 21 '23

a Suzanne Somers tribute in SCREEN 7, with some impressive dithering, and impressive ASCII management in the DATA fields.

Post image
5 Upvotes

r/QBprograms • • Feb 13 '26

QuickBasic 🟢🟢👨‍💻 THE SLIME MATRIX 👨‍💻🟢🟢

3 Upvotes
'
'                THE SLIME MATRIX
'
' a tech demo of slime dripping all over the screen.
'
' The name THE SLIME MATRIX was chosen when it was noticed
' that the slime dripping was very similar to the "code rain"
' that The Matrix is famous for, except it has varying shades
' of green, rather than varying ASCII/Unicode characters that
' are used with the famous Matrix "code rain".
'
' As far as the author is concerned, this slime tech demo is more
' suited for fans of nostalgic Nickelodeon media, than for fans of
' The Matrix movie series, as slime is one thing Nickelodeon fans
' can resonate with, but this tech demo can hopefully appeal to both
' entertainment media communities.
'
' Made for QBasic and QB64
'
' a special command below can be used in QB64
'
'
DEFINT A-Z
DIM avc AS LONG
RANDOMIZE TIMER
DIM slh(320) AS INTEGER
SCREEN 13
FOR c = 1 TO 255
    c1 = c - 1
    c4 = (c \ 4) ' complex math is used to make sure slime
    ri = ((c4 \ 9) * 2) + (c4 \ 8) ' isn't just pure green.
    bi = ((c4 \ 9) * 2) + (c4 \ 12)
    ro = (c1 MOD 4) * 6 + (c4 \ 12)
    PALETTE c1, (c4 * 256) + ro + ri + (bi * 65536)
NEXT
DO
    '
    ' ===========================================
    ' you can use this _LIMIT command in QB64
    '
    '   _LIMIT 500
    ' ============================================
    '
    ' above is a special command so QB64 can flow at
    ' a steady pace.
    '
    ' removing the apostrophe is the way to have the command take
    ' effect, although the underscore series commands are QB64
    ' exclusives that won't work in DOS QBasic, which is why an
    ' apostrophe was put there to show that it's meant for QB64,
    ' while DOS QBasic can run steady without it.
    '
    x = INT(RND * 320)
    di = INT(RND * 10)
    slh(x) = slh(x) + di
    yscan = slh(x)
    IF yscan > 200 THEN yscan = 200
    FOR y = yscan TO 0 STEP -1
        y2 = y - slh(x)
        IF y2 < 0 THEN PSET (x, y), INT(RND * 256)
    NEXT
    slh(x) = slh(x) + INT(RND * 6)
    'IF slh(x) > 200 THEN
    'LINE (x, 0)-(x, 200), 0     'leftover code from
    'slh(x) = 0                  'a previous idea
    'END IF                      'for running.
    '
    avc = 0
    FOR z = 0 TO 316 STEP 4
        avc = avc + slh(z) + slh(z + 1) + slh(z + 2) + slh(z + 3)
    NEXT
    LOCATE 10, 5
    COLOR 200
    av = avc \ 320
    ' PRINT av     ' the line was used for DEBUGGING purposes
    IF av > 150 THEN
        LINE (x, 0)-(x, 200), 0
        slh(x) = 0
    END IF
LOOP

r/QBprograms • • Feb 20 '22

message to users FLAIR REMINDER: remember that if you share BASIC programming code, that you FLAIR the post to indicate which variant of the QBASIC family, or other flairs for other post types.

1 Upvotes

GW-BASIC:

Use this flair if the program is compatible with GW-BASIC, sometimes GW-BASIC programs also run in QuickBasic and QBASIC, and even QB64.

NOTE: GW-BASIC was actually a precursor to the QBASIC family of BASIC interpreter programs that one can also write programs in. Many commands that QBASIC uses originated here, although a few commands from QuickBasic and newer may not be supported here, so be sure to test your programs before knowing what interpreters they are compatible with.

QuickBasic:

Use this flair if the program is compatible with QuickBasic. Because it has been observed that some programs written in the newer QBASIC program may sometimes have compatibility issues with QB45 and older.

QBASIC:

use this flair if the program is compatible with QBASIC. Some programs written in QBASIC will have compatibility issues with other BASIC interpreters in the QB family. Older programs such as QB45 will have compatibility issues with programs optimized for QBASIC, and even newer interpreters such as QB64 will also have compatibility issues some some QBASIC code too, even though QB64 has new commands in it.

QB64:

use this flair if any commands exclusive to QB64 are used in the BASIC code you wanna share.

Other QB:

use this flair if any other dialect of BASIC not listed here has partial compatibility with commands introduced in GW-BASIC or QBASIC

Pre-GW

These types of programs are designed to be compatible with older versions of BASIC that predate GW-BASIC and it's almost-identical program BASICA, use this flair if you know for sure that these programs also work on the QB family of interpreters.

Not QB:

use this flair if you're skeptical that any programs in a different dialect of BASIC code you share has any compatibility with the QB family, or if you know for sure that it's commands that are incompatible with any interpreter from the QB family made before, during or after the releases of GW-BASIC, QuickBasic and QBASIC.

URL to resource:

use this flair if you are using a URL to any webpage or video with help on programming in BASIC, or worthwhile showcases of usage of it, or something like documentaries about it, or some webpage or media that's on the lines of being related to this sub's topic.

message to users:

use this flair if you are making a text post for message purposes instead of directly sharing QB code.

miscellaneous:

use this flair if any post that is somewhat related to the BASIC programming language is shared.


r/QBprograms • • Apr 06 '22

GW-BASIC Channel identity jingle for PBS [56 SUBSCRIBER MILESTONE SPECIAL]

Thumbnail self.qbmusic
1 Upvotes

r/QBprograms • • Mar 22 '22

QB64 Hello World using only one line in SCREEN 0

2 Upvotes
_TITLE "HELLO WORLD" 'designed for QB64, as the rare one-line type program.
SCREEN _NEWIMAGE(41, 1, 0) 'one line is enough for HELLO WORLD.
_FONT 17
PALETTE 1, 16
PALETTE 2, 18 ' colors chosen for an old school vacuum fluorescent effect.
COLOR 2, 1
CLS
PRINT "          H E L L O   W O R L D"; ' kerning adjusted as a special effect!
WHILE INKEY$ = ""
WEND
END

r/QBprograms • • Feb 21 '22

QB64 QB PLAY COMMAND PAD, this here is a program for composing PLAY command music compositions on the fly.

1 Upvotes
$CONSOLE
_CONSOLE OFF '             programmed in QB64, so QB64 is recommended.
SCREEN _NEWIMAGE(90, 30, 0)
b = 0
t = 250
c = 1
_TITLE "QB PLAY COMMAND PAD"
COLOR 14
PRINT
PRINT "                                    QB PLAY COMMAND PAD ";
COLOR 12
PRINT "         version 0.1"
COLOR 14
PRINT
PRINT " offset note by 10 units up: RIGHT, D or +"
PRINT " offset note by 10 units down: LEFT, A, or -"
PRINT " offset note by 1 down: Q  ;  offset note by 1 up: E"
PRINT " increase tempo by 1 unit: UP or W"
PRINT " decrease tempo by 1 unit: DOWN or S"
PRINT
PRINT "note offset:"
PRINT "last note played:"
PRINT "tempo: "
PRINT
PRINT "press numeric digit to PLAY note (offset + digit = note)"
PRINT
PRINT "press Z to toggle (turn on or off) console and note sequence output"
COLOR 12
PRINT "TIP: console needs to be turned on for notes and other things to show up."
PRINT "however, you can also turn off the console to practice before adding more notes."
PRINT "The purpose of the console is to copy-and-paste note sequences for the PLAY command"
PRINT "you also have the option to edit the music notes you copy in another text editor"
COLOR 14
PRINT "press ENTER to add a break to the note sequence in the console"
PRINT
PRINT "press T to add tempo number to console ; press Y to enter number into tempo"
LOCATE 10, 14
COLOR 15
PRINT b; "   "
LOCATE 11, 18
PRINT nn; "  "
LOCATE 12, 8
PRINT t; " "
DO
    key$ = ""
    1
    WHILE key$ = ""
        key$ = INKEY$
    WEND
    SELECT CASE ASC(UCASE$(key$))
        CASE 13
            IF c / 2 = INT(c / 2) THEN
                _DEST _CONSOLE
                PRINT
                PRINT
                PRINT
                _DEST 0
            END IF
        CASE 43
            b = b + 10
        CASE 48 TO 57
            n = VAL(key$)
            nn = n + b
            IF nn > 84 THEN nn = 84
            PLAY "MB " + "T" + LTRIM$(STR$(t)) + " n" + STR$(nn)
            IF c / 2 = INT(c / 2) THEN
                _DEST _CONSOLE
                PRINT "n"; LTRIM$(STR$(nn)); " ";
                _DEST 0
            END IF
        CASE 45
            b = b - 10
        CASE 65
            b = b - 10
        CASE 66
        CASE 67
        CASE 68
            b = b + 10
        CASE 69
            b = b + 1
        CASE 81
            b = b - 1
        CASE 83
            t = t - 10
        CASE 84
            IF c / 2 = INT(c / 2) THEN
                _DEST _CONSOLE
                PRINT "T"; LTRIM$(STR$(t)); " ";
                _DEST 0
            END IF
        CASE 87
            t = t + 10
        CASE 89
            GOSUB tempoentry
            kk$ = ""
        CASE 90
            c = c + 1
        CASE 0
            IF key$ = CHR$(0) + "H" THEN t = t + 1
            IF key$ = CHR$(0) + "P" THEN t = t - 1
            IF key$ = CHR$(0) + "M" THEN b = b + 10
            IF key$ = CHR$(0) + "K" THEN b = b - 10
    END SELECT
    IF c = 10 THEN c = 0
    IF c / 2 = INT(c / 2) THEN _CONSOLE ON
    IF c / 2 <> INT(c / 2) THEN _CONSOLE OFF
    GOSUB valcheck
    LOCATE 10, 14
    COLOR 15
    PRINT b; "   "
    LOCATE 11, 18
    PRINT nn; "  "
    LOCATE 12, 8
    PRINT t; " "
LOOP

valcheck:
IF t <= 30 THEN t = 30
IF t > 255 THEN t = 255
IF b < 0 THEN b = 0
IF b > 80 THEN b = 80
IF nn > 84 THEN nn = 84
RETURN

tempoentry:
dg$ = ""
DO
    kk$ = ""
    LOCATE 12, 15
    COLOR 15
    PRINT "PRESS ENTER WHEN FINISHED"
    LOCATE 12, 8
    PRINT dg$; "_"; "   "
    WHILE kk$ = ""
        kk$ = INKEY$
    WEND
    SELECT CASE ASC(kk$)
        CASE 48 TO 57
            IF LEN(dg$) < 3 THEN dg$ = dg$ + kk$
        CASE 13
            LOCATE 12, 15
            PRINT "                                "
            t = VAL(dg$)
            IF t <= 30 THEN t = 30
            IF t > 255 THEN t = 255
            RETURN 'well, we have a play on words here!
    END SELECT
LOOP
kk$ = ""
RETURN

r/QBprograms • • Mar 17 '22

QBASIC a program to find the sign and absolute value of a number

1 Upvotes
PRINT "find the sign of a number." ' this time I thought I'd share a simple program.
PRINT
PRINT "enter '0'; 5 times in a row to quit"

DO
    INPUT a
    IF a = 0 THEN aa = aa + 1
    IF aa = 5 THEN END
    IF a <> 0 THEN aa = 0
    IF SGN(a) = -1 THEN sg$ = "NEGATIVE"
    IF SGN(a) = 1 THEN sg$ = "POSITIVE"
    IF SGN(a) = 0 THEN sg$ = "ZERO"
    PRINT "SIGN: "; SGN(a); " "; sg$
    PRINT "ABSOLUTE VALUE: "; ABS(a)
LOOP

r/QBprograms • • Apr 20 '22

message to users QB64.ORG RIP - Long Live QB64 Phoenix Edition ? - Day 120

Thumbnail
youtube.com
1 Upvotes

r/QBprograms • • Apr 09 '22

QBASIC A program that confirms valid SCREEN modes for QBasic with the ON ERROR GOTO statement.

2 Upvotes
DIM b(14) ' screen modes to test      program designed for QuickBasic, QBasic, and QB64.
ON ERROR GOTO testmode ' this way illegal function call errors don't interrupt the program.
FOR a = 0 TO 13 ' cycle through all screen modes between 0 and 13
    b(a) = 1 ' mode number checks out by default
    SCREEN a ' mode number is tested for availability.
    IF b(a) = 1 THEN a$ = a$ + STR$(a) ' mode numbers added to a text string.
NEXT
SCREEN 0 ' screen mode goes to text mode for text output.
WIDTH 80, 25 ' restore to default 80x25 text mode
PRINT
PRINT " Your available legacy SCREEN modes from QBasic to choose from:"
PRINT
PRINT " " + a$ ' basically the Hello World of programs that weed out unavailable SCREEN modes.
PRINT
PRINT '
PRINT
PRINT " press any key to quit"
WHILE INKEY$ = ""
WEND
END
testmode: ' illegal function call errors get redirected here to cancel out some options.
b(a) = 0 ' if mode number gives an illegal function call error, then it's disqualified.
RESUME NEXT

r/QBprograms • • May 11 '22

URL to resource r/QBeducation is a new subreddit that has been started to encourage educational use of QB64, as well as some education on how to program with it.

Thumbnail reddit.com
1 Upvotes

r/QBprograms • • May 29 '23

QBASIC QBasic Gorillas (GORILLA.BAS) [Microsoft, 1991] THE CLASSIC WE ALL LOVE!!! link in comments

Post image
1 Upvotes

r/QBprograms • • May 30 '22

QBASIC HAPPY MEMORIAL DAY

1 Upvotes
'
' runs on QuickBasic, QBasic, and QB64.
'
'
SCREEN 0
WIDTH 40, 25
CLS
PRINT
PRINT " * * * * * * * *======================="
PRINT "  * * * * * * * -----------------------"
PRINT " * * * * * * *  ======================="
PRINT "  * * * * * * * -----------------------"
PRINT " * * * * * * *  ======================="
PRINT "  * * * * * * * -----------------------"
PRINT " * * * * * * *  ======================="
PRINT " --------------------------------------"
PRINT " ======================================"
PRINT " --------------------------------------"
PRINT " ======================================"
PRINT " --------------------------------------"
PRINT " ======================================"
PRINT
COLOR 15
PRINT "               HAPPY MEMORIAL DAY"
COLOR 7
PRINT
PRINT
PRINT
PRINT " press any key to quit"
FOR y = 1 TO 13
    FOR x = 1 TO 38
        xx = x + 1
        yy = y + 1
        LOCATE yy, xx
        SELECT CASE CHR$(SCREEN(yy, xx))
            CASE "*"
                COLOR 15, 1
                PRINT "*"
            CASE " "
                COLOR 1, 1
                PRINT " "
            CASE "-"
                COLOR 15
                PRINT "Û"
            CASE "="
                COLOR 4
                PRINT "Û"
        END SELECT
    NEXT
NEXT
WHILE INKEY$ = ""
WEND
COLOR 7, 0
CLS
WIDTH 80, 25
END

r/QBprograms • • Feb 26 '22

QBASIC QBasic - ARRAYS

2 Upvotes

Hello everyone. I hope this post is apropriate for the group.

I'm trying to write a program that allows user to define an array that doesn't have over 100 elements. User inputs the elements of arary till 0 is typed, but 0 shouldn't be included as an element of an array. Plus it's assumed that user won't input negative numbers and that the lowest number is entered is 1. Then thr program prints the lowest and the highest number in an array.

This is the solution I came up with. I'm new to QBasic so if it's unefficient I apologize in advance :D.

CLS

1 INPUT "Enter the number of elements in array"; n

IF n>100 THEN GOTO 1

DIM numbers(n)

FOR i=1 TO n

INPUT" Enter the numbers of array: "; numbers(i)

IF numbers(i)=0 THEN GOTO 2 // This is the part of the code that stops input of numbers in anarray,but it stil counts 0 as an element of an array

NEXT i

2 min=numbers(1)

max=numbers(1)

FOR i=1 TO n

IF min>numbers(i) THEN min=numbers(i)

IF max<numbers(i) THEN max=numbers(i)

NEXT i

PRINT "Lowest number in array is: ", min, "Highest number in array is: ", max

END

If annayone can give me some input on how to solve the problem I would appriciate it a lot.