Spaces at the end of a token name

Confirmed bugs should get a single post here. Check the READ ME FIRST sticky thread for the format.

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice, MapTool BugReport Manager

Forum rules
Posts that do not conform to the READ ME FIRST sticky thread are subject to deletion.
Post Reply
taustinoc
Dragon
Posts: 516
Joined: Mon Aug 03, 2015 6:30 pm

Spaces at the end of a token name

Post by taustinoc »

This is on 1.5.8.

I had a token with a space at the end of the name (not sure how, but there it was). Let's say it was "Classic1 ".

I am working on an attack macro. It starts with GetTokenNames with some selection criteria, which gets a list of tokens. This works fine, and if I display the list, the trailing space is still there.

The next step is to use a FOREACH to iterate through the list to add to a drop down list with token images using getTokenImage. This fails, with the error message

Code: Select all

Error executing "getTokenImage": the token name or id "Classic1" is unknown.
I have no idea if it is the FOREACH or the getTokenImage that's doing it, but at this point, the trailing space stripped off. As soon as I correct the token name, it works fine.

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: Spaces at the end of a token name

Post by Merudo »

The problem is with listAppend - it deletes the spaces around each value.

Example:

Code: Select all

Values:[r: listAppend(" value1 ", " value2 ")].
Returns:
Values:value1, value2.
To preserve the spaces, you can use a JSONArray instead.
Last edited by Merudo on Fri Mar 20, 2020 5:11 pm, edited 1 time in total.

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

Re: Spaces at the end of a token name

Post by taustinoc »

Personally, I wouldn't have a problem with token names being trimmed automatically (which would solve this), but something should be done one way or the other.

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

Re: Spaces at the end of a token name

Post by taustinoc »

For the record, it does the same thing with a tab character (which can happen if you copy and paste from a spreadsheet or word processor), and also for leading spaces (or tabs) as well as trailing.

Post Reply

Return to “Bug Reports”