Noobie having bad time with Blitz Tutorials!
Blitz3D Forums/Blitz3D Beginners Area/Noobie having bad time with Blitz Tutorials!
| ||
Hi all, I'm having a hard time starting with Blitz 3D. I am completely, brand new to Blitz - last time I did any programming was in AMOS for the Amiga! Here's my problem: I copied and pasted one the first few Basic Tutorials in blitz3D: agecategory$=Input("What is the age restriction 15 or 18? ") ; Asks a moderator to set the age rating for a film age$=Input("What is your age: ") ; Then asks a viewer their age If agecategory$ = 18 And age$< 18 Or agecategory$ = 15 and age$< 15 Then Print "Your are not allowed to view this film - Sorry" ; using AND OR expressions decides if they are too young If agecategory$ = 18 And age$> 18 Or agecategory$ = 15 And age$> 15 Then Print "Enjoy your film." ; Using AND OR expressions decides if they are old enough Waitmouse ; waits for the mouse button to be pressed End ; Once the mouse button has been pressed - Ends the program. So I type in 18 at the first prompt for restriction, then age of 4 at the second prompt - and it prints the "Enjoy your Film" text!!! Why? other ages work, if you type in 18 restriction then 15 as your age, the program doesn't print any message and just hangs waiting for a mouse click???!!! Am I missing something really easy to solve - careful I'm brand new! ;) |
| ||
hi, im also new, but isn't $ for strings? i don't know if this is the probleme, but this works: agecategory$=Input("What is the age restriction 15 or 18? ") age$=Input("What is your age: ") If (agecategory$ = 18 And age< 18) Or (agecategory$ = 15 And age< 15) Then Print "Your are not allowed to view this film - Sorry" Else Print "Enjoy your film." EndIf WaitMouse End |
| ||
ups, sry 18 and 4 is also "Enjoy"....hmmmm |
| ||
Confusing stuff and this comes as the manual for Blitz! :( |
| ||
Yeah, don't you just LOVE the documentation provided :-)? |
| ||
or..agecategory$=Input("What is the age restriction 15 or 18? ") age$=Input("What is your age: ") If age >= agecategory Print "Enjoy your film." else Print "Your are not allowed to view this film - Sorry" endif Waitmouse End Yeah, don't you just LOVE the documentation provided :-)? It's not that bad. I've seen a lot worse. |
| ||
Thanks Rims, but the same thing is still happening. Try it out! Type in 18 as the rating of the film then your age as 4, 5, 6 - Enjoy your film comes up. Me puzzled. |
| ||
For a commercial programming product, I have seen a LOT better, though ;-) if this forum did not exist 90% of all users would be stuck using only the documentation ... |
| ||
Hansie's right, I am the proof! |
| ||
Aha! Rims, your code works, need to take out the $ sign when setting up. Then it works - but why doesn't the tutorial supplied work? I wanna learn! :) |
| ||
Is it because the tutorial is setting up strings and for some reason they are alphabetical only? Or can a < and > function equate to numbers too when you set up a string value? The original code from the tutorial works if you take out all the $! So expect this code to only work if you are using the alphabet? :) Thanks all for your help! Top Forum members and I learned something cool already! agecategory=Input("What is the age restriction on this film 15 or 18? ") ; Asks a moderator to set the age rating for a film age=Input("What is your age: ") ; Then asks a viewer their age If agecategory = 18 And age<18 Or agecategory = 15 and age< 15 Then Print "Your are not allowed to view this film - Sorry" ; using AND OR expressions decides if they are too young If agecategory = 18 And age>18 Or agecategory = 15 And age>15 Then Print "Enjoy your film." ; Using AND OR expressions decides if they are old enough WaitMouse ; waits for the mouse button to be pressed End ; Once the mouse button has been pressed - Ends the program. |
| ||
hey rims, there is only one probleme left, put in 18 and 4 and then cry! ^^ |
| ||
Heheh! Wipe your tears away Rims. It works without strings $ signs! It appears numbers cannot be used in a string in this way and the tutorial is incorrect. Slave, you were correct with your original post - strings will work for the alphabetical analysis of strings only. Nice work! |
| ||
This is what I as a noobie have worked out: when used as strings - 4 is more than the 1 of 18 and this is counted first like alphabetical sorting of strings (smith<smythe). hence typing 2 up to 9 meant a minor could watch texas chainsaw massacre no problem. |
| ||
No, strings cannot be used to store numbers as such. Numbers in strings will be made up of characters. 103="1"+"0"+"3"="103" It's no longer a number, but a string. You can convert this into a number though. Like so: a$="100" number=a$ number will equal 100. But a$="10r5" number=a$ number will equal 10. This is because it converts the string into a number until it reaches a non numeric character. So it stops at "r". Hope that helps some :) |
| ||
Thanks Ross, I figured it out (see post before yours) but this has cemented it now! thanks :) |
| ||
those damned strings. ;) Post here if you have any further probs, we're more than happy to help. |
| ||
Thanks Rims! You guys have been very helpful to a complete noobie! Hope to be posting with you in the more advanced forums in the not too distant future! Cheers all! |
| ||
@ tyler, i still post here :) |
| ||
Hey! Quit your moaning, Go over to www.blitzcoder.com and do yourself a favor and download all of Krylar's Tutorials (Sage page as website complete), then...read 'em!! I'm working through them and they're pretty good. I do have a background in basic so that does help. Don't worry, Krylar has a good variable tutorial too! |
| ||
Krylar's book should be bundled with a copy of Blitz ... |
| ||
Blitzcoder is great! Just checked it out! Thanks Coded. |
| ||
@TylerDurden while you're at it, check these sites out also: http://keyboard.freeshell.org/blitzbasic.html |
| ||
From basic programing we learned that a number written as a string is not the value of the number. It's the value of the ascii position. The string 18 is actually 31 38 hex. You need to use numeric values not strings. |