Author Topic: CMDSEGMENT in a PREFIX  (Read 1737 times)

Oss133

  • Newbie
  • *
  • Posts: 21
CMDSEGMENT in a PREFIX
« on: August 19, 2019, 12:24:06 PM »
Hello, me again.

I have a Prefix command of Shield Booster [1..4] and I have Suffix commands of Add, Check, On, Off etc.

I want to capture the result from the [1..4] part of the command. {CMDSEGMENT:} works in Full Commands but does not seem to work in Prefix commands.

Am I doing something wrong or is this just how it is?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: CMDSEGMENT in a PREFIX
« Reply #1 on: August 19, 2019, 12:33:58 PM »
It is possible to use "{CMDSEGMENT:}" with composite (prefix/suffix) commands, however as processing the segment info for those commands is resource intensive, it is disabled by default.

You can enable the "Allow command segment info for composite commands" option on the "System / Advanced" tab of the VoiceAttack options window, however I would recommend finding another way to achieve what you're trying to do.

If you don't have repeated words or phrase segments, you can use the "Contains" operator within your condition(s), in combination with the "{PREFIX}" and/or "{SUFFIX}" tokens.
For numbers you can use the "{TXTNUM:}" token to filter out anything but digits (though this will only work properly if you don't have more than one number in either prefix or suffix).


My personal preference is to use dynamic command sections instead of composite commands, using conditions to achieve the same result instead, which also allows the use of "{CMDSEGMENT:}".

Oss133

  • Newbie
  • *
  • Posts: 21
Re: CMDSEGMENT in a PREFIX
« Reply #2 on: August 19, 2019, 12:43:13 PM »
Do you never sleep?

Thank you again for your detailed reply. I will try and avoid the resource heavy solution.

UPDATE: I failed to avoid the resource heavy solution. I couldn't figure out how to use {TXTNUM} with {PREFIX} to extract the number I needed, and your personal preference doesn't suit the situation I have created.

GOOD NEWS THOUGH! Everything seems to work fine!
« Last Edit: August 20, 2019, 01:23:04 AM by Oss133 »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: CMDSEGMENT in a PREFIX
« Reply #3 on: August 20, 2019, 06:26:11 AM »
If you have a single number in the prefix, you should be able to extract it using something like
Code: [Select]
Set integer [i] value to the converted value of {TXTNUM:"{PREFIX}"}

As noted in the documentation
Quote from: VoiceAttackHelp.pdf page 145
This token can also render a literal text value or token, if the literal text or token is contained between double quotes.

Oss133

  • Newbie
  • *
  • Posts: 21
Re: CMDSEGMENT in a PREFIX
« Reply #4 on: August 21, 2019, 05:07:07 AM »
Thanks! I had missed the point about putting the token in double quotes. I will try this.

UPDATE: Works perfectly. Thank you.
« Last Edit: August 21, 2019, 04:33:41 PM by Oss133 »

Oss133

  • Newbie
  • *
  • Posts: 21
Re: CMDSEGMENT in a PREFIX
« Reply #5 on: August 22, 2019, 03:37:17 PM »
So,

I am trying a similar thing in a full command.

Code: [Select]
Set Text [MODNAME] to {TXT:"{CMDSEGMENT:0}"}
But the value of MODNAME remains Not Set.

Now what am I doing wrong?

Never mind. I figured it out!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: CMDSEGMENT in a PREFIX
« Reply #6 on: August 22, 2019, 03:47:27 PM »
Tokens are not variables.

You're trying to get the value of a text variable with the name of the first segment of your command surrounded by double quotes; As it is unlikely you set a variable with that name, "Not set" will be returned.


Tokens are replaced by literal text in fields that support them. E.G. If you set a variable named "myText" to "text", and use a token to retrieve that value (I.E. "{TXT:myText}"), that would have the exact same end result as directly typing in "text" instead.


As a side note, you can use the "Copy Selected as Text" or "Copy All as Text" options in the context menu for the action list for pasting into your post (I'm assuming you typed it instead, as the single quotes around the token are missing).

Oss133

  • Newbie
  • *
  • Posts: 21
Re: CMDSEGMENT in a PREFIX
« Reply #7 on: August 22, 2019, 03:52:20 PM »
Once again, thanks for the prompt help

Oss133

  • Newbie
  • *
  • Posts: 21
Re: CMDSEGMENT in a PREFIX
« Reply #8 on: August 23, 2019, 03:22:43 AM »
...As a side note, you can use the "Copy Selected as Text" or "Copy All as Text" options in the context menu for the action list for pasting into your post (I'm assuming you typed it instead, as the single quotes around the token are missing).

In fact, had I done that you would have seen square brackets instead of single quotes and realised how badly wrong I was getting this.