Recurse limit hit while finding token

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Recurse limit hit while finding token

Post by Tratz »

This thread technically started in Discord

I was trying to use the following snippet as a UDF to call from wherever I need it:

Code: Select all

<!-- findTokenAllMaps(tokenRef): result
   tokenRef - name or id of token. Obviously, if id is given only 1 map and id will be returned if present.
   result - json object of maps where token is present on with associated id for that map.

This function will find a token reference on all maps and return the map:id json object.
-->
[H: tokenRef = arg(0)]
[H: maps = getTokenMap(tokenRef,"json")]
[H: result = "{}"]
[H, foreach(map,maps): result = json.set(result,map,findToken(tokenRef,map))]
[H: macro.return = result]
I named the function findToken.

I attempted to call findToken in the following template. It was called by a button-click. Note that I'm not doing anything with the result of findToken, I just wanted to see what it would return what I thought it would.

Code: Select all

[h: selected = getSelected()]
[h: attrs = getProperty("attributes", selected)]
[h: primaries = '["strength", "dexterity", "intelligence", "health", "will", "perception", "hitpoints", "fatigue"]']
[h: attrProps = getLibProperty("attributeProperties", "Lib:GURPS")]
[r: logo = findToken("Lib:GURPS")]
[h: handler = macroLinkText("handleAttributes@Lib:GURPS", "none")]
[frame5(getName(selected)+" - Attributes", "width=350; height=450; temporary=1"): {
<html>
	<head>
		<link rel="stylesheet" type="text/css" href="sheetstyles@Lib:GURPS"></link>
	</head>
	<body>
		<table class="header">
			<tr>
				<td><img class="logo" src='[r:logo]'></img></td>
				<td><h1 class="title">Attributes</h1></td>
			</tr>
		</table>
		<h2 class="character-name">Character: [r: getName(selected)]</h2>
		<form action='[r: handler]' method="json">
			<input value="[r: selected]" name="token" hidden>
			<table id="attributes">
				<tr>
					<th></th>
					<th></th>
					<th class="input-header">Points</th>
					<th class="input-header">Mod</th>
				</tr>
				[foreach(stat, primaries, ""), code: {
				<tr>
					[macro("getStatProp@Lib:GURPS"): stat]
					[h: props = macro.return]
					<td><b>[r: json.get(props, "short")]</b></td>
					<td class="statval">[r: calcAttr(stat, attrs)]</td>
					<td><input value='[r: json.path.read(attrs, stat+".points")]' name="[r: stat].points"></input></td>
					<td><input value='[r: json.path.read(attrs, stat+".mod")]' name="[r: stat].mod"></input></td>
				</tr>
				}]
			</table>
			<button class="submit" type="submit">Update</button>
		</form>
	</body>
</html>
}]
I have since found my own way around the solution but wouldn't mind knowing how I managed to hit a ceiling of 10k recursions so quickly.

Error message: Maximum recurse limit reached
Last edited by Tratz on Wed Jan 06, 2021 12:30 pm, edited 1 time in total.

User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Re: Recurse limit hit while finding token image

Post by Tratz »

Maybe the reason is my UDF "calcAttr"? There's some recursion here.

Code: Select all

[h: statName = arg(0)]
[h: statData = arg(1)]
[h: charData = json.get(statData, statName)]
[h: points = json.get(charData, "points")]
[h: mod = json.get(charData, "mod")]
[macro("getStatProp@Lib:GURPS"): statName]
[h: props = macro.return]

[r, switch(statName):
	case "hitpoints": floor(calcAttr("strength", statData)+(points / json.get(props, "cost")) * json.get(props, "amount") + mod);
	case "fatigue": floor(calcAttr("health", statData)+(points / json.get(props, "cost")) * json.get(props, "amount") + mod);
	case "perception": floor(calcAttr("intelligence", statData)+(points / json.get(props, "cost")) * json.get(props, "amount") + mod);
	case "will": floor(calcAttr("intelligence", statData)+(points / json.get(props, "cost")) * json.get(props, "amount") + mod);
	default: floor(10 + (points / json.get(props, "cost")) * json.get(props, "amount") + mod);
]

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Recurse limit hit while finding token

Post by wolph42 »

might I suggest that you turn on the macro logging and the console log, that should 'immediately' show you the culprit. I say 'immediatley' cause when mt hits a loop it will take a loooooooong time for it to stop. So get some coffee OR change the loop limit to 100.

console log is found in the tool menu.

macro loggin on:

Code: Select all

[h: level = "DEBUG"]
[H: lname = "net.rptools.maptool.client.MapToolLineParser"]
[r: "Setting <i><b>" + lname + "</b></i> to <b>" + level + "</b>.<br>"]
[h: log.setLevel(lname,level)]

[h: level = "DEBUG"]
[H: lname = "net.rptools.maptool.client.VariableResolver "]
[r: "Setting <i><b>" + lname + "</b></i> to <b>" + level + "</b>."]
[h: log.setLevel(lname,level)]

macro loggin off":

Code: Select all

[h: loggers = json.sort(log.getLoggers(),"a","name")]
[h, FOREACH(logger, loggers), CODE: {
    [h: lname = json.get(logger,"name")]
   [h: log.setLevel(lname,"INFO")]
}]

User avatar
aliasmask
RPTools Team
Posts: 9023
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Recurse limit hit while finding token

Post by aliasmask »

What is the name of the macro in the second code block? It's not handleAttributes is it?

User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Re: Recurse limit hit while finding token

Post by Tratz »

aliasmask wrote:
Wed Jan 06, 2021 4:16 pm
What is the name of the macro in the second code block? It's not handleAttributes is it?
It is! It's attached to the form action. Submit automatically fires that. This macro processes the user input and updates the token "attributes" property accordingly, then re-loads the frame to update it.

handleAttributes:

Code: Select all

[h: tokenId = json.get(macro.args, "token")]
[h: charAttributes = getProperty("attributes", tokenId)]

[h, foreach(path, macro.args), code: {
	[h, if(path != "token"), code: {
		[h: rawVal = json.get(macro.args, path)]
		[h: val = if(isNumber(rawVal), rawVal, 0)]
		[h: charAttributes = json.path.set(charAttributes, path, val)]
	}]
}]

[h: setProperty("attributes", charAttributes, tokenId)]
[r, macro("attributesView@Lib:GURPS"): ""]

User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Re: Recurse limit hit while finding token

Post by Tratz »

wolph42 wrote:
Wed Jan 06, 2021 3:36 pm
might I suggest that you turn on the macro logging and the console log, that should 'immediately' show you the culprit. I say 'immediatley' cause when mt hits a loop it will take a loooooooong time for it to stop. So get some coffee OR change the loop limit to 100.

console log is found in the tool menu.

macro loggin on:

Code: Select all

[h: level = "DEBUG"]
[H: lname = "net.rptools.maptool.client.MapToolLineParser"]
[r: "Setting <i><b>" + lname + "</b></i> to <b>" + level + "</b>.<br>"]
[h: log.setLevel(lname,level)]

[h: level = "DEBUG"]
[H: lname = "net.rptools.maptool.client.VariableResolver "]
[r: "Setting <i><b>" + lname + "</b></i> to <b>" + level + "</b>."]
[h: log.setLevel(lname,level)]

macro loggin off":

Code: Select all

[h: loggers = json.sort(log.getLoggers(),"a","name")]
[h, FOREACH(logger, loggers), CODE: {
    [h: lname = json.get(logger,"name")]
   [h: log.setLevel(lname,"INFO")]
}]
That was fun!! It's definitely something with the findToken macro :)

Code: Select all

18:14:34.237 DEBUG net.rptools.maptool.client.MapToolLineParser - maybeBroken = findToken("Lib:GURPS")
18:14:34.238 DEBUG net.rptools.maptool.client.MapToolLineParser -  tokenRef = arg(0)
18:14:34.239 DEBUG net.rptools.maptool.client.MapToolLineParser -  maps = getTokenMap(tokenRef,"json")
18:14:34.240 DEBUG net.rptools.maptool.client.MapToolLineParser -  result = "{}"
18:14:34.241 DEBUG net.rptools.maptool.client.MapToolLineParser -  maps
18:14:34.241 DEBUG net.rptools.maptool.client.MapToolLineParser -  result = json.set(result,map,findToken(tokenRef,map))
18:14:34.242 DEBUG net.rptools.maptool.client.MapToolLineParser -   tokenRef = arg(0)
18:14:34.243 DEBUG net.rptools.maptool.client.MapToolLineParser -   maps = getTokenMap(tokenRef,"json")
18:14:34.243 DEBUG net.rptools.maptool.client.MapToolLineParser -   result = "{}"
18:14:34.244 DEBUG net.rptools.maptool.client.MapToolLineParser -   maps
18:14:34.244 DEBUG net.rptools.maptool.client.MapToolLineParser -   result = json.set(result,map,findToken(tokenRef,map))
18:14:34.245 DEBUG net.rptools.maptool.client.MapToolLineParser -    tokenRef = arg(0)
18:14:34.246 DEBUG net.rptools.maptool.client.MapToolLineParser -    maps = getTokenMap(tokenRef,"json")
18:14:34.246 DEBUG net.rptools.maptool.client.MapToolLineParser -    result = "{}"
18:14:34.247 DEBUG net.rptools.maptool.client.MapToolLineParser -    maps
18:14:34.248 DEBUG net.rptools.maptool.client.MapToolLineParser -    result = json.set(result,map,findToken(tokenRef,map))
18:14:34.248 DEBUG net.rptools.maptool.client.MapToolLineParser -     tokenRef = arg(0)
18:14:34.249 DEBUG net.rptools.maptool.client.MapToolLineParser -     maps = getTokenMap(tokenRef,"json")
18:14:34.250 DEBUG net.rptools.maptool.client.MapToolLineParser -     result = "{}"
18:14:34.250 DEBUG net.rptools.maptool.client.MapToolLineParser -     maps
18:14:34.251 DEBUG net.rptools.maptool.client.MapToolLineParser -     result = json.set(result,map,findToken(tokenRef,map))
18:14:34.252 DEBUG net.rptools.maptool.client.MapToolLineParser -      tokenRef = arg(0)
18:14:34.252 DEBUG net.rptools.maptool.client.MapToolLineParser -      maps = getTokenMap(tokenRef,"json")
18:14:34.253 DEBUG net.rptools.maptool.client.MapToolLineParser -      result = "{}"
18:14:34.253 DEBUG net.rptools.maptool.client.MapToolLineParser -      maps
18:14:34.254 DEBUG net.rptools.maptool.client.MapToolLineParser -      result = json.set(result,map,findToken(tokenRef,map))
18:14:34.255 DEBUG net.rptools.maptool.client.MapToolLineParser -       tokenRef = arg(0)
18:14:34.255 DEBUG net.rptools.maptool.client.MapToolLineParser -       maps = getTokenMap(tokenRef,"json")
18:14:34.256 DEBUG net.rptools.maptool.client.MapToolLineParser -       result = "{}"
18:14:34.256 DEBUG net.rptools.maptool.client.MapToolLineParser -       maps
18:14:34.257 DEBUG net.rptools.maptool.client.MapToolLineParser -       result = json.set(result,map,findToken(tokenRef,map))
18:14:34.258 DEBUG net.rptools.maptool.client.MapToolLineParser -        tokenRef = arg(0)
18:14:34.258 DEBUG net.rptools.maptool.client.MapToolLineParser -        maps = getTokenMap(tokenRef,"json")
18:14:34.259 DEBUG net.rptools.maptool.client.MapToolLineParser -        result = "{}"
18:14:34.260 DEBUG net.rptools.maptool.client.MapToolLineParser -        maps
18:14:34.261 DEBUG net.rptools.maptool.client.MapToolLineParser -        result = json.set(result,map,findToken(tokenRef,map))
18:14:34.262 DEBUG net.rptools.maptool.client.MapToolLineParser -         tokenRef = arg(0)
18:14:34.263 DEBUG net.rptools.maptool.client.MapToolLineParser -         maps = getTokenMap(tokenRef,"json")
18:14:34.264 DEBUG net.rptools.maptool.client.MapToolLineParser -         result = "{}"
18:14:34.264 DEBUG net.rptools.maptool.client.MapToolLineParser -         maps
18:14:34.265 DEBUG net.rptools.maptool.client.MapToolLineParser -         result = json.set(result,map,findToken(tokenRef,map))
18:14:34.266 DEBUG net.rptools.maptool.client.MapToolLineParser -          tokenRef = arg(0)
18:14:34.267 DEBUG net.rptools.maptool.client.MapToolLineParser -          maps = getTokenMap(tokenRef,"json")
18:14:34.268 DEBUG net.rptools.maptool.client.MapToolLineParser -          result = "{}"
18:14:34.269 DEBUG net.rptools.maptool.client.MapToolLineParser -          maps
18:14:34.270 DEBUG net.rptools.maptool.client.MapToolLineParser -          result = json.set(result,map,findToken(tokenRef,map))
18:14:34.271 DEBUG net.rptools.maptool.client.MapToolLineParser -           tokenRef = arg(0)
18:14:34.272 DEBUG net.rptools.maptool.client.MapToolLineParser -           maps = getTokenMap(tokenRef,"json")
18:14:34.272 DEBUG net.rptools.maptool.client.MapToolLineParser -           result = "{}"
18:14:34.273 DEBUG net.rptools.maptool.client.MapToolLineParser -           maps
18:14:34.274 DEBUG net.rptools.maptool.client.MapToolLineParser -           result = json.set(result,map,findToken(tokenRef,map))
18:14:34.275 DEBUG net.rptools.maptool.client.MapToolLineParser -            tokenRef = arg(0)
18:14:34.276 DEBUG net.rptools.maptool.client.MapToolLineParser -            maps = getTokenMap(tokenRef,"json")
18:14:34.277 DEBUG net.rptools.maptool.client.MapToolLineParser -            result = "{}"
18:14:34.278 DEBUG net.rptools.maptool.client.MapToolLineParser -            maps
18:14:34.278 DEBUG net.rptools.maptool.client.MapToolLineParser -            result = json.set(result,map,findToken(tokenRef,map))
18:14:34.279 DEBUG net.rptools.maptool.client.MapToolLineParser -             tokenRef = arg(0)
18:14:34.287 DEBUG net.rptools.maptool.client.MapToolLineParser -             maps = getTokenMap(tokenRef,"json")
18:14:34.288 DEBUG net.rptools.maptool.client.MapToolLineParser -             result = "{}"
18:14:34.289 DEBUG net.rptools.maptool.client.MapToolLineParser -             maps
18:14:34.290 DEBUG net.rptools.maptool.client.MapToolLineParser -             result = json.set(result,map,findToken(tokenRef,map))
18:14:34.291 DEBUG net.rptools.maptool.client.MapToolLineParser -              tokenRef = arg(0)
18:14:34.292 DEBUG net.rptools.maptool.client.MapToolLineParser -              maps = getTokenMap(tokenRef,"json")
18:14:34.293 DEBUG net.rptools.maptool.client.MapToolLineParser -              result = "{}"
18:14:34.294 DEBUG net.rptools.maptool.client.MapToolLineParser -              maps
18:14:34.294 DEBUG net.rptools.maptool.client.MapToolLineParser -              result = json.set(result,map,findToken(tokenRef,map))
18:14:34.295 DEBUG net.rptools.maptool.client.MapToolLineParser -               tokenRef = arg(0)
18:14:34.296 DEBUG net.rptools.maptool.client.MapToolLineParser -               maps = getTokenMap(tokenRef,"json")
18:14:34.297 DEBUG net.rptools.maptool.client.MapToolLineParser -               result = "{}"
18:14:34.297 DEBUG net.rptools.maptool.client.MapToolLineParser -               maps
18:14:34.298 DEBUG net.rptools.maptool.client.MapToolLineParser -               result = json.set(result,map,findToken(tokenRef,map))
18:14:34.299 DEBUG net.rptools.maptool.client.MapToolLineParser -                tokenRef = arg(0)
18:14:34.300 DEBUG net.rptools.maptool.client.MapToolLineParser -                maps = getTokenMap(tokenRef,"json")
18:14:34.301 DEBUG net.rptools.maptool.client.MapToolLineParser -                result = "{}"
18:14:34.302 DEBUG net.rptools.maptool.client.MapToolLineParser -                maps
18:14:34.303 DEBUG net.rptools.maptool.client.MapToolLineParser -                result = json.set(result,map,findToken(tokenRef,map))
18:14:34.304 DEBUG net.rptools.maptool.client.MapToolLineParser -                 tokenRef = arg(0)
18:14:34.305 DEBUG net.rptools.maptool.client.MapToolLineParser -                 maps = getTokenMap(tokenRef,"json")
18:14:34.305 DEBUG net.rptools.maptool.client.MapToolLineParser -                 result = "{}"
18:14:34.307 DEBUG net.rptools.maptool.client.MapToolLineParser -                 maps
18:14:34.307 DEBUG net.rptools.maptool.client.MapToolLineParser -                 result = json.set(result,map,findToken(tokenRef,map))
18:14:34.308 DEBUG net.rptools.maptool.client.MapToolLineParser -                  tokenRef = arg(0)
18:14:34.309 DEBUG net.rptools.maptool.client.MapToolLineParser -                  maps = getTokenMap(tokenRef,"json")
18:14:34.310 DEBUG net.rptools.maptool.client.MapToolLineParser -                  result = "{}"
18:14:34.311 DEBUG net.rptools.maptool.client.MapToolLineParser -                  maps
18:14:34.312 DEBUG net.rptools.maptool.client.MapToolLineParser -                  result = json.set(result,map,findToken(tokenRef,map))
18:14:34.313 DEBUG net.rptools.maptool.client.MapToolLineParser -                   tokenRef = arg(0)
18:14:34.313 DEBUG net.rptools.maptool.client.MapToolLineParser -                   maps = getTokenMap(tokenRef,"json")
18:14:34.314 DEBUG net.rptools.maptool.client.MapToolLineParser -                   result = "{}"
18:14:34.315 DEBUG net.rptools.maptool.client.MapToolLineParser -                   maps
18:14:34.316 DEBUG net.rptools.maptool.client.MapToolLineParser -                   result = json.set(result,map,findToken(tokenRef,map))
18:14:34.317 DEBUG net.rptools.maptool.client.MapToolLineParser -                    tokenRef = arg(0)
18:14:34.318 DEBUG net.rptools.maptool.client.MapToolLineParser -                    maps = getTokenMap(tokenRef,"json")
18:14:34.319 DEBUG net.rptools.maptool.client.MapToolLineParser -                    result = "{}"
18:14:34.320 DEBUG net.rptools.maptool.client.MapToolLineParser -                    maps
18:14:34.320 DEBUG net.rptools.maptool.client.MapToolLineParser -                    result = json.set(result,map,findToken(tokenRef,map))
18:14:34.321 DEBUG net.rptools.maptool.client.MapToolLineParser -                     tokenRef = arg(0)
18:14:34.322 DEBUG net.rptools.maptool.client.MapToolLineParser -                     maps = getTokenMap(tokenRef,"json")
18:14:34.323 DEBUG net.rptools.maptool.client.MapToolLineParser -                     result = "{}"
18:14:34.324 DEBUG net.rptools.maptool.client.MapToolLineParser -                     maps
18:14:34.325 DEBUG net.rptools.maptool.client.MapToolLineParser -                     result = json.set(result,map,findToken(tokenRef,map))
18:14:34.326 DEBUG net.rptools.maptool.client.MapToolLineParser -                      tokenRef = arg(0)
18:14:34.327 DEBUG net.rptools.maptool.client.MapToolLineParser -                      maps = getTokenMap(tokenRef,"json")
18:14:34.328 DEBUG net.rptools.maptool.client.MapToolLineParser -                      result = "{}"
18:14:34.329 DEBUG net.rptools.maptool.client.MapToolLineParser -                      maps
18:14:34.329 DEBUG net.rptools.maptool.client.MapToolLineParser -                      result = json.set(result,map,findToken(tokenRef,map))
18:14:34.330 DEBUG net.rptools.maptool.client.MapToolLineParser -                       tokenRef = arg(0)
18:14:34.331 DEBUG net.rptools.maptool.client.MapToolLineParser -                       maps = getTokenMap(tokenRef,"json")
18:14:34.332 DEBUG net.rptools.maptool.client.MapToolLineParser -                       result = "{}"
18:14:34.333 DEBUG net.rptools.maptool.client.MapToolLineParser -                       maps
18:14:34.334 DEBUG net.rptools.maptool.client.MapToolLineParser -                       result = json.set(result,map,findToken(tokenRef,map))

// MANY FAILED RECURSIONS LATER

18:14:35.289 DEBUG net.rptools.maptool.client.MapToolLineParser - net.rptools.parser.ParserException: Maximum recurse limit reached.

taustinoc
Dragon
Posts: 515
Joined: Mon Aug 03, 2015 6:30 pm

Re: Recurse limit hit while finding token

Post by taustinoc »

Tratz wrote:
Wed Jan 06, 2021 12:22 pm
I named the function findToken.
I have no idea what happens when you name a UDF with an actual built-in function name, but it seems like that might not be the best idea.

https://wiki.rptools.info/index.php/findToken

User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Re: Recurse limit hit while finding token

Post by Tratz »

taustinoc wrote:
Thu Jan 07, 2021 12:26 am
Tratz wrote:
Wed Jan 06, 2021 12:22 pm
I named the function findToken.
I have no idea what happens when you name a UDF with an actual built-in function name, but it seems like that might not be the best idea.

https://wiki.rptools.info/index.php/findToken
Fair to think so.

I tried naming the macro "findTokenMacro@Lib:GURPS" and the UDF function "findToken"

It still broke.

User avatar
bubblobill
Giant
Posts: 167
Joined: Sun Jan 24, 2010 3:07 pm

Re: Recurse limit hit while finding token

Post by bubblobill »

Tratz wrote:
Wed Jan 06, 2021 12:22 pm
I named the function findToken.
There's your problem.

Now look in your foreach loop.
Tratz wrote:
Wed Jan 06, 2021 12:22 pm

Code: Select all

<!-- findTokenAllMaps(tokenRef): result
   tokenRef - name or id of token. Obviously, if id is given only 1 map and id will be returned if present.
   result - json object of maps where token is present on with associated id for that map.

This function will find a token reference on all maps and return the map:id json object.
-->
[H: tokenRef = arg(0)]
[H: maps = getTokenMap(tokenRef,"json")]
[H: result = "{}"]
[H, foreach(map,maps): result = json.set(result,map,findToken(tokenRef,map))] 
[H: macro.return = result]
Bubblobill on the forum.
@Reverend on the MapTool Discord Server

Responsible for less atrocities than most... I do accept responsibility for these though: SmartDoors, Simple d20 Framework - barebones, Drop-in: All 3.5 SRD Monsters, Drop in: Simple Character Editor, Battletech Framework

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Recurse limit hit while finding token

Post by wolph42 »

why on earth are you doing this recursively? and I also see no breakout of the recursive loop whatsover. you just keep calling the same function with the same arguments recusively, no wonder it never breaks from the loop: nothing changes. don't you want to use the MT Wiki: findToken() function inside your own function?
You've now both repurposed the MT function findToken (for no apparent reason) and are calling it from within the function creating the recursive loop (for no apparent reason)

In case its not entirely clear, you've effectively creaeted the UDF 'callMe' and the function callMe looks like this:

Code: Select all

<!--  callMe() function-->
[r:callMe(arg(0)]
<!-- end of function-->

User avatar
Tratz
Kobold
Posts: 9
Joined: Tue Dec 15, 2020 2:57 pm

Re: Recurse limit hit while finding token

Post by Tratz »

wolph42 wrote:
Thu Jan 07, 2021 3:02 am
why on earth are you doing this recursively? and I also see no breakout of the recursive loop whatsoever. you just keep calling the same function with the same arguments recusively, no wonder it never breaks from the loop: nothing changes. don't you want to use the MT Wiki: findToken() function inside your own function?
Yes, yes I do. I did not realize the naming conflict when I named my UDF function findToken. This is a classic issue of someone (myself in this case) having copied someone else's snippet and not giving it too much thought after the fact. Embarrassing!

Sorry it took so long for me to see it. I see that taustinoc pointed it out but I misunderstood it as the macro name, not the function name. Beg your pardon(s).


User avatar
wyrmwood_lives
Cave Troll
Posts: 25
Joined: Fri Nov 08, 2019 10:22 pm

Re: Recurse limit hit while finding token

Post by wyrmwood_lives »

taustinoc wrote:
Thu Jan 07, 2021 12:26 am
Tratz wrote:
Wed Jan 06, 2021 12:22 pm
I named the function findToken.
I have no idea what happens when you name a UDF with an actual built-in function name, but it seems like that might not be the best idea.

https://wiki.rptools.info/index.php/findToken
You have to use "oldFunction". If it's a macro, and you don't use UDF, then it doesn't matter, but once you define it as a UDF, https://wiki.rptools.info/index.php/oldFunction

Post Reply

Return to “Macros”