Page 1 of 1

my program. 1 error driving me mad.

Posted: Wed Oct 15, 2003 8:39 am
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.

Re: my program. 1 error driving me mad.

Posted: Wed Oct 15, 2003 7:35 pm
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

Re: my program. 1 error driving me mad.

Posted: Thu Oct 16, 2003 2:19 am
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.
:)

Re: my program. 1 error driving me mad.

Posted: Thu Oct 16, 2003 2:33 am
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.

Re: my program. 1 error driving me mad.

Posted: Wed Dec 03, 2003 2:34 am
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.