Jump to content
Sign in to follow this  
jbs30000

Minor request for the next version of bB

Recommended Posts

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 by jbs30000

Share this post


Link to post
Share on other sites
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 by Random Terrain

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 by Random Terrain

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thanks SeaGtGruff. I totally misread what was posted. I read his def as dim. And I looked at it more than once. :dunce:

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...