Author Topic: Can I use a variable in a token?  (Read 1213 times)

errspace

  • Guest
Can I use a variable in a token?
« on: March 23, 2019, 07:35:18 AM »
I am trying to write a command which consists of several digits. The processing will be the same for each digit, so I want a loop which iterates through the digits. Can I use a variable to call the appropriate CMDSEGMENT somehow? I have tried
Code: [Select]
Start Loop While : [index] Is Less Than 5
    Begin Text Compare : [{CMDSEGMENT:[index]}] Equals '8'
...
But I get 'error in token' as an output. Do I have to use an integer literal with the CMDSEGMENT token?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Can I use a variable in a token?
« Reply #1 on: March 23, 2019, 07:45:41 AM »
You can nest tokens, so if a token doesn't take a variable directly you can use another token to retrieve the value first.

E.G.
Code: [Select]
{CMDSEGMENT:{INT:index}}

errspace

  • Guest
Re: Can I use a variable in a token?
« Reply #2 on: March 23, 2019, 07:49:41 AM »
Awesome, thank you.