This is kind of dumb but..

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
Konamix
Newbie
Posts: 1
Joined: Mon Aug 22, 2005 10:06 pm
Location: Texas

This is kind of dumb but..

Post 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.
tweaks

Re: This is kind of dumb but..

Post 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
tweaks

Re: This is kind of dumb but..

Post 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
Rattrapmax6
Veteran
Posts: 1055
Joined: Sun Jan 02, 2005 2:11 pm
Location: At my computer
Contact:

Re: This is kind of dumb but..

Post 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:
-Kevin (aka:Rattra)
(x.t.r.GRAPHICS)
Post Reply