yuppicide Posted July 31, 2008 Share Posted July 31, 2008 (edited) First, DIM: I don't really need things like DIM backframe=a Does it take up more room or the same if I add that dim and do backframe=backframe+1 as opposed to just doing a=a+1? Second, RAND: I read up on doing something like a=rand What I need is a random number between 4 and 27. How exactly do I? Is something like this possible? loop a = rand if a>27 and a<4 then goto loop if a<27 and a>4 then goto loop2 Will that slow things down too much because it might keep picking numbers out of my range randomizing over and over and over? Going to bed now. Thanks again. I've really learned a lot today and feel very accomplished. Edited July 31, 2008 by yuppicide Quote Link to comment Share on other sites More sharing options...
jwierer Posted July 31, 2008 Share Posted July 31, 2008 (edited) First, DIM: I don't really need things like DIM backframe=a Does it take up more room or the same if I add that dim and do backframe=backframe+1 as opposed to just doing a=a+1? Second, RAND: I read up on doing something like a=rand What I need is a random number between 4 and 27. How exactly do I? Is something like this possible? loop a = and if a>27 and a<4 then goto loop if a<27 and a>4 then goto loop2 Will that slow things down too much because it might keep picking numbers out of my range randomizing over and over and over? Going to bed now. Thanks again. I've really learned a lot today and feel very accomplished. RAND will generate a number from 0 to 255 (decimal) or 00000000 to 11111111 (binary). If you do a logical AND with 11111000 (31 decimal) you'll get a number from 0 to 31 which should reduce the chances of getting a number outside of your desired range. -Jeff Edited July 31, 2008 by jwierer Quote Link to comment Share on other sites More sharing options...
yuppicide Posted July 31, 2008 Author Share Posted July 31, 2008 Thanks. I should have just kept my RAND questions in my other post. What Impaler said in there solved my problem. Quote Link to comment Share on other sites More sharing options...
CurtisP Posted August 3, 2008 Share Posted August 3, 2008 First, DIM: I don't really need things like DIM backframe=a Does it take up more room or the same if I add that dim and do backframe=backframe+1 as opposed to just doing a=a+1? DIM does not actually define a new variable, it just creates an alias for an existing variable. So, backframe and a will point to the same location. This means that a=a+1 backframe=backframe+1 a=backframe+1 backframe=a+1 will all generate identical assembly code. For me, DIMing variables to logical names is a lot easier than having to lookup what variable r is evertime. The only possible disadvantage to DIMming variables is that it will make the Symbol table larger in the ASM file, but this should not be a problem. Quote Link to comment Share on other sites More sharing options...
SeaGtGruff Posted August 3, 2008 Share Posted August 3, 2008 The only possible disadvantage to DIMming variables is that it will make the Symbol table larger in the ASM file, but this should not be a problem. There's another possible disadvantage, which is that the new variable names will be longer than 1 character, which can make a difference if you're trying to squeeze a lot of bB statements onto a single line-- e.g., in the "then" section of an "if" statement. Of course, this isn't much of a problem, because you can squeeze a lot of characters onto a line (I'm not sure what the limit is in bB v1.0), but you might want to keep your variable names on the shorter side-- even though you can create more self-explanatory names by using longer variable names. Michael 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.