[COUNT(): inside a [COUNT():
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
Re: [COUNT(): inside a [COUNT():
CIF might have a point cause I cant find anything wrong with your code. A for(i,1,6), code:{ statement might solve this.
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
Re: [COUNT(): inside a [COUNT():
Here is the code in full with a FOR instead of COUNT
Same error as count.
Throws this error:
Same error as count.
Code: Select all
[dialog("Treasure Chamber", "width=700; height=650; temporary=1; input=0; noframe=1"):{
<html>
<form>
[h: tokenName = "Treasure_Token_1"]
[h: button = strformat('<td><input type="image" src="%s" name="btnMove" value="UP"></td>',getImage("image:" + tokenName))]
<table border = "1" align = "center" style="background-color:yellow;">
[r,count(6,""),code:
{
<tr>
[r, for(i,1,6), code: { [r: button] } ]
</tr>
}]
</table>
</form>
</html>
}]
Error in body of roll. Statement options (if any): dialog("Treasure Chamber", "width=700; height=650; temporary=1; input=0; noframe=1") Statement Body (first 200 characters): {
[h: tokenName = "Treasure_Token_1"] [h: button = strformat('
',getImage("image:" + tokenName))]
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
Yep. Thats nesting limit. As said its the number of braces/curly brackets that counts, not the keyword CODE.
Note that you can simply omit a pair here:
This
does pretty much the same as this
Note that you can simply omit a pair here:
This
Code: Select all
[r, for(i,1,6), code: { [r: button] } ]
Code: Select all
[r, for(i,1,6, ""): button]
Re: [COUNT(): inside a [COUNT():
But then if I omit the code: {} from the FOR I won't be able to add code to +1 to a var to change the image?CoveredInFish wrote:Yep. Thats nesting limit. As said its the number of braces/curly brackets that counts, not the keyword CODE.
Note that you can simply omit a pair here:
Thisdoes pretty much the same as thisCode: Select all
[r, for(i,1,6), code: { [r: button] } ]
Code: Select all
[r, for(i,1,6, ""): button]
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
Yes.
If you plan to include more code into the inner loop you have to split the macro in two.
The nesting limit is a fact - due to the fact that this macro language is grown into something that was never planned from the beginning - and we have to live with it.
You only have two choices. Either you write the macro within the nesting limit. Sometimes possible, sometimes not. You maybe could - instead of using another variable - use the index variable i of your for-loop. Or you split it into more sub-macros - each macro can nest again two levels of braces. You probably could create some GetButton(index)-user function that you call using the i-variable.
edit: added some case-specific comments.
If you plan to include more code into the inner loop you have to split the macro in two.
The nesting limit is a fact - due to the fact that this macro language is grown into something that was never planned from the beginning - and we have to live with it.
You only have two choices. Either you write the macro within the nesting limit. Sometimes possible, sometimes not. You maybe could - instead of using another variable - use the index variable i of your for-loop. Or you split it into more sub-macros - each macro can nest again two levels of braces. You probably could create some GetButton(index)-user function that you call using the i-variable.
edit: added some case-specific comments.
Re: [COUNT(): inside a [COUNT():
Theres the light bulb. I understand now. I made a openDialog macro to house the Dialog {}s and all came together. Thanks for the help.
Re: [COUNT(): inside a [COUNT():
If you feel it appropriate to make a separate macro call within your innermost code block then you may do so as I sometime do. However, when I really want to keep my code together I work around the nesting limit by using evalMacro.
Your code then becomes:
The difference is that you can put more statements after "[r: button]". Generally speaking, I don't put too many as it then starts to look a little silly if you don't align it right.
Your code then becomes:
Code: Select all
[dialog("Treasure Chamber", "width=700; height=650; temporary=1; input=0; noframe=1"):{
<html>
<form>
[h: tokenName = "Treasure_Token_1"]
[h: button = strformat('<td><input type="image" src="%s" name="btnMove" value="UP"></td>',getImage("image:" + tokenName))]
<table border = "1" align = "center" style="background-color:yellow;">
[r,count(6,""),code:
{
<tr>
[r, for(i,1,6), code: evalMacro('[r: button]') ]
</tr>
}]
</table>
</form>
</html>
}]
StarMan - The MacroPolicebox D&D 4E Framework: Import ANYTHING!
- CoveredInFish
- Demigod
- Posts: 3104
- Joined: Mon Jun 29, 2009 10:37 am
- Location: Germany
- Contact:
Re: [COUNT(): inside a [COUNT():
Nice trick.
Probably you do omit the code block here (syntax would be wrong anyway):
Probably you do omit the code block here (syntax would be wrong anyway):
Code: Select all
<!-- so its not this -->
[r, for(i,1,6), code: evalMacro('[r: button]') ]
<!-- but this -->
[r, for(i,1,6): evalMacro('[r: button]')]
Re: [COUNT(): inside a [COUNT():
Nice trick indeed!!
GETTING STARTED WITH MAPTOOLS - TUTORIALS, DOCS, VIDEOS, TOOLS, ETC
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
DISCORD (the new MT forum!)
My stuff
Excel Tools: Table and Light editors
MT Tools: Bag of Tricks: Tools for Maptool, Dungeon Builder I, Dungeon Builder II,onMouseOverEvent.
Frameworks: Dark Heresy, Rogue Trader, Deathwatch, Black Crusade, Only War, SET Card Game, RoboRally
Wiki: Debugging Tutorial, Speed Up Your Macros, Working With Two CODE Levels, Shortcut Keys, Avoiding Stack Overflow, READ THIS
Re: [COUNT(): inside a [COUNT():
I wouldn't do this in code that is going to be executed a lot. The function essentially "starts over" and executes the string with a fresh initialization. This is likely to increase the needed stack space and the setup/init is probably slower than just running the code. (If anyone has performance numbers on this I'd love to hear about it.)
However, if you have to do it because of the nesting depth, then the only other option is a separate macro and that has overhead of its own (such as maintenance and functional linkage between macros).
However, if you have to do it because of the nesting depth, then the only other option is a separate macro and that has overhead of its own (such as maintenance and functional linkage between macros).