Author Topic: Having trouble comparing two variables  (Read 918 times)

DeckerdJames

  • Newbie
  • *
  • Posts: 5
Having trouble comparing two variables
« on: April 30, 2020, 01:44:51 PM »
Hello, I am new to using VoiceAttack but I really like it. It is a great program. I apologize if I am missing something obvious but I am having trouble with this bit of code. I do not understand why these two variables do not match. The output in the log follows and the code snippet is after that. In the log output, the [] brackets contain the contents of the variables and they appear to be the same. I tried changing the code so that I was comparing two ~~command scoped variables in case the comparison also compared types, but the output is the same. Thank you so much for your program and your time.

Quote
Ship Selection Control - Programs - Attempt to load [~~New Ship Type] - [Failed] Ship Stations Not Started - [vulture] does not equal [vulture]

Code: [Select]
    Begin Text Compare : [>Current Ship Type] Equals '~~New Ship Type'
        Execute command, 'Ship Station Control - Program - Start Ship Stations' (and wait until it completes)
    Else If Text Compare : [>Current Ship Type] Does Not Equal '~~New Ship Type'
        Set text [~~FlowMessage] to 'Ship Selection Control - Programs - Attempt to load [~~New Ship Type] - [Failed] Ship Stations Not Started - [{TXT:~~New Ship Type}] does not equal [{TXT:>Current Ship Type}]'
    End Condition

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Having trouble comparing two variables
« Reply #1 on: April 30, 2020, 01:51:15 PM »
You're comparing the contents of a variable to literal text, not the contents of two variables.

I.E. the contents of a text variable named ">Current Ship Type", to the literal string "~~New Ship Type".


Also note that checking for both "Equals" and "Does Not Equal" is redundant, unless you're specifically doing so in case the variable is not set.
If you have the "Evaluate 'Not Set' as empty (blank)" option checked, there are only two possible outcomes, so you can do one check, and use the "Condition Else" action instead of the "Add Else If to Conditional Block" action.

DeckerdJames

  • Newbie
  • *
  • Posts: 5
Re: Having trouble comparing two variables
« Reply #2 on: April 30, 2020, 02:05:04 PM »
I have to laugh. I figured it was something obvious. Thank you for the tip about the 'Not Set' check box, I will have to make a decision about whether I need to know the difference between False and 'Not Set'.