Jump to content
abaudrand

trouble with a segmented variable

Recommended Posts

Hi,

I'm trying to spare variables and started to rewrite my program by using a{0}, a{1}, etc... as most of them are TRUE/FALSE tag.

It worked fine when all variables were a,b,f,i etc... but now, I've just changed them, the compilation go wrong...

I've spent the last two night to scratch my head but can't see whats wrong...

 

Share this post


Link to post
Share on other sites

I have to go out for a few hours. If nobody looks at it by then, I'll see if I can track down the problem when I get back.

Share this post


Link to post
Share on other sites

You can't check the value of a bit variable this way:

  if a{3} = 1 then missile1y=missile1y+1

Instead, you have to do it this way:

  if a{3} then missile1y=missile1y+1

That's to see if the bit is 1, or turned on (a "true" value). To see if the bit is 0, or turned off (a "false" value), use the ! or "not" operator, like this:

  rem * old line
  rem if a{1}=1 && a{2}=0 then missile0x=missile0x+d:missile0y=missile0y+e:goto DoneFire

  rem * corrected line
  if a{1} && !a{2} then missile0x=missile0x+d:missile0y=missile0y+e:goto DoneFire

Michael

Share this post


Link to post
Share on other sites

SeaGtGruff to the rescue! My eyeballs were hurting looking for the syntax error. I didn't even know about that caveat with binary values. I take it

if a{1} = %1 then gosub way_sandwhich

wont work?

Edited by theloon

Share this post


Link to post
Share on other sites

SeaGtGruff to the rescue! My eyeballs were hurting looking for the syntax error. I didn't even know about that caveat with binary values. I take it

if a{1} = %1 then gosub way_sandwhich

wont work?

Correct; it would have to be

  if a{1} then gosub way_sandwhich

Michael

Share this post


Link to post
Share on other sites

SeaGtGruff to the rescue! My eyeballs were hurting looking for the syntax error. I didn't even know about that caveat with binary values. I take it

if a{1} = %1 then gosub way_sandwhich

wont work?

Yeah, the bB page says:

 

http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit

Notice that bit operations do not use an equal sign in if-then statements.

 

Maybe it also needs a Warning message or a Did You Know? message.

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...