Author Topic: Question by token EXP  (Read 1560 times)

Aniv_D

  • Newbie
  • *
  • Posts: 18
Question by token EXP
« on: January 03, 2020, 10:37:50 AM »
Hello.
as you know from the documentation:
{EXP: 'welcome' + ' ' + 'captain' } evaluates to 'welcome captain'.
or if we use numbers:
{EXP: '1' + '5'} evaluates to '15'.
but if you use 0, then you don't get '05'
{EXP: '0' + '5'} evaluates to '5'.
but I would like to evaluate to '05'.
after all, the number 0 is enclosed in single quotes and must be provided as text.
tell me if it's a bug or if it's all planned.
Thanks.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2827
Re: Question by token EXP
« Reply #1 on: January 03, 2020, 11:03:57 AM »
EXP is evaluating the result of '0' + '5' and presents a string representation of that evaluation.  So, '1' + '5' is, '15' which evaluates to 15 which is presented as '15' as a string.  '0' + '5' is '05', but is evaluated as 5 and is presented as, '5'.

I'd recommend using the {TXTCONCAT} token to concatenate strings - it just puts the strings together and does not evaluate.

Hope that helps!

Aniv_D

  • Newbie
  • *
  • Posts: 18
Re: Question by token EXP
« Reply #2 on: January 03, 2020, 11:36:10 AM »
Yes, thank you so much for the tip Gary!
I did not have to deal with this token, I missed this token something in the help :))

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Question by token EXP
« Reply #3 on: January 03, 2020, 11:49:38 AM »
Tokens are parsed and replaced with literal text, so the end result is always a single string of text.

Because of this, you can do away with any explicit concatenation, which is especially useful if you have more than two strings.

E.G. instead of
Code: [Select]
{TXTCONCAT:variableContainingOne:"{TXTCONCAT:variableContainingZero:variableContainingFive}"}you could just do
Code: [Select]
{TXT:variableContainingOne}{TXT:variableContainingZero}{TXT:variableContainingFive}which will produce the exact same end result.

Of course you can mix in regular literal text as well, E.G.
Code: [Select]
1{TXT:variableContainingZero}5

All parsing is completed before the end result is passed on, so it doesn't matter how you compose the text you're looking to input, as it all ends up as part of the same string anyway.