PDA

View Full Version : Array Handling Difficulties



william chan
01-19-2009, 10:22 AM
Help!

I tried doing

VAR
long mydata[20]

index := 1
third := 3
mydata[index].byte[third] := 100

but the compiler keeps complaining "variable needs a parameter"....

What gives?

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my (http://www.fd.com.my)
www.mercedes.com.my (http://www.mercedes.com.my)

Erik Friesen
01-19-2009, 10:33 AM
You will have to do it this way.




mydata.byte[(index*4)+third]

william chan
01-19-2009, 10:57 AM
I thought the most logical and clean way would be my example code.
This is most unusual.

Thanks for your help.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.fd.com.my (http://www.fd.com.my)
www.mercedes.com.my (http://www.mercedes.com.my)

Phil Pilgrim (PhiPi)
01-19-2009, 11:25 AM
William,

I can't disagree. A subscripted variable should still produce a typed "lvalue" on the compile stack that's subject to further modification. It's probably not a bug in the compiler, but more likely just an oversight.

-Phil

Erik Friesen
01-19-2009, 07:52 PM
I have smacked my head into this one too. I think I have tried every possible combination. I'd agree with phil.