BBC BASIC for Windows
Programming >> BBC BASIC language >> A quick question-variables
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1355761968

A quick question-variables
Post by Bailey on Dec 17th, 2012, 3:32pm

How do i add a word as a variable?
I thought it was like this....
name$=james
PRINT"welcome";name

what am I doing wrong?

Thanks James
Re: A quick question-variables
Post by admin on Dec 17th, 2012, 3:41pm

on Dec 17th, 2012, 3:32pm, Bailey wrote:
name$=james
PRINT"welcome";name

Did you mean this:

Code:
name$="James"
PRINT "Welcome ";name$ 

Richard.

Re: A quick question-variables
Post by Bailey on Dec 17th, 2012, 3:55pm

Yes I did and thank you soo much :)

If i was a name style password thing
so you type the correct name and get to continue what do i do Something like this ?
Code:
name$="james"
PRINT "Welcome user what is your name?"
INPUT A
IF A=james 
GOTO
7
ELSE
END 
7
PRINT "CONTINUE" 


Thanks for the quick reply with my last post Just trying to get the hang of BBC :) !

Re: A quick question-variables
Post by admin on Dec 17th, 2012, 4:43pm

on Dec 17th, 2012, 3:55pm, Bailey wrote:
INPUT A
IF A=james

Unlike some other BASICs, BBC BASIC requires string variables always to end with a $, so:

Code:
INPUT A$
IF A$="james" THEN 

or

Code:
INPUT A$
IF A$=name$ THEN 

I would suggest that you spend some time working through the Beginners' Tutorial before you pick up too many bad habits (like using GOTO!):

http://www.bbcbasic.co.uk/bbcwin/tutorial/

Richard.
Re: A quick question-variables
Post by Bailey on Dec 17th, 2012, 5:25pm

Lol will do smiley Thanks
Was on the guide when I got confused with the Variable and didnt want to keep going untill i understood all aspects just thought i would kill two birds with one stone ! smiley Thanks Again you have been a real help smiley ! No wonder my school has BCC !!