Hey, I was shortening a Basic program the other day and I was wondering whether you could perhaps use parentheses (or something like it?) in If statements to preserve memory.

Example:
If A=B and (A=C or A=D)
Commands

In this scenario the statement would always need A to equal B to run, but also needs at least one of the parameters in the parentheses to be true as well. Nesting this sort of If statement could exponentially decrease memory usage. Is this at all possible, or is there another way to do this? Or am I being completely oblivious to something obvious?
Thanks. Good Idea

Code:
If A=B and max(A={C,D

Probably better?
The only thing that matters for an If statement is that you provide an expression which evaluates to a real numeric value, and anything other than 0 is truth.
PT_ wrote:

Code:
If A=B and max(A={C,D

Probably better?

Thanks m80
Only issue is it only refers to the largest of the two values. If the smaller value was equal to A, the statement would run incorrectly.
thanks.
PT_ wrote:

Code:
If A=B and max(A={C,D

Probably better?


That only saves one byte, and it slows down the program a little. It's not always worth the tradeoff.

I can't think of anything better.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement