New To ComputerForums Saying Hello With A Script.

Chamblin

Baseband Member
Messages
34
Hello everyone, Im new to the computer forums and new to scripting. I've just started Basic programming in my computers class. I was messing around and wrote this little code just to get my fingers wet and to start learning the fundamentals of coding and such. I know its not much but Im just learning so look at my code please and tell me what you think?

COLOR 2, 0
CLS

DIM color1 AS STRING
DIM white AS STRING
DIM background AS STRING
DIM black AS STRING
DIM dakota AS STRING
DIM animal AS STRING
DIM math AS STRING




PRINT "Hello"
SLEEP 1

PRINT "We Are Going To Do A Quiz"
SLEEP 1
PRINT "Lets See How Many Questions You Can Get Right Out Of 5."
SLEEP 2

PRINT "Here We Go."
SLEEP 1
CLS


Question1:
PRINT ""
INPUT "What Is The Color Of A White Sword"; color1
IF color1 = "white" THEN
PRINT "Very Good Question 1 of 5 Correct."
SLEEP 2
ELSE
PRINT "Sorry Try Again"
SLEEP 2
GOTO Question1:
END IF
PRINT ""
Question2:
PRINT "Question 2"
INPUT "What Color Is The Background On This Screen"; background
IF background = "black" THEN
SLEEP 2
PRINT "Very Good Question 2 of 5 Correct."
ELSE
SLEEP 2
PRINT "Sorry Go Back To Question 1"
GOTO Question1:
END IF
PRINT ""

Question3:
PRINT "Question 3"
SLEEP 1
INPUT "Who Was President When World War 2 Started"; dakota
SELECT CASE dakota$
CASE "franklin d roosevelt"
PRINT "Right Again Question 3 of 5 Correct."
SLEEP 2
CASE "fdr"
PRINT "Right Again Question 3 of 5 Correct."
SLEEP 2
CASE "franklindroosevelt"
PRINT "Right Again Question 3 of 5 Correct."
SLEEP 2
CASE ELSE
PRINT "Wrong Answer Back To Question 1"
GOTO Question1:
END SELECT

PRINT ""


Question4:
PRINT "Question 4"
SLEEP 1
INPUT "What Is The Fastest Animal In The World"; animal
IF animal = "cheetah" THEN
SLEEP 1
PRINT "Good Job Question 4 of 5 Correct."
ELSE
SLEEP 1
PRINT "Sorry Try Again"
GOTO Question1
END IF

PRINT ""

Question5:
PRINT "Question 5"
SLEEP 1

INPUT "If You Have 1000 Dollars And You Add 40 To it. Now Add Another 1000. Now add 30 Plus Another 1000. Now Add 20. Now add Another 1000. Now Add 10 How Much Do You Have."; math
IF math = "4100" THEN
PRINT ""
PRINT "Congradulations You Completed The Test."
ELSE PRINT "Sorry Go Back To Question 1"
GOTO Question1:
END IF
SLEEP
 
I suppose you have the thinkings / ideas around what you want to do.. Its ok to start with! Just a few little general pointers, to help it read better, try spacing your code out on each line, this also helps when you go back and check for errors in your code. E.G:


Question3:
PRINT "Question 3"
...SLEEP 1
.....INPUT "Who Was President When World War 2 Started"; dakota
.......SELECT CASE dakota$
......CASE "franklin d roosevelt"
....PRINT "Right Again Question 3 of 5 Correct."
...SLEEP 2
.....CASE "fdr"
.......PRINT "Right Again Question 3 of 5 Correct."
...SLEEP 2
.....CASE "franklindroosevelt"
.......PRINT "Right Again Question 3 of 5 Correct."
...SLEEP 2
CASE ELSE
...PRINT "Wrong Answer Back To Question 1"
GOTO Question1:
END SELECT

PRINT ""


This isnt a great example (take out the dots with spaces) - but now you can clearly see the 'bits inbetween' the 'sleep' sections. It makes it so you can find parts of your code easier and edit them easier. Two other points, I would have a read up about Wildcards symbols, if you are asking people to enter text / answers, and also consider reading up about adding comments to your code, especially if it starts to get much longer.

Please use
Code:
 tags. [/QUOTE] The above poster means when you are putting code, wrap it in a [CODE] Code
tag so its a little easier for us to see - you can see proper spacing - and also complies with the forum posting rules :)
 
Back
Top Bottom