Author Topic: text compare command and text arrays  (Read 1241 times)

HILOK

  • Newbie
  • *
  • Posts: 5
text compare command and text arrays
« on: October 04, 2022, 10:42:03 AM »
hi there, could somebody please help me with this:

Code: [Select]
Set text [cancel] to 'cancel;stop'
Wait for spoken response:'{TXT:cancel}'
Begin Text Compare : [response] Contains [cancel]
[...]

so here's the thing: the array passes the 'Wait for...' function, whether i say "cancel" or "stop", no problem. but none of the words are identified within the 'text compare' part. i tried lots of things already, including replacing '[cancel]' with '{TXT:cancel}', 'Equals' iso 'Contains', and all combos thereof. also looked up the forums, but couldnt find any solution unfortunately. vap attached.

any help much appreciated, thanks!!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: text compare command and text arrays
« Reply #1 on: October 04, 2022, 10:47:31 AM »
There is no such thing as text arrays in VoiceAttack.

Comparing the literal text "cancel" against the literal text "cancel;stop" correctly won't result in a match, as they're not the same text. The semicolon has no special meaning in this context, it's just another literal character.


In this particular case you could switch the order of your comparison, and check whether the value of your "cancel" variable contains the response (as "cancel;stop" will contain both "cancel" and "stop").
This is only viable when there is no possibility that a response is contained within part of the other text, however (assuming you intend to check multiple possibilities separately later on, as otherwise there is no need for a condition at all as the response will either always be one of your predefined responses, Not set, or "@@invalid").

HILOK

  • Newbie
  • *
  • Posts: 5
Re: text compare command and text arrays
« Reply #2 on: October 05, 2022, 03:03:53 AM »
thanks for your reply, pfeil!
the intriguing thing for me was that the method worked for the "wait for..." block, and i was wondering, if i was doing sth wrong within the "compare" block. so, it's not possible, ok.

thanks 😊

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: text compare command and text arrays
« Reply #3 on: October 05, 2022, 03:07:51 AM »
The "Wait For Spoken Response" action explicitly uses the same syntax as regular command phrases, so semicolons have special meaning within its input field (dynamic command sections, including numeric ranges, also work).

Press F1 while VoiceAttack has focus to open VoiceAttackHelp.pdf in your default PDF viewer, which contains information on VoiceAttack's features.

HILOK

  • Newbie
  • *
  • Posts: 5
Re: text compare command and text arrays
« Reply #4 on: October 05, 2022, 11:22:42 AM »
actually there's a way to do it like this
Code: [Select]
Set text [cancel(0)] to 'cancel'
Set text [cancel(1)] to 'stop'
Wait for spoken response:'{TXT:cancel}'
Begin Condition : [response] Equals [cancel(0)] OR [response] Equals [cancel(1)]
[...]
caveat: this method only works for single words like "stop", not for several words like "stop procedure"

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: text compare command and text arrays
« Reply #5 on: October 05, 2022, 11:33:50 AM »
That would not be a working example, as the "cancel" variable would not be set.

If you're referring to using the condition builder to perform multiple checks, yes, that's exactly why that exists, and how it would normally be done.

HILOK

  • Newbie
  • *
  • Posts: 5
Re: text compare command and text arrays
« Reply #6 on: October 05, 2022, 12:06:57 PM »
it does work, i tried it

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: text compare command and text arrays
« Reply #7 on: October 05, 2022, 12:12:02 PM »
Then you have set the value of the text variable named "cancel" elsewhere.

Otherwise, the only available phrase for the "Wait For Spoken Response" action would be "not set".

HILOK

  • Newbie
  • *
  • Posts: 5
Re: text compare command and text arrays
« Reply #8 on: October 06, 2022, 12:32:45 AM »
well, i'll have a look. thought variables are local to the command, but if not, that could explain it...

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4785
  • RTFM
Re: text compare command and text arrays
« Reply #9 on: October 06, 2022, 12:36:04 AM »
They are not. As mentioned in the documentation, and summed up at the end here.