combining two vars
Chupa
Posts: 4
im trying to figure out how to combine two variables, and put a . between them. my code is like this:
var1 = united
var2 = states
i want var3 to be
var3 = var1"."var3
or
united.states
i cant figure this out for the life of me....
var1 = united
var2 = states
i want var3 to be
var3 = var1"."var3
or
united.states
i cant figure this out for the life of me....
Comments
I think your are confused about the basics of variable storage in a BS2. PBASIC variables can be a bit, 4 bits (nib), 8 bits (byte), or 16 bits (word). You haven't provided enough information to indicate whether you are trying to work with numbers or strings (1234 vs. "Hello"). Are you trying to concatonate the actually words "united" and "states", or is united defined to be a number (somewhere in your code appears something like "united = 234")?
Since a PBASIC variable permits a maximum of 16 bits and each letter in a string takes 8 bits, you could store a maximum of 2 letters in a variable (and you shouldn't do this anyways). To store a string variable you have to use an array of bytes which is group of bytes, each byte holding a letter. Refer to the Stamp User Manual for how to work with arrays. The problem with working with arrays, is the BS2 has a limited amount of varaible space (maximum of 26 bytes) and you will quickly run out of variable space when working with strings. There are ways around this if certain conditions are true, but I won't go into them unless it is clear this is what you are trying to do.
If you are trying to combine two numbers so that the first part is the integer value and the second part is the fractional part, the BS2 only works in integers. It doesn't understand how to work with fractions. Again there are ways around this if certain conditions are true, but I won't go into them unless it is clear this is what you are trying to do.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 8/6/2005 3:36:26 PM GMT
·· About the only option left is to store the data in EEPROM in that order as you create the data.· This would involve using the WRITE and READ commands.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
Do you have a Stamp Tester yet?
http://hometown.aol.com/newzed/index.html
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10
Post Edited (Paul Baker) : 8/6/2005 4:40:36 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·1+1=10