Jump to content
IGNORED

Weird compiling error with a defined bit in a conditional statement


Sprybug

Recommended Posts

Hey guys, as you know I'm working on Robot Zed and decided to use DIMs and DEFs to help keep my code readable and keep my sanity, however I came across something weird.

 

I dim'd all my variables with names, and for bits, I used DEF like you are supposed to.

 

For example I have:

dim Extra_Bits = g

 

Then I have underneath all my dims:

def Enemy_Direction = Extra_Bits{0}
def Ball_Direction = Extra_Bits{1}
def Missile_Direction = Extra_Bits{2}
def Section_Exit = Extra_Bits{3}
def Section_Order = Extra_Bits{4}
def Genesis_Controller = Extra_Bits{7}
Now this is fine, however in a conditional check on one of these it would error on compile.
The line before it is fine:
if Section_Order && Level_Section=6 then Level_Section=0:goto LS2
But the line after it gives me a compile error without a reason
if !Section_Order && !Level_Section then Level_Section=6:goto LS2
I tried changing it to: if Section_Order=0 && Level_Section=0 and it still error'd on compile.
So, I tried changing Section_Order in this line to Extra_Bits{4} and it compiled no problem, so now that line is:
if !Extra_Bits{4} && !Level_Section then Level_Section=6:goto LS2
That's fine apparently. So, is there a bug here in the compiler? I can't see any reason why this would happen.

 

  • Like 2
Link to comment
Share on other sites

Try leaving out the "def"

I always get invalid keyword errors reported when I have have bits dim'd, but compiles ok.

 

This works for me:

 

dim animplayer1 = var18

dim animplayer2 = var18

 

animplayer1{1} = 0

animplayer2{2}=0

Oh , had to re-read your post again. you are wanting to use def . sorry Sprybug!

Link to comment
Share on other sites

What compile error did you get specifically?

 

RT has a note about running into odd problems using different defs, so I have a them. Instead, you can put the number of the intended bit in the dim statement as a way to remember, e.g.:

 

dim Enemy_Direction_Bit1 = g

dim Ball_Direction_Bit2 = g

(etc)

 

It's not as clean as a def, but it works.

Link to comment
Share on other sites

Thanks guys for the heads up. I might just keep it the way it is for now then. It should work logically, but making it a not bit check (or just a check for 0) for some reason causes it to not know what to do. It would come back with a Syntax Error on that line and would show me the entire compiled code without indication there what went wrong. That's about all I can really tell you.

  • Like 1
Link to comment
Share on other sites

this compiles

 

 

 
 dim Level_Section = z
 
 dim Extra_Bits = g
 
 dim abcdefg = g
 
 def Enemy_Direction = Extra_Bits{0}
 def Ball_Direction = Extra_Bits{1}
 def Missile_Direction = Extra_Bits{2}
 def Section_Exit = Extra_Bits{3}
 def Section_Order = Extra_Bits{4}
 def !SectionOrder = !Extra_Bits{4}
 def am = a{4}
 
 if !Level_Section && !Section_Order then Level_Section=6:goto LS2
 
 if !SectionOrder && !Level_Section then Level_Section=6:goto LS2
 
 
 
 
LS2
 
Link to comment
Share on other sites

 

this compiles

 
 dim Level_Section = z
 
 dim Extra_Bits = g
 
 dim abcdefg = g
 
 def Enemy_Direction = Extra_Bits{0}
 def Ball_Direction = Extra_Bits{1}
 def Missile_Direction = Extra_Bits{2}
 def Section_Exit = Extra_Bits{3}
 def Section_Order = Extra_Bits{4}
 def !SectionOrder = !Extra_Bits{4}
 def am = a{4}
 
 if !Level_Section && !Section_Order then Level_Section=6:goto LS2
 
 if !SectionOrder && !Level_Section then Level_Section=6:goto LS2
 
 
 
 
LS2
 

I see what you did there! So I have to make defs for both True and false bits on conditional checks? That seems like quite a bit of work.

  • Like 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

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