Jump to content

Photo

Weird compiling error with a defined bit in a conditional statement


6 replies to this topic

#1 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • 562 posts

Posted Thu May 10, 2018 3:15 AM

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.
 
 
 
 
 

 



#2 TheMajorHavoc OFFLINE  

TheMajorHavoc

    Space Invader

  • 41 posts
  • Location:Louisiana

Posted Thu May 10, 2018 4:30 AM

 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



#3 TheMajorHavoc OFFLINE  

TheMajorHavoc

    Space Invader

  • 41 posts
  • Location:Louisiana

Posted Thu May 10, 2018 4:34 AM

 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!



#4 kdgarris OFFLINE  

kdgarris

    Moonsweeper

  • 292 posts

Posted Thu May 10, 2018 4:55 AM

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.

#5 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • Topic Starter
  • 562 posts

Posted Fri May 11, 2018 3:53 AM

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.



#6 bogax OFFLINE  

bogax

    Dragonstomper

  • 758 posts

Posted Fri May 11, 2018 4:52 PM

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
 


#7 Sprybug OFFLINE  

Sprybug

    Dragonstomper

  • Topic Starter
  • 562 posts

Posted Sun May 13, 2018 1:49 AM

 

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.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users