Jump to content
tdp

Boolean operator syntax error

Recommended Posts

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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
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 by bogax

Share this post


Link to post
Share on other sites

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 by tdp

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Hello Random - what do you mean by temporary variables? Will need to hit the docs again to learn more.

Edited by tdp

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...