Page 1 of 1

This is kind of dumb but..

Posted: Mon Aug 22, 2005 10:12 pm
by Konamix
I am experienced in the DM programming language, and now wish to learn QBASIC. I know some, and what I do not understand is quite simple..yet to hard!

Code: Select all

CLS
TYPE Player
 Name$ = ""
 Score AS INTEGER
END TYPE
PRINT "Welcome to Guess or Die!"
PLAY "ABA"
INPUT "Please enter your name"; Player.Name$
BEEP
PRINT "First Question..What is 1+1?", Question1%
IF Question1% = 2 THEN
 PRINT "Correct! 10 Points."
 Player.Score 10
What I am trying do to is basicly add 10 points to the players score.

Re: This is kind of dumb but..

Posted: Tue Aug 23, 2005 1:26 am
by tweaks
Konamix wrote:I am experienced in the DM programming language, and now wish to learn QBASIC. I know some, and what I do not understand is quite simple..yet to hard!

Code: Select all

CLS
TYPE Player
 Name$ = ""
 Score AS INTEGER
END TYPE
PRINT "Welcome to Guess or Die!"
PLAY "ABA"
INPUT "Please enter your name"; Player.Name$
BEEP
PRINT "First Question..What is 1+1?", Question1%
IF Question1% = 2 THEN
 PRINT "Correct! 10 Points."
 Player.Score 10
What I am trying do to is basicly add 10 points to the players score.

player.score = player.score + 10

Re: This is kind of dumb but..

Posted: Tue Aug 23, 2005 1:30 am
by tweaks
Konamix wrote:I am experienced in the DM programming language, and now wish to learn QBASIC. I know some, and what I do not understand is quite simple..yet to hard!

Code: Select all

CLS
TYPE Player
 Name$ = ""
 Score AS INTEGER
END TYPE
PRINT "Welcome to Guess or Die!"
PLAY "ABA"
INPUT "Please enter your name"; Player.Name$
BEEP
PRINT "First Question..What is 1+1?", Question1%
IF Question1% = 2 THEN
 PRINT "Correct! 10 Points."
 Player.Score 10
What I am trying do to is basicly add 10 points to the players score.
i think you also must do this:

after END TYPE

you must put

DIM play AS player

then player.score is really written play.score...

play could be any label you want that was just an exmaple

Re: This is kind of dumb but..

Posted: Tue Aug 23, 2005 12:56 pm
by Rattrapmax6

Code: Select all

CLS
TYPE Player
    Name AS STRING '<---
    Score AS INTEGER
END TYPE

DIM Plyr AS Player '<---

PRINT "Welcome to Guess or Die!"
PLAY "ABA"
INPUT "Please enter your name"; Plyr.Name '<---
BEEP

PRINT "First Question..What is 1+1?", Question1%

IF Question1% = 2 THEN
    PRINT "Correct! 10 Points."
    Plyr.Score = Plyr.Score + 10 '<---
END IF '<---
Going by and adding up what the others pointed out, all the new or changed stuff in this code is marked with '<---...

Also, Name$ = "" should be Name AS STRING,.. And when you have a IF block, you need to end it with END IF... And you can't use Play as a lable sence play is a Statement, so that needs to be Plyr or something else...

:wink: