Using the Device Modeling Language (DML), version 1.4.
I create a param of lists like
param X = [ [0, 0, 0], [0, 0, 1].......];
And I want to access them in a method using variable like
method get_var(uint32 idx) -> (uint32) {
return X[idx][0];
}
But when I try to compile it says I cannot use variable index in a constant list.
Is there a different data type that I should be using other than param to allow this? Or is there a way to define "idx" as a const so it could be used?
The workaround that I currently have is creating a session variable and copying the param list over during post_init()
since then I'm allowed to access that session variable using variable index. I don't know if it's the best way to handle that.
Another possibility is to use a session variable. Session variables will take some extra space, and will consume stack space equal to their size during object initialization, so they are not suited for very large arrays. But for reasonable array sizes < 256 it is a valid approach.