tdp Posted May 28, 2018 Share Posted May 28, 2018 Hello Guys, I have been using the following without issue:- if x= 49 || x=57 then a=26 But if I use the following, I get a Syntax error:- if x= c-2 || x=c+2 then a=26 I guessing I'm missing something really obvious here, but what have I done wrong. I have checked out http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#boolean, and from what I can see, what I'm doing is good. For what I'm trying to do, it is important that the x value is compared against the result of the c value. The weird thing is that the following compiles without issue:- if x=c+1 then a=14 Is the problem that I'm doing x=c-2 followed by the boolean or? Quote Link to comment Share on other sites More sharing options...
Osgeld Posted May 28, 2018 Share Posted May 28, 2018 (edited) try if x= (c-2) || x=(c+2) then a=26 Edit you need a space tween - and 2 Edited May 28, 2018 by Osgeld Quote Link to comment Share on other sites More sharing options...
tdp Posted May 29, 2018 Author Share Posted May 29, 2018 Thanks for the response Osgeld. Spaces is not the issue:- if x = c - 5 || x = c + 5 then a=28 The above still fails to compile. I also tried:- if x = (c - 5) || x = (c + 5) then a = 28 But still no cigar. Any further ideas? Quote Link to comment Share on other sites More sharing options...
+Lewis2907 Posted May 29, 2018 Share Posted May 29, 2018 tdp, I got this to compile: if x= c-2 then a=26 else if x=c+2 then a=26 I'm not sure if this is what you are looking for, thanks. Quote Link to comment Share on other sites More sharing options...
bogax Posted May 29, 2018 Share Posted May 29, 2018 (edited) This Works if x <> c - 2 && x <> c + 2 then skip a = 26 skip This Works better if c - 2 <> x && c + 2 <> x then skip a = 26 skip Edited May 30, 2018 by bogax Quote Link to comment Share on other sites More sharing options...
tdp Posted May 30, 2018 Author Share Posted May 30, 2018 (edited) Thanks guys. Digging into the RT bBatari docs some more, I can see that OR (||) has more restrictions on it that AND (&&). Case in point:- if player0x = c + 5 && player0y = d + 5 then a=30 The above compiles fine. Now, just swap the operator from AND to OR:- if player0x = c + 5 || player0y = d + 5 then a=30 The above does not compile. Looks like there are stricter restrictions on OR, compared to AND. Still trying stuff. Edited May 30, 2018 by tdp Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 30, 2018 Share Posted May 30, 2018 Earlier versions of bB couldn't use math in if-thens, so we did the math in temporary variables and used those in the if-thens. I still do that to avoid any problems. Quote Link to comment Share on other sites More sharing options...
tdp Posted May 30, 2018 Author Share Posted May 30, 2018 (edited) Hello Random - what do you mean by temporary variables? Will need to hit the docs again to learn more. Edited May 30, 2018 by tdp Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted May 30, 2018 Share Posted May 30, 2018 Hello Random - what do you mean by temporary variables? randomterrain.com/atari-2600-memories-batari-basic-commands.html#temp_variables Example: temp6 = c + 5 : temp5 = d + 5 if player0x = temp6 || player0y = temp5 then a = 30 Quote Link to comment Share on other sites More sharing options...
tdp Posted May 30, 2018 Author Share Posted May 30, 2018 @RT - Awesome stuff. I will try this later. Thank you so much!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.