Author Topic: Define a command whose name is based on a variable.  (Read 782 times)

janjan

  • Newbie
  • *
  • Posts: 42
Define a command whose name is based on a variable.
« on: April 26, 2020, 04:02:58 AM »
Hi,
I am trying to defined commands whose names is derived from a global variable.
e.g.
Instead of defining the following 3 commands, so that when I say:
Code: [Select]
Set com 1 [tower1;tower2;tower2....towerX]
Set com 2 [tower1;tower2;tower2....towerX]
Set tacan [tower1;tower2;tower2....towerX]

I define, when I load the profile a variable:
Code: [Select]
Set text [airpotList] to 'tower1;tower2;tower3...towerX'

Then I defines my command so that when I say:
Code: [Select]
Set com 1 [{TXT:airpotList}]
Set com 2 [{TXT:airpotList}]
Set tacan [{TXT:airpotList}]

This allows me the flexibility to make a single modifications which will be reflected to all my commands.

I tested it and it is working.
I want to know if this is a 'legit' way to define a command or perhaps it can lead to stability or other issues.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Define a command whose name is based on a variable.
« Reply #1 on: April 26, 2020, 08:19:11 AM »
While that functionality is available, it is undocumented exactly because there is no guarantee of stability or compatibility.

Also note that variables values are only refreshed when the profile is reloaded (E.G. using the "Reset the Active Profile" action), meaning if you set the values after the profile loads (as is always the case when VoiceAttack loads a profile on startup), you need to reload it in order for commands containing tokens in their phrases to work correctly.