Hello
I would like to know if there is a way to get the length of a specified dimension of a multidimensionnal array in karel (ARRAY_LEN but works only for one dimension array)?
thanks ahead.
Hello
I would like to know if there is a way to get the length of a specified dimension of a multidimensionnal array in karel (ARRAY_LEN but works only for one dimension array)?
thanks ahead.
Hi ,
I think it's not possible...
You can only find out how many dimensions the variable has with "var_info"-builtin
...
If you "own" the var you can use a (complex) structure instead and then use ARRAY_LEN
Or by iterating over and check for "index out of range" or similar (don't know the exact error code / name)
best
Hi,
I think i am going to use the second solution.
"Or by iterating over and check for "index out of range"
Thanks for the reply.
The question is, why do you have to do this at all?
Do you really need to find out the length dynamically?
In many sysvars, for example, there is a second var that determines the length of the arrays...
e.g.:
[*NUMREG*]$NUMREG Storage: SHADOW Access: RW : ARRAY[200] OF Numeric Reg
--> [*NUMREG*]$MAXREGNUM Storage: CMOS Access: RW : INTEGER = 200
....
same for Number of Groups, Axis and so on
...
best