Countdown timer, combine 3 variables into one.
jayove
Posts: 2
I am developing a countdown timer circuit using BS2.· I start by setting·3 variables in an array.· For example:
var1=7
var2=2
var3=0
I want var4 to = 720.· How can I combine var1-3?
var1=7
var2=2
var3=0
I want var4 to = 720.· How can I combine var1-3?
Comments
var4 = var3
var4 = var2 * 10 + var4
var4 = var1 * 100 + var4
var4 = (var1 + (var2*10) + (var3*100))
[noparse];)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
PBASIC·recognizes groups with·( ) ?·
I thought that it just goes left to right regardless.
·· In the Editor Help File under PBASIC Operators it explains that you can use parenthesis to change the order that things are evaluated in.· Within the parenthesis it is also from left to right.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
· Well, dangit...
··OK, I looked up parentheses in PBASIC Help's Search and found Operator Precedence.
· Before, I've only looked up stuff from the Index -- and·there's been that Search tab there all this time.· Boy, howdy.
· Got it.
Post Edit --
· BTW, jayove, VARiables·with values greater than 255 (e.g. var4, var1) will need to be declared as Words.
Post Edited (PJ Allen) : 6/15/2006 2:33:29 PM GMT
·· You don't even have to search...If you click the + next to PBASIC Reference (In Contents) then click the words PBASIC Operators you're right in the section that explains how they're evaluated.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited By Moderator (IT Guy (Parallax)) : 6/15/2006 8:15:27 PM GMT