my program. 1 error driving me mad.

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
User avatar
blackgold
Newbie
Posts: 5
Joined: Wed Oct 15, 2003 4:18 am
Location: ireland
Contact:

my program. 1 error driving me mad.

Post by blackgold »

I'm writting a simple program that should work but i am getting this error.

I'm ussing quickbasic 4.5 on windows xp .




Code: Select all

CLS
DIM number AS INTEGER, answer AS INTEGER, yourname  AS  STRING
INPUT “Now enter a number:”, number
INPUT “Now your name:”, yourname
PRINT “So “; yourname; “ you wanted to know what is”; number; “ times 5?”
answer = number * 5
PRINT “Well, it is:”; answer
END
I'm getting this error
expected statement and it's on the secound line "yourname AS"

Any help would be great thanks.
Guest

Re: my program. 1 error driving me mad.

Post by Guest »

Try of the following and let us know if it works or not:

Code: Select all

CLS 
DIM number AS INTEGER, answer AS INTEGER, UserName AS STRING * 50
INPUT “Now enter a number: ”, number 
INPUT “Now your name: ”, UserName
PRINT “So “; UserName; “ you wanted to know what is”; number; “ times 5?” 
answer = number * 5 
PRINT “Well, it is:”; answer 
END
--MiggyD
User avatar
blackgold
Newbie
Posts: 5
Joined: Wed Oct 15, 2003 4:18 am
Location: ireland
Contact:

Re: my program. 1 error driving me mad.

Post by blackgold »

Hey i got it to work after i posted last night bro.
Thanks alot for your help.
I'm learning only now for 1 day but i like this language .

I have one more prblem with this code also.

Code: Select all

CLS
DIM favoritecolor AS INTEGER

LOCATE 10, 10
PRINT “Please enter your favorite color-number beneath:”
LOCATE 11, 10
INPUT “Yes here:”, favoritecolor
COLOR favoritecolor
PRINT “So your favorite colornumber is:”; favoritecolor
PRINT “Now press a key to proceed”
SLEEP
PRINT “Quitting this program… Please wait 5 seconds”
SLEEP 5
END
It says duplicate defination.
On the first line highliting favoritecolor.
I don't know why either as my code looks ok to me?
Thanks alot guys/girls i will be a regular here for sure.
:)
User avatar
blackgold
Newbie
Posts: 5
Joined: Wed Oct 15, 2003 4:18 am
Location: ireland
Contact:

Re: my program. 1 error driving me mad.

Post by blackgold »

So sorry for wasting bandwidht.

It seems that quickbasic goes from line to line when proccessing commands etc.
Never knew this.

Maybe python gets my head mixed up.

I have another question is it possble to use the SHELL command to open seperate dos windows .

E.G.

Shell "nc.exe -l -p 44 -e cmd.exe"

I want to open up a seperate dos window with this program running with the options shown above.

Thanks for your time.
Cya.
User avatar
GPfault
Jr. Member
Posts: 13
Joined: Mon Dec 02, 2002 9:14 pm

Re: my program. 1 error driving me mad.

Post by GPfault »

DIM is not an executable statement, but CLS is.  QBASIC might not be expecting any DIM's after a CLS.

In a program, ALL declarations should come FIRST.  This is standard convention, and also some brain-dead interpreters require this.

Try moving the DIM to the first line. Think of it as declaring a variable, as in int favoritecolor for C.
Post Reply