How to access dynamic array var in AWK

related thread about multi-step "for each" loops:



running command:

hawk@Tug:~/tmp/ind/src/checkpoint$ full-command --ssh indeni,indenirocks123! multitest.ind

I'm trying to write a multi-step variable which holds a list of values (an array). I am able to create the variable and retrieve it in the second step, but then I can't seem to access the data in the variable -- it does not "act like" an AWK array. E.g., trying to do this:

for (key in theArr) {

Give me the error:

Description = Failed to compile AWK code of command "a-little-test-script". Code:
    theArr = dynamic("myarr")
    debug("** length: " length(theArr))
writeComplexMetricString("dummy-metric", null, theArr)

for (key in theArr) {
Message = Failed to convert script to tuples. Script:

Interestingly, if I write the variable using writeComplexMetricString(), it succeeds and reports three metrics (the values of the “array”).

I’m guessing that the AWK variable type I’m ending up with in the second step isn’t an associative array, but I can’t figure out what it is. Dumping with writeDebug() “doesn’t work” – it seems to actually crash the script, but there’s no error message…I can’t quite tell what’s going on there…there’s a ton of DEBUG output, and I can see some of the values in the array (but not all), but this is all of the “>>><<< haystack” debug out that I don’t understand at all.

The second step is being executed for every value in the “myarr” array; each time it is executed, it can access that (single) value via dynamic("myarr") which will return the string of that value.

For instance, if the first step generated a dynamic variable with 4 values: ["val1", "val2", "val3", "val4"] then the second step would be executed 4 times and each time the value of dynamic("myarr") would be one of these values.