for any beginners
BlitzPlus Forums/BlitzPlus Beginners Area/for any beginners
| ||
. |
| ||
so, I was just fiddling around with the code that I know(I know close to nothing) and decided to create a question program from the specks that I do know. any advice, because I get a 'endif' message when I try to run it. for any of you programming extremists/trolls/and grammar nazi's, be gentle. |
| ||
name$=Input$["What is your name?"] If name$="Aaron" Then Print"Hello Aaron,what would you like to do today?" Else Print "Sorry, you are not accepted here." EndIf answer$=Input$["_____"] If answer$= "Learn" Then Print "what is 1+1?" If answer$="2" Then Print "What is the square root of 625?" Else Print "wrong" EndIf If answer$= "25" Then Print "What is PI?" If answer$= "3.14159265" Then Print "What is e?" Else Print "wrong" EndIf If answer$= "an irrational number" Then Print "What is mass?" If answer$= "the ammount of matter in an object"Then Else Print "wrong" EndIf Print "What year were the Moors expelled from Spain? If answer$= "1492" Then Print "What is yeast?" Else Print "wrong" EndIf If answer$= "a fungus"Then Print "what is your middle name?" Else Print "wrong" EndIf If answer$= "E.D." Then Else Print "wrong" EndIf Print "Good, Learning is complete." Then If answer$= "Close Program" Then Print "done" EndIf End |
| ||
If you indent your code these kind of problems jump out and become obvious. you can use the forum codes (code) blah (/code) (but using square brackets in place of the round ones) around your code to better display it on the forum. like this |
| ||
thx very much! |
| ||
name$=Input$["What is your name?"] If name$="Aaron" Then Print"Hello Aaron,what would you like to do today?" Else Print "Sorry, you are not accepted here." End If answer$=Input$["_____"] If answer$= "Learn" Then Print "what is 1+1?" If answer$="2" Then Print "What is the square root of 625?" Else Print "wrong" End If If answer$= "25" Then Print "What is PI?" If answer$= "3.14159265" Then Print "What is e?" Else Print "wrong" End If If answer$= "an irrational number" Then Print "What is mass?" If answer$= "the ammount of matter in an object"Then Else Print "wrong" End If Print "What year were the Moors expelled from Spain? If answer$= "1492" Then Print "What is yeast?" Else Print "wrong" End If If answer$= "a fungus"Then Print "what is your middle name?" Else Print "wrong" End If If answer$= "Emmanuel Diaz" Then Else Print "wrong" End If Print "Good, Learning is complete." Then If answer$= "Close Program" Then Print "done" End If End |
| ||
is that better? i think i'm also associating BASIC with HTML for some reason. Don't ask |
| ||
Not sure- unless you put it in a code box, your formatting doesn't display properly. I mean indentation using the tab button. If you tab things properly it makes it easy to identify if/end if and for/next pairs. e.g.name$=Input$["What is your name?"] If name$="Aaron" Then Print"Hello Aaron,what would you like to do today?" Else Print "Sorry, you are not accepted here." End If answer$=Input$["_____"] |
| ||
name$=Input$("What is your name?") If name$="Aaron" Then Print "What would you like to do Aaron?" End If |
| ||
so square 1, that works, but I want to add on |
| ||
Do you know what "indent your code" actually means? Bad code: If something If somethingelse doStuff() EndIf EndIf Indented code: If something If somethingelse doStuff() EndIf EndIf In the latter case, it is much easier to see where the Ifs match up with the EndIfs. |
| ||
To use code boxes and other formatting in your forum posts, you need to write special tags and put text between them: http://blitzbasic.com/faq/faq_entry.php?id=2 When the code is small, you can use the 'code' tag. When it's very long, more than one screen height, you should use the 'codebox' tag since it keeps things contained in a box with sliders. You can click the Preview button at the bottom of this page to preview your post to make sure the tags are working correctly. |