PDA

View Full Version : Modifying a variable?



ybrisson
- 9th October 2003, 03:12
Hello all,

I would like to know if there's a way to minimise the number of
"IF THEN" in this following (simplified) situation.
(I'm new to picbasic!).


value VAR byte

x VAR byte

y0 VAR byte
y1 VAR byte
y2 VAR byte
y3 VAR byte
.
.
.
y15 VAR byte 'or y VAR byte[16]?


If x = 0 Then y0 = value
If x = 1 Then y1 = value
If x = 2 Then y2 = value
If x = 3 Then y3 = value

... and so forth

So is there a way to modify variable "y" by using the "x" one?

ie: yx, y.x, y[x], ???

Thank you

Melanie
- 9th October 2003, 14:16
This is an alternative you can consider...

value var byte
x var byte
y var byte [16]

For x=0 to 15
if y[x]=x then y[x]=value
next x

Melanie

Billyc
- 15th April 2004, 18:37
Can any one shed light on Melabs Compilers PicBasic Pro & PicBasic . THey have different suntaxes declaring /defining variables syntax is totally different. I bought the PicBasic Standard compiler and the manual that comes with it is really really bad. Can anyone direct me to a tutorial paid or unpaid that simply shows the user how to write the correct PicBasic code for THE PICBASIC COMPIIER (Micro Engineering Labs, Inc)it's worth a bottle of Newcastle BRown ! Why do they make it so confusing and why don't they make the syntax the same for both versions of the compiler!! A reply would be appreciated WWC Bolton MA 01740 USA