Odd Statement?
Blitz3D Forums/Blitz3D Beginners Area/Odd Statement?
| ||
Well, ive never seen this type of statement done before, but it apparently works. Why havnt I seen it used before? Ive been using BB for quite a while now (over 6 months). If (Direction%>-15 And Direction%<15 And Distance%<=96) Or Distance%<=64 |
| ||
Um, what are you saying? You've never seen an IF statement used before? BOY ARE YOU IN FOR A TREAT! just kidding. What part haven't you seen? the use of parentheses? the use of boolean operators (AND and OR)? the use of floating point variables (as opposed to integer variables)? the use of all of the above at once in an IF statement? Yes, this is entirely possible and you can make it extremely more complex if you desire. |
| ||
I think he just doesn't know you can put parenthesis around booleans. Or that you can use booleans like that. Booleans and = statements are operators just like +-*/. |
| ||
I never seen an if statement using brackets and with that complexity :P Funny thing is, I made the first state ive seen like that! lol |
| ||
Keep this in mind though: Every argument of the IF statement will be evaluated when the IF statement is executed SO if one of the arguments normally takes a long time to execute (ex. LinePick) then you may want to place it on a seperate line so that it only is evaluated if the other (faster executing) arguments are true. This: If (Direction%>-15 And Direction%<15 And Distance%<=96) And LinePick(x#,y#,z#,dx#,dy#,dz#) = SomeEntity ;do something EndIfcould be written like this: If (Direction%>-15 And Direction%<15 And Distance%<=96) If LinePick(x#,y#,z#,dx#,dy#,dz#) = SomeEntity ;do something EndIf EndIfto speed up execution. If the first part isn't True, the LinePick command won't be executed. |