Home/Support/Support Forum/Rabbit Web: Value of array's element as index of element of another array
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Rabbit Web: Value of array's element as index of element of another array

0 votes

I work with a Rabbit 6700 and Dynamic C 10.66.


int A[3] = {11, 22, 33};
#web A
int B[3] = {1, 2, 3};
#web B

in browser:

<?z echo($B[0]) ?> shows "1",
<?z echo($A[1]) ?> shows "22",
but <?z echo($A[$B[0]]) ?> shows "ZHTML ERROR: Unknown variable"

What the problem, and why it doesn't work correctly?

Thanks for your help.
asked Aug 4, 2016 in Rabbit by Vasily New to the Community (0 points)

Please log in or register to answer this question.

1 Answer

0 votes
First, note that RabbitWeb makes use of single-letter variable names for loop control. You should be using multi-letter variable names in your program.

Second, RabbitWeb does not support multiple levels of array indexing. You can work around this by using a loop:
int foo[3] = {11, 22, 33}; #web foo int bar[3] = {1, 2, 3}; #web bar
<?z echo($bar[0]) ?> shows "1" <?z echo($foo[1]) ?> shows "22" <?z for ($A = $bar[0]; $A <= $bar[0]; $A++) { ?> <?z print($foo[$A]) ?> shows "22" <?z } ?>

It's a bit of a hack, but it accomplishes your goal.

Finally, please use the latest version of Dynamic C (10.72A). You can view the Release Notes for an idea of how many bugs have been fixed since the 10.66 release you're using. There's also a 10.72B release in the works -- you can see what's going into that on the GitHub repository for Dynamic C.

answered Aug 8, 2016 by TomCollins Veteran of the Digi Community (2,311 points)