Sprybug Posted May 10, 2018 Share Posted May 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
TheMajorHavoc Posted May 10, 2018 Share Posted May 10, 2018 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 Quote Link to comment Share on other sites More sharing options...
TheMajorHavoc Posted May 10, 2018 Share Posted May 10, 2018 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! Quote Link to comment Share on other sites More sharing options...
+Karl G Posted May 10, 2018 Share Posted May 10, 2018 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. Quote Link to comment Share on other sites More sharing options...
Sprybug Posted May 11, 2018 Author Share Posted May 11, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
bogax Posted May 11, 2018 Share Posted May 11, 2018 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 Quote Link to comment Share on other sites More sharing options...
Sprybug Posted May 13, 2018 Author Share Posted May 13, 2018 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. 1 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.