[ExM Users] nested foreach and variable scope

Ketan Maheshwari ketan at mcs.anl.gov
Fri Jun 27 16:54:47 CDT 2014


Consider the following two cases:

1.
main{
    file files[] = glob("adir/*.txt");
    string commands[]=split(read(input_file("./commands.txt")),"\n");

    foreach afile, i in files{
            printf("%s", filename(afile));
        foreach command, j in commands{
            printf("%s", command);
        }
    }
}

2.
main{
    file files[] = glob("adir/*.txt");
    string commands[]=split(read(input_file("./commands.txt")),"\n");

    foreach afile, i in files{
        foreach command, j in commands{
            printf("%s", filename(afile));
            printf("%s", command);
        }
    }
}


Case 1 works while 2 shows error at runtime as follows:
can't read "u:afile": no such variable
    while executing
"turbine::file_read_refcount_incr ${u:afile} [ expr { ${tcltmp:iters} - 1 }
]"

Any clue?

Thanks,
Ketan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/exm-user/attachments/20140627/7565e20a/attachment.html>


More information about the ExM-user mailing list