Author Topic: [v1.8.3.15] "{CMDSEGMENT:}" inconsistencies with shortcut-triggered commands  (Read 1425 times)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
When the "{CMDSEGMENT:}" token is used in a command that is executed by shortcut (I.E. keyboard key, joystick button, or mouse button, but not "Execute Another Command" action with the "Execute selected command" option selected, or the command list context menu; Inline function/plugin and the "Execute by name (Advanced)" option are equivalent to spoken commands in this context), only one particular order of phrases/dynamic sections allows the token to function:

If "When I say" is set to "phrase 1;phrase [2;3]", "{CMDSEGMENT:0}" will return "phrase 1"
If "When I say" is set to "phrase [1;2];phrase 3", "{CMDSEGMENT:0}" will return "Not Set"
If "When I say" is set to "phrase 1;phrase 2", "{CMDSEGMENT:0}" will return "Not Set"

So when executing a command using a keyboard key, joystick button, or mouse button, "{CMDSEGMENT:}" only works if the first possible phrase has no dynamic segments, but any following phrase does have dynamic segments.


I'd argue it would be more consistent for "{CMDSEGMENT:}" to not work at all with non-spoken phrases, rather than only in this very particular set of circumstances.


EDIT: Behavior changed in v1.8.3.19; "{CMDSEGMENT:}" now always returns "Not Set" for shortcut-triggered top-level commands
« Last Edit: February 25, 2020, 03:37:41 PM by Pfeil »

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2832
{CMDSEGMENT} is intended for use with spoken commands only and will cause unpredictable results if used otherwise (various levels of caching from other places will cause this - it's not figured out at the point that the command is executed).  I will (hopefully) make it return, 'Not Set' consistently. I'll get this into the help doc.   Thanks for the heads up!

Edit - updated to return, 'Not Set' unless a spoken phrase was used for exec.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
v1.8.3.16 corrects the behavior when a command is triggered using a shortcut, however it also affects commands executed using the "Execute by name (Advanced)" option of the "Execute Another Command" action, and the "Command.Execute()" method.

In case of the former, segment info is only available when the calling command is spoken. Executing the calling command using a shortcut will result in "{CMDSEGMENT:}" also returning "Not Set" within the called command.

In case of the latter, segment info is only available if the calling command is spoken, and the "AsSubcommand" parameter is set to "true".