Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Autocalculate to concatenate

December 07 (7 years ago)
Chad
Sheet Author
Ran into a little oddity in the autocalculation when using it to concatenate text values. Anyone know a workaround?

I have a field that autocalculates like so:  value="@{text_1}"

Works perfectly if I enter something like this in attr_text_1:   "The quick brown fox."
The result is: "The quick brown fox."

However, if I enter something like this in attr_text_1: "We have 5 dogs and 2 cats."
The result is: "52"

Anyone know a workaround?

Thanks!
December 07 (7 years ago)
Chad
Sheet Author
Addendum:  Another weirdness 

If i enter:  "Home Ground"
The result is: 0

(After testing, it appears to see "round" and return a 0)
December 07 (7 years ago)
I think autocalculation is for numbers to do math on, so it's always looking for numbers and math commands (like round).

Why do you need autocalc on these fields?
December 07 (7 years ago)
Chad
Sheet Author
Trying to concatenate a couple of strings into the display on a button. 
December 07 (7 years ago)

Edited December 07 (7 years ago)
Jakob
Sheet Author
API Scripter
Why don't you concatenate them in the HTML if it's only for display, or, if you need the concatenated string as an attribute, use sheet workers?

There's really no reason to use an autocalc field for this.
December 07 (7 years ago)
Chad
Sheet Author
Sheet workers are something I’m trying now. Not sure how successful that will be though. Can they even touch the text of a label?

As for using HTML, I’m not sure what you mean. How can I concatenate various attributes using only HTML?


December 07 (7 years ago)
Chad
Sheet Author
Checking into using worker scripts for this, I ran into this problem as well.

From the Wiki:
Note: If you are trying to update a disabled input field with this method you may run into trouble. One option is to use this `setAttrs` method to set a hidden input, then set the disabled input to the hidden element. 
So if I try to use a disabled field to hold the concatenation, I'm going to end up running into the same problem :(

December 07 (7 years ago)

Edited December 07 (7 years ago)
chris b.
Pro
Sheet Author
API Scripter
for one, don't put disabled on the fields. 
then you can put it as spans where the button name goes, you can put multiple spans there. we do this for some things on our sheet:
where one, two, etc , are the attribute names of your strings

<button name="roll_x" type="roll" value="macro"><span name="attr_one"></span><span name="attr_two"></span></button>
December 07 (7 years ago)

Edited December 07 (7 years ago)
Jakob
Sheet Author
API Scripter
In addition to what chris said, if you do want something that looks like an input, but does not autocalculate anything (suitable for being set via sheetworkers), use an input that is readonly instead of disabled).

The wiki is really terrible for some things. That advice is you quoted is at best useless, at worst misleading.
December 07 (7 years ago)
Chad
Sheet Author

chris b. said:

for one, don't put disabled on the fields. 
then you can put it as spans where the button name goes, you can put multiple spans there. we do this for some things on our sheet:
where one, two, etc , are the attribute names of your strings

<button name="roll_x" type="roll" value="macro"><span name="attr_one"></span><span name="attr_two"></span></button>

Interesting. I didn't know I could put an attribute in a span and have it ever update. Thanks for the idea, I'll try it.