Fun programs with QBasic 4.5

Chat about just about anything else
User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Fun programs with QBasic 4.5

Post by pascal111 » Tue Aug 27, 2019 4:08 am

This's small program I made when I was practicing programming in old ways, it shows you your luck by picking 3 cards, it's programmed originally in QB45 but I used QB64 linux version to make the executable file.

Image

This's the executable file, it worked well under my Mint:
http://www.mediafire.com/file/5s6edfrvu07t8nv/LUCK/file
Last edited by pascal111 on Sat Aug 31, 2019 4:32 am, edited 1 time in total.

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: See your luck program

Post by rene » Tue Aug 27, 2019 1:23 pm

You'll want to look at the existence or placement of a RANDOMIZE call: you generate the same three cards after " [ ... ] play again (y/n)?"

But... I'd also not post binaries without source to a forum largely dedicated to open source. Certainly most people on Linux would not advise anyone to run random binaries posted to the web. As such, and if this post in fact serves a purpose as to giving or asking for advise, you may want to post source rather than or in addition to binaries.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Tue Aug 27, 2019 3:08 pm

I appreciate that you used my program very much, I didn't expect that there's someone care in such classic programming and there's professionals in this hobby but I'm still training.

The story of this program is that I was training in how to make data saved in array without repeating then the idea of this cards luck has triggered on my mind so I complete the program like this.

This's the source code:

QB45 code:

Code: Select all

RANDOMIZE TIMER
OPTION BASE 1

CLS

DIM x(14) AS INTEGER
DIM l(3) AS INTEGER

FOR i = 1 TO UBOUND(x)
    LET x(i) = 0
NEXT i


FOR k = 1 TO UBOUND(x)
    10 LET y = INT((15 - 1) * RND + 1)
    FOR i = 1 TO UBOUND(x)

        IF x(i) = y THEN 10


    NEXT i

    FOR j = 1 TO UBOUND(x)
        IF x(j) = 0 THEN
            LET x(j) = y
            EXIT FOR
        END IF
    NEXT j

NEXT k

20 INPUT "Are you ready to pick your three luck cards (y/n)?", s$
IF s$ = "n" THEN 20
PRINT

FOR i = 1 TO 3
    SELECT CASE x(i)
        CASE IS <= 10
            PRINT x(i)
        CASE 11
            PRINT "King"
        CASE 12
            PRINT "Queen"
        CASE 13
            PRINT "Prince"
        CASE 14
            PRINT "Ace"
    END SELECT
    LET l(i) = x(i)
NEXT i


FOR i = 1 TO 3
    SELECT CASE l(i)
        CASE 1
            PRINT
            PRINT "You'll understand a wisdom."
        CASE 2
            PRINT
            PRINT "You'll have a good adviser."
        CASE 3
            PRINT
            PRINT "Good deeds yield good times."
        CASE 4
            PRINT
            PRINT "You'll back again to things of your past."
        CASE 5
            PRINT
            PRINT "World will know about your private life."
        CASE 6
            PRINT
            PRINT "Some money or benefits is in your way."
        CASE 7
            PRINT
            PRINT "Tests in life will face you."
        CASE 8
            PRINT
            PRINT "You need to clean black points,"
            PRINT "in your life before time being late."
        CASE 9
            PRINT
            PRINT "Hard times, be strong."
        CASE 10
            PRINT
            PRINT "The hapiness is over your expecting."
        CASE 11
            PRINT
            PRINT "Some benefits from government side."
        CASE 12
            PRINT
            PRINT "Good opinions from women."
        CASE 13
            PRINT
            PRINT "You'll know high class someone."
        CASE 14
            PRINT
            PRINT "False doubts in your mind."
    END SELECT
NEXT i

PRINT
INPUT "Do you want to play again (y/n)?", s$

IF s$ = "y" THEN 20
PRINT
PRINT "Programmed by Ahmed Crow 2019,"

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: See your luck program

Post by rene » Tue Aug 27, 2019 6:26 pm

I see. You shuffle the deck only once before looping the game, so I take it that it showing the same hand upon "playing again" is by design. You can in that case make things rather more compact though. Just having a bit of fun here... but I'd functionality-wise boil this down to basics as:

Code: Select all

DIM card(2 TO 14) AS STRING

card$(2) = "2 (You'll have a good adviser)"
card$(3) = "3 (Good deeds yield good times)"
card$(4) = "4 (You'll back again to things of your past)"
card$(5) = "5 (World will know about your private life)"
card$(6) = "6 (Some money or benefits is in your way)"
card$(7) = "7 (Tests in life will face you)"
card$(8) = "8 (You need to clean black points in your life before time being late)"
card$(9) = "9 (Hard times, be strong)"
card$(10) = "T (The hapiness is over your expecting)"
card$(11) = "J (You'll know high class someone)"
card$(12) = "Q (Good opinions from women)"
card$(13) = "K (Some benefits from government side)"
card$(14) = "A (False doubts in your mind)"

RANDOMIZE TIMER
FOR i = 1 TO 3
    DO
        j = INT((UBOUND(card) - LBOUND(card) + 1) * RND) + LBOUND(card)
    LOOP UNTIL card$(j) <> ""
    PRINT card$(j)
    card$(j) = ""
NEXT i
If you did originally want to generate additional hands when "playing again" you'd adjust this for example as:

Code: Select all

DIM card(2 TO 14) AS STRING

card$(2) = "2 (You'll have a good adviser)"
card$(3) = "3 (Good deeds yield good times)"
card$(4) = "4 (You'll back again to things of your past)"
card$(5) = "5 (World will know about your private life)"
card$(6) = "6 (Some money or benefits is in your way)"
card$(7) = "7 (Tests in life will face you)"
card$(8) = "8 (You need to clean black points in your life before time being late)"
card$(9) = "9 (Hard times, be strong)"
card$(10) = "T (The hapiness is over your expecting)"
card$(11) = "J (You'll know high class someone)"
card$(12) = "Q (Good opinions from women)"
card$(13) = "K (Some benefits from government side)"
card$(14) = "A (False doubts in your mind)"

RANDOMIZE TIMER

DO
    DIM have(3) AS INTEGER

    have(0) = 0
    have(1) = 0

    FOR i = 0 TO 2
        DO
            j = INT((UBOUND(card) - LBOUND(card) + 1) * RND) + LBOUND(card)
        LOOP UNTIL j <> have(0) AND j <> have(1)
        PRINT card$(j)
        have(i) = j
    NEXT i

    PRINT
    INPUT "Do you want to play again (y/n)"; again$
    PRINT

LOOP UNTIL again$ <> "y"
As said, just playing around. Have probably not written BASIC since growing hair in awkward spots...

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Wed Aug 28, 2019 6:24 am

Perfect! your routine seems good, I'm studying it, by the way I made changes in the original program and I hope it changed its behaviour to the better, and I added remarks.

QB45 code:

Code: Select all

REM ********* Luck Cards *************
REM Programmed by Ahmed Crow 2019 QB45
REM The main aim is to charge an array
REM with uniqe random values.
REM **********************************

RANDOMIZE TIMER
OPTION BASE 1

CLS

DIM x(14) AS INTEGER 'Array of cards
DIM l(3) AS INTEGER 'Array of picked 3 cards


REM *** Charging the cards array with unique values
Charge:

FOR k = 1 TO UBOUND(x)
Gener:
    LET y = INT(((UBOUND(x) + 1) - 1) * RND + 1)
   
REM *** Searching for repeated value
REM *** Passing unique value

    FOR i = 1 TO UBOUND(x)

        IF x(i) = y THEN GOTO Gener


    NEXT i

REM *** Charging the array with the unique
REM value in surely empty position

    FOR j = 1 TO UBOUND(x)
        IF x(j) = 0 THEN
            LET x(j) = y
            EXIT FOR
        END IF
    NEXT j

NEXT k


REM *** Preparing the user before picking cards

ready:

INPUT "Are you ready to pick your three luck cards (y/n)?", s$
IF s$ = "n" THEN
GOTO ready
ELSEIF s$ <> "y" AND s$ <> "n" THEN
GOTO ready
END IF

REM *** Picking 3 luck cards

PRINT
FOR i = 1 TO 3
    SELECT CASE x(i)
        CASE IS <= 10
            PRINT x(i)
        CASE 11
            PRINT "King"
        CASE 12
            PRINT "Queen"
        CASE 13
            PRINT "Prince"
        CASE 14
            PRINT "Ace"
    END SELECT
    LET l(i) = x(i) 'Saving cards numbers
NEXT i

REM *** Showing luck value of each card

FOR i = 1 TO 3
    SELECT CASE l(i)
        CASE 1
            PRINT
            PRINT "Brevity words will be explained."
        CASE 2
            PRINT
            PRINT "You'll have a good adviser."
        CASE 3
            PRINT
            PRINT "Good deeds yield good times."
        CASE 4
            PRINT
            PRINT "You'll back again to things of your past."
        CASE 5
            PRINT
            PRINT "World will know about your private life."
        CASE 6
            PRINT
            PRINT "Some money or benefits is in your way."
        CASE 7
            PRINT
            PRINT "Tests in life will face you."
        CASE 8
            PRINT
            PRINT "You need to clean black points,"
            PRINT "in your life before time being late."
        CASE 9
            PRINT
            PRINT "Hard times, be strong."
        CASE 10
            PRINT
            PRINT "The hapiness is over your expecting."
        CASE 11
            PRINT
            PRINT "Some benefits from government side."
        CASE 12
            PRINT
            PRINT "Good opinions from women."
        CASE 13
            PRINT
            PRINT "You'll know high class someone."
        CASE 14
            PRINT
            PRINT "False doubts in your mind."
    END SELECT
NEXT i

PRINT

REM *** Questioning of repeating the game

Again:

INPUT "Do you want to play again (y/n)?", s$

IF s$ = "y" THEN
PRINT
CLEAR
GOTO Charge
ELSEIF s$ <> "y" AND s$ <> "n" THEN
GOTO Again
END IF
END
Edit reason: There's no need for zeroing an array declared by dim because dim will zeroing it automatically in QB, and we used "clear" command to zeroing all variables for next turns that need zeroing variables and removing previous values.

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: See your luck program

Post by rene » Wed Aug 28, 2019 9:32 am

Yes, that version now in fact plays again. Don't get me wrong, I noticed your "main aim" as stated at at the top (i.e., your program isn't necessarily about functionality nor program logic) but things that I'd critique if it were say a homework assignment, in decreasing order of "seriousness":

1. You generate a random hand of 14 cards in x(1) through x(14) but then in fact use only x(1), x(2) and x(3). I'd therefore also only generate those 3.
2. The search for the "surely empty position" in "x" to plug the newly generated value into seems to not make sense: it will simply be position k.
3. Why the "l" array? You do not disturb "x" in any way when outputting the cards so could jjust use x(1), x(2) and x(3) directly again. Might have something to with 1; it seems your idea here was that "l" would be the actually drawn hand but well, once again, that hand is simply x(1), x(2), x(3).
4. A regular card suit in fact consists of 13 cards; does not include "1" if "ace" is also included such as in your case. Clearly you're free to invent your own cards here (and the order of king after ten seems to be doing as much as well) but it smells a bit like the common "off by one" programming error.
5. Unless for temporary integers and loop control variables and things like that, try to use descriptive variable names. I.e., "hand" instead of "l" for example if indeed that was the idea of that array. Comments are important, but not needing some/any due to self-documenting code is still much preferred.

Hope you find this useful...

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Wed Aug 28, 2019 2:39 pm

rene wrote:
Wed Aug 28, 2019 9:32 am
Yes, that version now in fact plays again. Don't get me wrong, I noticed your "main aim" as stated at at the top (i.e., your program isn't necessarily about functionality nor program logic) but things that I'd critique if it were say a homework assignment, in decreasing order of "seriousness":

Hope you find this useful...
I'm so glad and have wide-spreading breast (not disturbed nor sad) with your critique, I discover new things in a lovely subject like programming.
1. You generate a random hand of 14 cards in x(1) through x(14) but then in fact use only x(1), x(2) and x(3). I'd therefore also only generate those 3.
Yes, it's sense.
2. The search for the "surely empty position" in "x" to plug the newly generated value into seems to not make sense: it will simply be position k.
I didn't noticed that, I'll test it.
3. Why the "l" array? You do not disturb "x" in any way when outputting the cards so could jjust use x(1), x(2) and x(3) directly again. Might have something to with 1; it seems your idea here was that "l" would be the actually drawn hand but well, once again, that hand is simply x(1), x(2), x(3).
I think you're so right.
4. A regular card suit in fact consists of 13 cards; does not include "1" if "ace" is also included such as in your case. Clearly you're free to invent your own cards here (and the order of king after ten seems to be doing as much as well) but it smells a bit like the common "off by one" programming error.
It's not bad idea here to work according to the common order, I agree.
5. Unless for temporary integers and loop control variables and things like that, try to use descriptive variable names. I.e., "hand" instead of "l" for example if indeed that was the idea of that array. Comments are important, but not needing some/any due to self-documenting code is still much preferred.
I read once about that it was advised to give some sensible names for variables, but the old BASIC style was using just two letters for variable names and may be a number like in C64 BASIC, it's not so necessary for program in this size such mine but of course, sensible names is more flexible. Another point I read too is that the remarks are advised to be typed, I think it's useful because next program reading time, maybe I'll forget the sequence of the program and it's useful too for beginners if they read program like this.

Really, I'm so glad with your critique, don't be ungenerous at anytime to tell me any critical point you notice in my code, you're welcome.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Wed Aug 28, 2019 3:27 pm

What about this version, I took in my consideration the critical points and changed the general purpose of the program :)

Code: Select all

REM ********* Luck Cards *************
REM Programmed by Ahmed Crow 2019 QB45
REM Critical changes by rene of
REM https://forums.linuxmint.com :)
REM **********************************

RANDOMIZE TIMER
OPTION BASE 1

CLS

DIM x(3) AS INTEGER 'Array of cards

REM *** Charging the cards array with unique values

DO

FOR k = 1 TO UBOUND(x)

DO
    LET y = INT(((14 + 1) - 1) * RND + 1)

LOOP UNTIL x(1) <> y AND x(2) <> y

LET x(k) = y

NEXT k


REM *** Preparing the user before picking cards

ready:

INPUT "Are you ready to pick your three luck cards (y/n)?", s$
IF s$ = "n" THEN
GOTO ready
ELSEIF s$ <> "y" AND s$ <> "n" THEN
GOTO ready
END IF

REM *** Picking 3 luck cards

PRINT
FOR i = 1 TO UBOUND(x)
    SELECT CASE x(i)
        CASE IS <= 10
            PRINT x(i)
        CASE 13
            PRINT "King"
        CASE 12
            PRINT "Queen"
        CASE 11
            PRINT "Prince"
        CASE 14
            PRINT "Ace"
    END SELECT
NEXT i

REM *** Showing luck value of each card

FOR i = 1 TO UBOUND(x)
    SELECT CASE x(i)
        CASE 1
            PRINT
            PRINT "Brevity words will be explained."
        CASE 2
            PRINT
            PRINT "You'll have a good adviser."
        CASE 3
            PRINT
            PRINT "Good deeds yield good times."
        CASE 4
            PRINT
            PRINT "You'll back again to things of your past."
        CASE 5
            PRINT
            PRINT "World will know about your private life."
        CASE 6
            PRINT
            PRINT "Some money or benefits is in your way."
        CASE 7
            PRINT
            PRINT "Tests in life will face you."
        CASE 8
            PRINT
            PRINT "You need to clean black points,"
            PRINT "in your life before time being late."
        CASE 9
            PRINT
            PRINT "Hard times, be strong."
        CASE 10
            PRINT
            PRINT "The hapiness is over your expecting."
        CASE 13
            PRINT
            PRINT "Some benefits from government side."
        CASE 12
            PRINT
            PRINT "Good opinions from women."
        CASE 11
            PRINT
            PRINT "You'll know high class someone."
        CASE 14
            PRINT
            PRINT "False doubts in your mind."
    END SELECT
NEXT i

PRINT

REM *** Questioning of repeating the game

Again:

INPUT "Do you want to play again (y/n)?", s$

IF s$ = "y" THEN
PRINT
CLEAR
ELSEIF s$ <> "y" AND s$ <> "n" THEN
GOTO Again
END IF

LOOP UNTIL s$ = "n"
END

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: See your luck program

Post by rene » Wed Aug 28, 2019 5:12 pm

Yes, if you are indeed certain that "x" is initialized to all-zero automatically by all BASIC dialects you are interested in, I have no functional complaints left.

Very slight issue:
pascal111 wrote:
Wed Aug 28, 2019 3:27 pm

Code: Select all

INPUT "Are you ready to pick your three luck cards (y/n)?", s$
IF s$ = "n" THEN
GOTO ready
ELSEIF s$ <> "y" AND s$ <> "n" THEN
GOTO ready
END IF
s$ = "n" is being taken care of by the IF-branch, so if you hit the ELSEIF-branch you are guaranteed that s$ <> "n". That is, you can leave out the 'AND s$ <> "n"' bit. Same thing for the "Do you want to play again" question below; there, s$ <> "y" is automatically true in the ELSEIF-branch.

Other than that I could only think to complain about indentation of those bits: I'd indent both GOTO's...

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Wed Aug 28, 2019 5:54 pm

You're right! I removed "goto" by "do-loop", I discovered that now, it's more appropriate for this part of code, I know that one of programming directions preferred not to use "goto", but I see no problem of its usage if it's in the appropriate cases.

What about this version of the program:
QB45 code:

Code: Select all

REM ********* Luck Cards *************
REM Programmed by Ahmed Crow 2019 QB45
REM Critical changes by rene of
REM https://forums.linuxmint.com :)
REM **********************************

RANDOMIZE TIMER
OPTION BASE 1

CLS

DIM x(3) AS INTEGER 'Array of cards

REM *** Charging the cards array with unique values

DO

CLEAR 'Unnecessary for 1st turn!

FOR k = 1 TO UBOUND(x)

DO
    LET y = INT(((14 + 1) - 1) * RND + 1)

LOOP UNTIL x(1) <> y AND x(2) <> y

LET x(k) = y

NEXT k


REM *** Preparing the user before picking cards

DO
INPUT "Are you ready to pick your three luck cards (y/n)?", s$
LOOP UNTIL s$ = "y" OR s$ = UCASE$("y")

REM *** Picking 3 luck cards

PRINT
FOR i = 1 TO UBOUND(x)
    SELECT CASE x(i)
        CASE IS <= 10
            PRINT x(i)
        CASE 13
            PRINT "King"
        CASE 12
            PRINT "Queen"
        CASE 11
            PRINT "Prince"
        CASE 14
            PRINT "Ace"
    END SELECT
NEXT i

REM *** Showing luck value of each card

FOR i = 1 TO UBOUND(x)
    SELECT CASE x(i)
        CASE 1
            PRINT
            PRINT "Brevity words will be explained."
        CASE 2
            PRINT
            PRINT "You'll have a good adviser."
        CASE 3
            PRINT
            PRINT "Good deeds yield good times."
        CASE 4
            PRINT
            PRINT "You'll back again to things of your past."
        CASE 5
            PRINT
            PRINT "World will know about your private life."
        CASE 6
            PRINT
            PRINT "Some money or benefits is in your way."
        CASE 7
            PRINT
            PRINT "Tests in life will face you."
        CASE 8
            PRINT
            PRINT "You need to clean black points,"
            PRINT "in your life before time being late."
        CASE 9
            PRINT
            PRINT "Hard times, be strong."
        CASE 10
            PRINT
            PRINT "The hapiness is over your expecting."
        CASE 13
            PRINT
            PRINT "Some benefits from government side."
        CASE 12
            PRINT
            PRINT "Good opinions from women."
        CASE 11
            PRINT
            PRINT "You'll know high class someone."
        CASE 14
            PRINT
            PRINT "False doubts in your mind."
    END SELECT
NEXT i

PRINT

REM *** Questioning of repeating the game

DO
INPUT "Do you want to play again (y/n)?", s$
LOOP UNTIL (s$ = "n" OR s$ = UCASE$("n")) OR (s$ = "y" OR s$ = UCASE$("y"))

'if s$="y" or s$=ucase$("Y") then clear 'instead of the 1st "CLEAR" command

PRINT

LOOP UNTIL s$ = "n" OR s$ = UCASE$("n")

PRINT
PRINT "Programmed by Ahmed Crow 2019,"
PRINT "judas.the.messiah.111@gmail.com"

END

Edit: some remarks
Last edited by pascal111 on Wed Aug 28, 2019 6:19 pm, edited 1 time in total.

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: See your luck program

Post by rene » Wed Aug 28, 2019 6:19 pm

Personally I tend to reserve use of GOTO in C for error handling. GOTO does in fact turn one's code into spaghetti when used as a general looping primitive I feel but is generally exactly right for the "oops, let's get the <bleep> out of here" type of error handling flow (in languages without so-called "exceptions").

As an example of how GOTO does tend to obscure codeflow I'd almost be tempted to point to me not above remarking on what you have in this new version already done much better with a DO/LOOP UNTIL. Yes, after foregoing the AND bit of the ELSEIF-branch we had an IF-condition that was a subset of the ELSEIF-condition --- and given that both branched to the same label, therefore effectively just one condition + branch, therefore effectively the much nicer DO/LOOP UNTIL construct that you changed it to. If I'd feel pedantic I'd comment that I'd feel it likely that BASIC guarantees that UCASE$("y") = "Y" and UCASE$("n") = "N" -- but I'd say this will do fine as the final version.

As an only general comment, and referring to my own version, I'm personally strongly inclined to "data-centric programming" as opposed to code-centric. I.e., the reason why my version defined the card names and "lucks" as an array itself and (there through) forewent the large SELECT statement. Code-centric tends to be more straightforward; data-centric to be shorter/faster. Just a preference, but it's good to be aware early on when learning programming that those can be seen to be two discrete sub-paradigms of the procedural programming paradigm (data-centric leans a bit more towards the object paradigm).

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: See your luck program

Post by pascal111 » Wed Aug 28, 2019 6:38 pm

Your aid helped to make like a standard program that one can keep it and open it at another time and study it, this's what I intended to, to make program like traditional BASIC programs I saw in books, of course, this one is small one or has simple idea if compared to another traditional programs, but it makes someone to feel happy if he succeeded to build a program.

C language as you mentioned, in my opinion has its own logic and maybe we can do things in BASIC in ways that don't seem appropriate in C, goto is one of these things and maybe goto was in something like TC++ under DOS but I don't think someone will use goto in something like VC++

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Sat Aug 31, 2019 4:43 am

This time I made unprofessional tic tac toe, it's not smart one yet and I think this isn't the final form of it, but the good thing is that I tried to do it with personal efforts without taking a look in a standard code for it, I share it and wait critiques and opinions.

I found a problem in the text editor to show the same ASCII characters I used to draw the game board, it must be like in next image:

Image

QB45 code:

Code: Select all

DECLARE SUB lookxo (s$)
DECLARE SUB newxy (p%) '*** Routine of x,y input
DECLARE SUB sign (xx!, yy!, s$) '*** Graphing in the table routine
CONST vrai = 1
CONST faux = 0
OPTION BASE 1
RANDOMIZE TIMER
CLS

LOCATE 4, 40: PRINT "ÚÄÄÄÄÄÂÄÄÄÄÄÂÄÄÄÄÄ¿"
LOCATE 5, 40: PRINT "³     ³     ³     ³"
LOCATE 6, 40: PRINT "ÃÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄŽ"
LOCATE 7, 40: PRINT "³     ³     ³     ³"
LOCATE 8, 40: PRINT "ÃÄÄÄÄÄÅÄÄÄÄÄÅÄÄÄÄÄŽ"
LOCATE 9, 40: PRINT "³     ³     ³     ³"
LOCATE 10, 40: PRINT "ÀÄÄÄÄÄÁÄÄÄÄÄÁÄÄÄÄÄÙ"


DIM SHARED m$(3, 3)
DIM SHARED column%, row%
DIM SHARED x, y, c

LET column% = POS(0)
LET row% = CSRLIN
LET c = faux

DO


CALL newxy(0) '*** Computer turn for input
CALL sign(x, y, m$(x, y)) '*** The graph sign of computer input
CALL lookxo(m$(x, y))

REM *** Being sure that the array of the board is full
LET k = 0
FOR i = 1 TO 3
FOR j = 1 TO 3
IF m$(i, j) = "o" OR m$(i, j) = "x" THEN LET k = k + 1
NEXT j
NEXT i

IF k = 9 THEN EXIT DO

CALL newxy(1) '*** User turn
CALL sign(x, y, m$(x, y)) '*** The graph sign of user input
CALL lookxo(m$(x, y))

LOOP
END


subroutine;

Code: Select all

SUB lookxo (s$)

LET l = 0

FOR i = 1 TO 3
IF m$(i, 1) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
FOR i = 1 TO 3
IF m$(i, 2) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
FOR i = 1 TO 3
IF m$(i, 3) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
FOR i = 1 TO 3
IF m$(1, i) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
FOR i = 1 TO 3
IF m$(2, i) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
FOR i = 1 TO 3
IF m$(3, i) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
LET f = 0
FOR i = 1 TO 3
LET f = f + 1
IF m$(f, f) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result
NEXT i

LET l = 0
IF m$(1, 3) = s$ THEN LET l = l + 1
IF m$(2, 2) = s$ THEN LET l = l + 1
IF m$(3, 1) = s$ THEN LET l = l + 1
IF l = 3 THEN GOTO Result

EXIT SUB
Result:
IF s$ = "x" THEN
FOR i = 1 TO 5
LOCATE i, 1
PRINT "Computer won!!"
NEXT i
ELSE
FOR i = 1 TO 5
LOCATE i, 1
PRINT "You won!!"
NEXT i
END IF
END
END SUB
subroutine

Code: Select all

SUB newxy (p%)

REM ****** Computer turn for input *******
IF p% = 0 THEN

DO

LET x = INT(((3 + 1) - 1) * RND + 1)
LET y = INT(((3 + 1) - 1) * RND + 1)

LOOP WHILE m$(x, y) = "x" OR m$(x, y) = "o"
LET d$ = "x"

REM ******* User turn for input *********
ELSEIF p% = 1 THEN

person:
IF c = vrai THEN
LET row% = row% - 3
LOCATE row%, column%
FOR i = 1 TO 3
PRINT SPACE$(80)
NEXT i
END IF

LOCATE row%, column%
PRINT "Your turn,"


INPUT "Enter x:", x
INPUT "Enter y:", y
LET c = vrai

IF m$(x, y) = "x" OR m$(x, y) = "o" THEN
PRINT "This square is full."
LET column% = POS(0)
LET row% = CSRLIN
SLEEP 1
LET row% = row% - 1
LOCATE row%, column%
PRINT SPACE$(80)
GOTO person
END IF
LET d$ = "o"
ELSE
PRINT "False parameter in newxy sub!!"
END IF

LET m$(x, y) = d$ 'Determining x or o for next step

REM *** Saving the cursor position before signing

LET column% = POS(0)
LET row% = CSRLIN

END SUB
subroutine

Code: Select all

SUB sign (xx, yy, s$)

IF s$ = "x" THEN
SLEEP 1
PLAY "MB D"
ELSE
PLAY "MB F"
END IF


IF (xx = 1 AND yy = 1) THEN
LOCATE 5, 43: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column% 'Return to the same position before signing
ELSEIF (xx = 1 AND yy = 2) THEN
LOCATE 7, 43: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 2 AND yy = 1) THEN
LOCATE 5, 49: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 2 AND yy = 2) THEN
LOCATE 7, 49: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 1 AND yy = 3) THEN
LOCATE 9, 43: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 2 AND yy = 3) THEN
LOCATE 9, 49: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%


ELSEIF (xx = 3 AND yy = 1) THEN
LOCATE 5, 55: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 3 AND yy = 2) THEN
LOCATE 7, 55: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%
ELSEIF (xx = 3 AND yy = 3) THEN
LOCATE 9, 55: PRINT UCASE$(m$(xx, yy))
LOCATE row%, column%

END IF

END SUB

User avatar
Portreve
Level 7
Level 7
Posts: 1997
Joined: Mon Apr 18, 2011 12:03 am
Location: Florida
Contact:

Re: Fun programs with QBasic 4.5

Post by Portreve » Sat Aug 31, 2019 4:31 pm

I know of QBasic, but I've never used it. When I was in high school, I learned some very elementary basics in Tandy BASICA, and I also learned to play around with GW-BASIC in MS-DOS. One of the programs I had to enter was the William Tell Overture (by Rossini) and then, years later, I found someone had posted it online.

If anyone's interested, here's a link to a web page with a bunch of GW-BASIC programs, which I think you can take and run using QBasic. Most of the way down on that list is willtell.zip, which when decompressed will give you willtell.bas.

I was really never able to make the transition from using line numbers to not using line numbers. Honestly, though I wouldn't trade my grounding in basic technology from the computer class I took for three years in high school, I can tell you right now I'm no programmer, and have never fancied myself as one.
I'm so down wit' dat', yo, dass ich unter dem Beton bin.

Presently rocking LinuxMint 19.2 Cinnamon.

Remember to mark your fixed problem [SOLVED].

All in all, you're just another brick in the wall.

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: Fun programs with QBasic 4.5

Post by rene » Sat Aug 31, 2019 11:39 pm

pascal111 wrote:
Sat Aug 31, 2019 4:43 am
I found a problem in the text editor to show the same ASCII characters I used to draw the game board
That is due to QB64 by default using the CP437 "codepage" (the basic, US codepage) for both the IDE editor and its output.

Very briefly, ASCII is a 7-bit standard; comprises 2^7=128 characters. The PC used 8-bit characters meaning it had characters 128-255 available for additional characters over ASCII. Only 128 additional characters over ASCII were never enough to satisfy all non-English uses though; users from different language zones (think Nordic, Greek, Cyrillic zones) would load different codepages, different characters 128-255.

CP437 can be viewed here: https://en.wikipedia.org/wiki/Code_page_437 and you can for example see that the left-upper corner box drawing character is 218 in CP437. You can enter that into the QB64 IDE editor by holding down left-Alt, typing 2, 1, 8 and letting go of left-Alt. Same for the other box drawing characters you see there.

These days "codepages" are obsolete; the Unicode character set is a single character set that aims to comprise everything anyone could ever need. It's UTF-8 encoding is what I believe comprises the gobbledegook you pasted in above. I.e., seems something got pasted a few too many times through UTF-8 intermediary state -- or something. In any case, just enter the box drawing characters directly as per previous paragraph.

Interestingly though, the very mention of these "codepages" should really be all that anyone needs to realise that this stuff is truly, decidedly obsolete. Rather than comment further on old BASIC I therefore thought it might be more interesting for you to look at a mode modern implementation of the same game, in this case in Python. I've kept your basic logic; the computer "AI" still just picks a random field.

As to your internal logic there's a change: whereas your computer player picks a random field by looping until it has one which isn't yet occupied, this Python version keeps a count of still available fields --- very useful to declare a draw once it drops to 0 anyway --- and generates a random field only from among those still available ones. The difference of course is that it then generates only one random number per computer turn whereas your version could loop around generating more; could theoretically loop infinitely, if we had been talking about a real rather than pseudo random number generator. It also by the way denotes a field as 1 to 9, internally 0 to 8, rather than (1,1) through (3,3) but while it makes things easier that's not in itself essential; you'll see r(ow) and c(olumn) being taken from that single integer f(ield) in this version as well.

As said, I would not myself find BASIC a very worthy study at this point; thought I'd try and see if you'd consider Python interesting. At least the box drawing characters are now UTF-8 encoded Unicode. Be sure to chmod +x ttt.py before running it as ./ttt.py from the directory it's in.

Code: Select all

#!/usr/bin/python3

from curses import wrapper 
from random import randint
from time import sleep

def main(stdscr):

    board = [None] * 9
    avail = 9

    stdscr.clear()
    stdscr.addstr("┌─────┬─────┬─────┐\n"
                  "│     │     │     │\n"
                  "├─────┼─────┼─────┤\n"
                  "│     │     │     │\n"
                  "├─────┼─────┼─────┤\n"
                  "│     │     │     │\n"
                  "└─────┴─────┴─────┘\n"
                  "\n"
                  "Field (1-9): ")

    while True:

        def move(f, p):
            nonlocal avail

            board[f] = p
            avail -= 1

            r = f // 3
            c = f % 3

            stdscr.addch(1 + 2 * r, 3 + 6 * c, 'x' if p == 0 else 'o')
            stdscr.refresh()
            stdscr.move(8, 0)

            line = [p] * 3
            return board[3 * r : 3 * r + 2 + 1] == line or \
                   [board[i] for i in [c, c + 3, c + 6]] == line or \
                   (f % 4 == 0 and [board[i] for i in [0, 4, 8]] == line) or \
                   (f % 2 == 0 and [board[i] for i in [2, 4, 6]] == line)


        i = randint(1, avail)
        f = 0
        while True:
            if board[f] == None:
                i -= 1
                if i == 0:
                    break
            f += 1

        if move(f, 0):
            stdscr.addstr("The computer has won")
            break

        if avail == 0:
            stdscr.addstr("Draw")
            break

        while True:
            f = stdscr.getch(8, 13) - ord('1')
            if f < 0 or f > 8 or board[f] != None:
                stdscr.addch(8, 13, '!')
                stdscr.refresh()
                sleep(1)
                stdscr.addch(8, 13, ' ')
            else:
                break

        if move(f, 1):
            stdscr.addstr("The player has won")
            break;

    stdscr.addstr(" (press any key to exit)")
    stdscr.refresh()
    stdscr.getkey()


if __name__ == "__main__":
    wrapper(main)
Last edited by rene on Sun Sep 01, 2019 10:28 am, edited 1 time in total.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Sun Sep 01, 2019 5:18 am

Portreve wrote:
Sat Aug 31, 2019 4:31 pm
I know of QBasic, but I've never used it. When I was in high school, I learned some very elementary basics in Tandy BASICA, and I also learned to play around with GW-BASIC in MS-DOS. One of the programs I had to enter was the William Tell Overture (by Rossini) and then, years later, I found someone had posted it online.

If anyone's interested, here's a link to a web page with a bunch of GW-BASIC programs, which I think you can take and run using QBasic. Most of the way down on that list is willtell.zip, which when decompressed will give you willtell.bas.

I was really never able to make the transition from using line numbers to not using line numbers. Honestly, though I wouldn't trade my grounding in basic technology from the computer class I took for three years in high school, I can tell you right now I'm no programmer, and have never fancied myself as one.
I'm really trying figure what's programming, in this way I didn't use high logic like C++, I used what can be enough like BASIC in general and QBasic particularly, I've another important question on my mind that if we don't feel in enjoyment in programming, so why we've to learn it?! This's the essential point I care in, the artistic programming, it's not just traditional education programming for performing calculations and solve problems for business as an example.

To line number point, I can help you, I can tech you what I know, the transition isn't that complex seemed to be, you can think that if you took a look on big QBasic program at first time, you'll think that you're lost, QBasic according to my understanding added some advanced techniques for traditional BASIC ones, in the same time, you can't say that QBasic is like C logic, there's a deference, in QBasic we still deal and work with traditional BASIC with new advanced features that make the programming to be more flexible but it still in its core pure BASIC. When BASIC take some styles from Pascal logic this what makes it more attractive.

Take quick points:

- You don't have to use GOSUB in QBasic but you can, you can use instead of it a subroutine block, go to "EDIT menu > New SUB", and give your subroutine a name and inside your program call it like:

Call mysub

or maybe use just its name, you can use parameters to pass 'em to your subroutine, if you want to use variables from the general program in the sub without passing 'em as a parameter, you declare 'em in the general program like this "DIM SHARED X, Y, Z", just use the word shared.

There's no need to use "RETURN" inside the subroutine, the program control will back automatically after the subroutine call to the general program and at the correct next command.

- I didn't work with "DEF FN" but I think it's just to make a function, there's more flexible way to make functions too like subroutines, go to "EDIT > New Function", and you can make complex function if you want, you can pass parameters, and in the end of the function you use the function name and the value you want to return to the general program for example, like " myfunctionname = x", and in the program you use it like "K = myfunction (x)", for example, you can used too the shared variables without passing.

- In traditional BASIC there's no scope for variables, to make that for a variable, declare it with "DIM SHARED", because it seemed that any variable has a scope inside the imitation of the its block, like sub block or function block or general program area.

- I saw no addition for "FOR-NEXT"

- You can use new flexible loop, the "DO-LOOP", with two words "UNTIL-WHILE", you can use untile/while with first of the loop "DO" or last of loop "LOOP", it's all just depending on how the logic of the loop you want it to work, it's one of beautiful addition to the logic of the program, they're more simple than remembering how "while-wend" loop works, I can provide you examples and details in "DO-LOOP" if you like.

- "IF-THEN", I think we're usually using a line number to make a branch after the condition is true, we don't have to do this in QBasic, you can enter all statements you like after "THEN" like this and close the "IF" block with "ENDIF" , and you can add "ELSE" or "ELSEIF" for another condition in the same block, simple example:

IF PIZZA = 1 THEN
COMMAND1
COMMAND2
...
ELSE
COMMAND1
COMMAND2
...
ENDIF

- There's additional condition statement but it works depending to the values of one variable as I understood it, it's "SELECT CASE", there's details and examples for it, and it's really so flexible logic, it doesn't need much efforts to understand it, it use blocks too instead of branching with line numbers, but you can use branching with line numbers and you can use too, the calling for your subroutines instead of branching with GOTO.

- You can use line numbers, you can use too labels, they work like line numbers but with more sensible names and it gives the feeling or the form of a block.

label:
command1
command2
command3
goto lablel

- You can use GOTO

Maybe there's more but these points helped much to convert traditional BASIC programs to QBasic and QBasic can run the traditional BASIC programs because it includes same rules.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Sun Sep 01, 2019 5:48 am

rene wrote:
Sat Aug 31, 2019 11:39 pm
pascal111 wrote:
Sat Aug 31, 2019 4:43 am
I found a problem in the text editor to show the same ASCII characters I used to draw the game board

That is due to QB64 by default using the CP437 "codepage" (the basic, US codepage) for both the IDE editor and its output.

Very briefly, ASCII is a 7-bit standard; compromises 2^7=128 characters. The PC used 8-bit characters meaning it had characters 128-255 available for additional characters over ASCII. Only 128 additional characters over ASCII were never enough to satisfy all non-English uses though; users from different language zones (think Nordic, Greek, Cyrillic zones) would load different codepages, different characters 128-255.

CP437 can be viewed here: https://en.wikipedia.org/wiki/Code_page_437 and you can for example see that the left-upper corner box drawing character is 218 in CP437. You can enter that into the QB64 IDE editor by holding down left-Alt, typing 2, 1, 8 and letting go of left-Alt. Same for the other box drawing characters you see there.

These days "codepages" are obsolete; the Unicode character set is a single character set that aims to comprise everything anyone could ever need. It's UTF-8 encoding is what I believe comprises the gobbledegook you pasted in above. I.e., seems something got pasted a few too many times through UTF-8 intermediary state -- or something. In any case, just enter the box drawing characters directly as per previous paragraph.

Interestingly though, the very mention of these "codepages" should really be all that anyone needs to realise that this stuff is truly, decidedly obsolete. Rather than comment further on old BASIC I therefore thought it might be more interesting for you to look at a mode modern implementation of the same game, in this case in Python. I've kept your basic logic; the computer "AI" still just picks a random field.
Good oil! I know at my first times in dealing with computers that the 255 ASCII characters is the alphabet of computers, I think this subject has double faces, the side of characters in programming we experienced before and the side of characters in internet and HTML, the new period.
As to your internal logic there's a change: whereas your computer player picks a random field by looping until it has one which isn't yet occupied, this Python version keeps a count of still available fields --- very useful to declare a draw once it drops to 0 anyway --- and generates a random field only from among those still available ones. The difference of course is that it then generates only one random number per computer turn whereas your version could loop around generating more; could theoretically loop infinitely, if we had been talking about a real rather than pseudo random number generator. It also by the way denotes a field as 1 to 9, internally 0 to 8, rather than (1,1) through (3,3) but while it makes things easier that's not in itself essential; you'll see r(ow) and c(olumn) being taken from that single integer f(ield) in this version as well.

As said, I would not myself find BASIC a very worthy study at this point; thought I'd try and see if you'd consider Python interesting. At least the box drawing characters are now UTF-8 encoded Unicode. Be sure to chmod +x ttt.py before running it as ./ttt.py from the directory it's in.

Code: Select all

#!/usr/bin/python3

from curses import wrapper 
from random import randint
from time import sleep

def main(stdscr):

    board = [None] * 9
    avail = 9

    stdscr.clear()
    stdscr.addstr("┌─────┬─────┬─────┐\n"
                  "│     │     │     │\n"
                  "├─────┼─────┼─────┤\n"
                  "│     │     │     │\n"
                  "├─────┼─────┼─────┤\n"
                  "│     │     │     │\n"
                  "└─────┴─────┴─────┘\n"
                  "\n"
                  "Field (1-9): ")

    while True:

        def move(f, p):
            nonlocal avail

            board[f] = p
            avail -= 1

            r = f // 3
            c = f % 3

            stdscr.addch(1 + 2 * r, 3 + 6 * c, 'x' if p == 0 else 'o')
            stdscr.refresh()
            stdscr.move(8, 0)

            line = [p] * 3
            return board[3 * r : 3 * r + 2 + 1] == line or \
                   [board[i] for i in [c, c + 3, c + 6]] == line or \
                   (f % 4 == 0 and [board[i] for i in [0, 4, 8]] == line) or \
                   (f % 2 == 0 and [board[i] for i in [2, 4, 6]] == line)


        i = randint(1, avail)
        f = 0
        while True:
            if board[f] == None:
                i -= 1
                if i == 0:
                    break
            f += 1

        if move(f, 0):
            stdscr.addstr("The computer has won")
            break

        if avail == 0:
            stdscr.addstr("Draw")
            break

        while True:
            f = stdscr.getch(8, 13) - ord('1')
            if f < 0 or f > 8 or board[f] != None:
                stdscr.addch(8, 13, '!')
                stdscr.refresh()
                sleep(1)
                stdscr.addch(8, 13, ' ')
            else:
                break

        if move(f, 1):
            stdscr.addstr("The player has won")
            break;

    stdscr.addstr(" (press any key to exit)")
    stdscr.refresh()
    stdscr.getkey()


if __name__ == "__main__":
    wrapper(main)
Nice! I tested it and it works, it's my first experience time to try program with Terminal style, it's so similar to traditional DOS programming :)
But I didn't understand the program really because I know no Python but I think it's some close to C++ language.

rene
Level 11
Level 11
Posts: 3627
Joined: Sun Mar 27, 2016 6:58 pm

Re: Fun programs with QBasic 4.5

Post by rene » Sun Sep 01, 2019 11:13 am

pascal111 wrote:
Sun Sep 01, 2019 5:48 am
But I didn't understand the program really because I know no Python but I think it's some close to C++ language.
(note; the just made above "edit" to my previous post was just a silly typo compromises -> comprises; nothing changed)

Certainly Python takes more inspiration from C/C++ than BASIC (although there are newer dialects of BASIC that come closer) but I myself would find "pointers", the lack of them in both BASIC and Python, to have Python in fact closer to BASIC. Or, well, at least for short programs such as the above that don't use object-orientation either.

Having it look rather different from the BASIC version was the idea though. I as said stuck in only one significant logic difference, the "avail" thing; kept your functional logic, although "program logic" has been Pythonized. If you were to now try and lift that one difference from the Python version back into BASIC that'd be one of the best ways to learn: you'd then be concentrating on programming rather than doing so in some specific language. Trust me, the versions may look very different now, but they're really not in a fundamental sense :)

Note that the BASIC program is also "terminal style" as you put it, although I do agree that having a nice graphical IDE available for development can make all the difference for someone starting out (and even though I would not feel that the QB64 IDE fits that description). If you're at all interested in looking more at Python I'd recommend the standard Python IDLE IDE as a minimal one, or PyCharm Community, https://www.jetbrains.com/pycharm/, for a decidedly none-minimal one.

Unfortunately I then also have to immediately comment that the use of "curses" (the text-mode graphics) interferes with IDE's in the sense that running the program still requires an actual terminal. In PyCharm you can set that in Run -> Edit Configurations -> Templates -> Python -> Emulate terminal in output console. In IDLE, just keep a terminal open to in fact run it from...

User avatar
Portreve
Level 7
Level 7
Posts: 1997
Joined: Mon Apr 18, 2011 12:03 am
Location: Florida
Contact:

Re: Fun programs with QBasic 4.5

Post by Portreve » Sun Sep 01, 2019 11:32 am

Dude, I'm not trying to be a programmer. Thanks, but no thanks.
I'm so down wit' dat', yo, dass ich unter dem Beton bin.

Presently rocking LinuxMint 19.2 Cinnamon.

Remember to mark your fixed problem [SOLVED].

All in all, you're just another brick in the wall.

User avatar
pascal111
Level 3
Level 3
Posts: 180
Joined: Wed Mar 06, 2019 4:09 pm

Re: Fun programs with QBasic 4.5

Post by pascal111 » Sun Sep 01, 2019 11:56 am

rene wrote:
Sun Sep 01, 2019 11:13 am
pascal111 wrote:
Sun Sep 01, 2019 5:48 am
But I didn't understand the program really because I know no Python but I think it's some close to C++ language.
(note; the just made above "edit" to my previous post was just a silly typo compromises -> comprises; nothing changed)

Certainly Python takes more inspiration from C/C++ than BASIC (although there are newer dialects of BASIC that come closer) but I myself would find "pointers", the lack of them in both BASIC and Python, to have Python in fact closer to BASIC. Or, well, at least for short programs such as the above that don't use object-orientation either.

Having it look rather different from the BASIC version was the idea though. I as said stuck in only one significant logic difference, the "avail" thing; kept your functional logic, although "program logic" has been Pythonized. If you were to now try and lift that one difference from the Python version back into BASIC that'd be one of the best ways to learn: you'd then be concentrating on programming rather than doing so in some specific language. Trust me, the versions may look very different now, but they're really not in a fundamental sense :)

Note that the BASIC program is also "terminal style" as you put it, although I do agree that having a nice graphical IDE available for development can make all the difference for someone starting out (and even though I would not feel that the QB64 IDE fits that description). If you're at all interested in looking more at Python I'd recommend the standard Python IDLE IDE as a minimal one, or PyCharm Community, https://www.jetbrains.com/pycharm/, for a decidedly none-minimal one.

Unfortunately I then also have to immediately comment that the use of "curses" (the text-mode graphics) interferes with IDE's in the sense that running the program still requires an actual terminal. In PyCharm you can set that in Run -> Edit Configurations -> Templates -> Python -> Emulate terminal in output console. In IDLE, just keep a terminal open to in fact run it from...
I'll think in Python one day, maybe after becoming so familiar with programming world and this's what I'm doing with the positive programming like that under DOS, but yes, to be someone in programming market and make programs that users seek and pay for I need to learn the modern negative visual programming languages.

Post Reply

Return to “Open chat”