3 variables

armagon29

New Member
Dear All:

I need to join tree variables and become in a single variable example:

b0= 2 + b1=1 + b2=5 new variable = w215

b0= 0 + b1=5 + b2=3 new variable = w053

b0= 3 + b1=0 + b2=8 new variable = w308

Thanks
 

premelec

Senior Member
I need to join tree variables and become in a single variable example:
b0= 2 + b1=1 + b2=5 new variable = w215
b0= 0 + b1=5 + b2=3 new variable = w053
b0= 3 + b1=0 + b2=8 new variable = w308
>>>>>>>>
First - please read the manual carefully on variables

You can name a word variable "w215"
e.g
Symbol w215 = w2
w215 = b1 + b2

But if you want w215 to equal 5 then "w215 = 5"

or

b0 = 2
b1 = 3

w213 = b1 + b2

You need to distinguish between operators like + / and variable names like b0, w0
Good luck... you can learn the arbitrary conventions established for the PICAXE
and everything else we work with :)
 

BeanieBots

Moderator
Not 100% sure what you're really trying to do.
If you want MORE variables, then sorry, not possible, but there is scope to use RAM for extra variable storage.
If you want to convert "b0= 3 + b1=0 + b2=8" into a word variable containing 308 then try this:-

Wordvariable=b0*100
b1=b1*10
Wordvariable=Wordvariable+b1+b2

Wordvariable will now have the value 308.
 

eclectic

Moderator
Hippy explained this, but I can't find the post at present.



b0= 2 + b1=1 + b2=5 new variable = w215

b0= 0 + b1=5 + b2=3 new variable = w053

b0= 3 + b1=0 + b2=8 new variable = w308

It goes something like this:

b0 = 2 : b1 = 1 : b2 = 5

w2 = b0*100
b1 = b1*10

w2 = w2 + b1 + b2

e
 
Last edited:

hippy

Ex-Staff (retired)
eclectic has probably hit the nail on the head, so ...

b0 = 2
b1 = 1
b2 = 5
w0 = b0 * 10 + b1 * 10 + b2

Will leave w0 with the value 215 in it.

There's two "times 10" and no "times 100" because maths on a PICAXE is strictly left to right, equivalent to ...

result = (( ( hundreds * 10 ) + tens ) * 10 ) + units
 

westaust55

Moderator
Dear All:

I need to join tree variables and become in a single variable example:

b0= 2 + b1=1 + b2=5 new variable = w215

b0= 0 + b1=5 + b2=3 new variable = w053

b0= 3 + b1=0 + b2=8 new variable = w308

Thanks
Or are you trying to use the values in b0, b1 and b2 to act as a pointer to a new location.

In this case, yes hippy's formula give the location but you cannot have more than 14 or 28 byte variable (= 7 or 14 word variable).

Your third examples also suggest that you may want more then 255 locations (ie w308) in which case you might need to look at an external EEPROM (if the numbers are not changing too frequently due to limited number of write operations to each memory location before possible failure) or an F-RAM for far greater number of write operations.

You will need to clarify better exactly what you are trying to achieve and which PICAXE chip you have.
 
Top