jbs30000 Posted July 31, 2010 Share Posted July 31, 2010 (edited) I can't use a constant with a bit variable. For instance, if I used: def MyVar=a{0} const One=1 I could do MyVar=1 but not MyVar=One. If I tried the second one the compiler would give me an error. If it's possible it would be nice to be able to use constants with bit defs. Thank you. Edited July 31, 2010 by jbs30000 Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted July 31, 2010 Share Posted July 31, 2010 (edited) def MyVar=a{0} You can't do that. Scroll down to the bad examples: http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit Update: Misunderstood. Thought he was using dim, not def. Edited August 12, 2010 by Random Terrain Quote Link to comment Share on other sites More sharing options...
jbs30000 Posted July 31, 2010 Author Share Posted July 31, 2010 def MyVar=a{0} You can't do that. Scroll down to the bad examples: http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#bit Actually you can do that. I've done it a few times. It works. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted July 31, 2010 Share Posted July 31, 2010 (edited) Actually you can do that. I've done it a few times. It works. What's the point of doing it, even if you can get away with it? It's not like you can assign a specific alias that only works for that bit. You can do this: dim Hero_Shot = a dim Hero_Thrust = a dim Hero_Crash = a dim Hero_Shield = a dim Enemy_Shot = a dim Enemy_Thrust = a dim Enemy_Crash = a dim Enemy_Shield = a Hero_Shot{0} = 0 Hero_Thrust{1} = 0 Hero_Crash{2} = 1 Hero_Shield{3} = 0 Enemy_Shot{4} = 0 Enemy_Thrust{5} = 0 Enemy_Crash{6} = 0 Enemy_Shield{7} = 0 Update: Misunderstood. Thought he was using dim, not def. Edited August 12, 2010 by Random Terrain Quote Link to comment Share on other sites More sharing options...
+Gemintronic Posted July 31, 2010 Share Posted July 31, 2010 If constants get stable one could do: const won_game = 0 const has_chalice = 1 dim boolean = a if boolean{has_chalice} gosub way_sandwhich Sadly I still don't have any really good reproducable patterns for my constant use crashes. Quote Link to comment Share on other sites More sharing options...
jbs30000 Posted July 31, 2010 Author Share Posted July 31, 2010 Actually you can do that. I've done it a few times. It works. What's the point of doing it, even if you can get away with it? It's not like you can assign a specific alias that only works for that bit. You can do this: dim Hero_Shot = a dim Hero_Thrust = a dim Hero_Crash = a dim Hero_Shield = a dim Enemy_Shot = a dim Enemy_Thrust = a dim Enemy_Crash = a dim Enemy_Shield = a Hero_Shot{0} = 0 Hero_Thrust{1} = 0 Hero_Crash{2} = 1 Hero_Shield{3} = 0 Enemy_Shot{4} = 0 Enemy_Thrust{5} = 0 Enemy_Crash{6} = 0 Enemy_Shield{7} = 0 The point is that it already exists. And there is no right or wrong way to do it. If you want to do it your way, cool. I like the other way. No big deal. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted July 31, 2010 Share Posted July 31, 2010 (edited) The point is that it already exists. And there is no right or wrong way to do it. If you want to do it your way, cool. I like the other way. No big deal. I'm just reporting what has been posted in the forums. If batari updates bB and cleans up various bugs and things, your way will probably stop working, so it will be the wrong way. If you don't want to go back and redo your programs, you might want to stick with the recommended way because that will always work. Update: Misunderstood. Thought he was using dim, not def. Edited August 12, 2010 by Random Terrain Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted July 31, 2010 Share Posted July 31, 2010 Actually you can do that. I've done it a few times. It works. What's the point of doing it, even if you can get away with it? It's not like you can assign a specific alias that only works for that bit. The "def" statement is like the "dim" statement, but it lets you define an entire string and assign it to a logical name. So if you use "def" to assign "a{0}" to "MyVar," then everywhere batari Basic sees "MyVar" in your program, it will replace it with "a{0}." In other words, "def" *does* let you assign a specific alias that works only for that bit. Of course, the other restrictions and rules still apply, so you have to check it with "if MyVar then," or "if !MyVar then," instead of using "if MyVar=0 then," or "if MyVar=1 then." The "def" statement also works with math, such as "def MyVar=a+b-c." Everywhere batari Basic sees "MyVar," it will replace it with "a+b-c." But it shouldn't be confused with a function, because it's just doing a "search and replace" in the code, not calling a function. So it can help make your code more readable and concise, but it doesn't save any bytes or cycles. batari posted a brief description of the "def" statement a while back, along with information about "callmacro" and a few other statements. Michael Quote Link to comment Share on other sites More sharing options...
jbs30000 Posted July 31, 2010 Author Share Posted July 31, 2010 Thank you SeaGtGruff you just helped me out a lot. Instead of using const I can just use def to assign numbers to variables and it works. def MyVar=a{0}* def One=1* MyVar=One* *Just an example obviously. Quote Link to comment Share on other sites More sharing options...
+Random Terrain Posted August 1, 2010 Share Posted August 1, 2010 Thanks SeaGtGruff. I totally misread what was posted. I read his def as dim. And I looked at it more than once. 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.