MapTool 1.3 Release's macro language allows the nesting of operations (such as branching and looping operations) via the use of the CODE roll option and curly braces to demarcate groups of operations. However, you are restricted as to how many levels deep you can "nest" such operations. Use of the CODE block can extend only two levels deep
So if I try to nest three for loops inside each other I will get an error, e.g.:
Code: Select all
[for(i,0,2,1), code:
{
[output = strformat("<b>i is %{i}:</b> ")]
[for(j,0,3,1), code:
{
[output = strformat("j is %{j}")]
[for(k,0,2,1), code:
{
[output = strformat("<i>k is %{k}</i>")]
}]
}]
[output = strformat("<br>")]
}]
In this example I could work around that by omitting the brackets in the inner loop, i.e.:
Code: Select all
[for(i,0,2,1), code:
{
[output = strformat("<b>i is %{i}:</b> ")]
[for(j,0,3,1), code:
{
[output = strformat("j is %{j}")]
[for(k,0,2,1): output = strformat("<i>k is %{k}</i>")]
}]
[output = strformat("<br>")]
}]
But if I understand it correctly there is no way to have three nesting for-loops where each has more than one command, or is there a way to work around this limitation?
I run into the same problem when I want an if-comparison inside two nesting for loops (with more than one command), e.g.:
Code: Select all
[for(i,0,2,1), code:
{
[output = strformat("<b>i is %{i}:</b> ")]
[for(j,0,3,1), code:
{
[output = strformat("j is %{j}")]
[if( j > 1 ), code:
{
[h: someVar = 1]
[output = strformat("<i>j is big.</i>")]
};{
[h: someVar = 0]
[output = strformat("<i>j is small.</i>")]
}]
}]
[output = strformat("<br>")]
}]
Same question: Is there any way to work around this?