Author Topic: How do I 'not' use Compound Condition Builder for this?  (Read 1259 times)

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
How do I 'not' use Compound Condition Builder for this?
« on: October 02, 2019, 04:06:56 PM »
I'm revisiting an old command version that I had apparently discarded, and conceded to use the Compound Condition Builder instead of a small text array that I can continually and easily expand as needed.  Not the biggest deal, of course I can just keep using the Compound Condition Builder as in example 2 below, but I'm confused because I thought I had a good understanding of this, and maybe I'm just misunderstanding something yet again. ;)

This works well:

Code: [Select]
COMMAND:  "[Enable;Allow;Initialize;Turn On;Turn Off;Disable;Terminate] Push To Talk Mode"

Set Text [~avcs_on] to 'Enable Allow Initialize Turn On'
Set Text [~avcs_off] to 'Turn Off Disable Terminate'
//
Begin Text Compare : [~avcs_on] Contains '{CMDSEGMENT:0}'
    Write [Purple] 'ON command fired' to log
End Condition - Exit when condition met
//
Begin Text Compare : [~avcs_off] Contains '{CMDSEGMENT:0}'
    Write [Pink] 'OFF command fired' to log
End Condition - Exit when condition met


...and this works well:

Code: [Select]
COMMAND: "[deploy;extend;extent;lower;raise;retract;toggle;] [the;the landing;landing;] [gear] [down;up;]"

Begin Condition : [{CMDSEGMENT:0}] Contains 'raise' OR [{CMDSEGMENT:0}] Contains 'retract' OR [{CMDSEGMENT:3}] Contains 'up'
    Write [Purple] 'UP command fired' to log
End Condition - Exit when condition met
//
Begin Condition : [{CMDSEGMENT:0}] Contains 'deploy' OR [{CMDSEGMENT:0}] Contains 'extend' OR [{CMDSEGMENT:0}] Contains 'extent' OR [{CMDSEGMENT:0}] Contains 'lower' OR [{CMDSEGMENT:3}] Contains 'up'
    Write [Pink] 'DOWN command fired' to log
End Condition - Exit when condition met




...but why does this not work? I'd love to use this command like this, without a suffix/prefix, in a single command where I can adjust the ~up/~down words in a simple text array variable, without entering a *long* compound condition builder if possible:

Code: [Select]
COMMAND: "[deploy;extend;extent;lower;raise;retract;toggle;] [the;the landing;landing;] [gear] [down;up;]"

Begin Text Compare : [{CMDSEGMENT:0}] Contains 'toggle'
    Write [Orange] 'toggle command fired' to log
End Condition - Exit when condition met
//
Set Text [~up] to 'raise retract up'
Set Text [~down] to 'deploy extend extent lower'
Begin Condition : [~up] Contains '{CMDSEGMENT:0}' OR [~up] Contains '{CMDSEGMENT:3}'
    Write [Purple] 'UP command fired' to log
End Condition - Exit when condition met
//
Begin Condition : [~down] Contains '{CMDSEGMENT:0}' OR [~down] Contains '{CMDSEGMENT:3}'
    Write [Pink] 'DOWN command fired' to log
End Condition - Exit when condition met


example profile attached:


*edit: FTR, I had tried a bit of case sensitivity, and quickly abandoned that line of thinking, would hate if there was some trick there I missed

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: How do I 'not' use Compound Condition Builder for this?
« Reply #1 on: October 02, 2019, 04:24:52 PM »
If a segment is blank, String.Contains (the method called behind the scenes) will return true:
Quote from: https://docs.microsoft.com/en-us/dotnet/api/system.string.contains?view=netframework-4.8
true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

You could add a check to make sure either segment isn't blank:
Code: [Select]
//  THIS IS THE DESIRED VERSION IF POSSIBLE
//
Begin Text Compare : [{CMDSEGMENT:0}] Contains 'toggle'
    Write [Orange] 'toggle command fired' to log
End Condition - Exit when condition met
//
//
Set Text [~up] to 'raise retract up'
Set Text [~down] to 'deploy extend extent lower'
Begin Condition : ([{CMDSEGMENT:0}] Does Not Equal '' AND [~up] Contains '{CMDSEGMENT:0}') OR ([{CMDSEGMENT:3}] Does Not Equal '' AND [~up] Contains '{CMDSEGMENT:3}')
    Write [Purple] 'UP command fired' to log
End Condition - Exit when condition met
//
Begin Condition : ([{CMDSEGMENT:0}] Does Not Equal '' AND [~down] Contains '{CMDSEGMENT:0}') OR ([{CMDSEGMENT:3}] Does Not Equal '' AND [~down] Contains '{CMDSEGMENT:3}')
    Write [Pink] 'DOWN command fired' to log
End Condition - Exit when condition met


As a side note, the brackets around "gear" are redundant (they will not affect segment numbering when removed).

I also believe "~down" is, ironically, missing "down" as a possible word.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 291
  • Upstanding Lunatic
    • My AVCS Homepage
Re: How do I 'not' use Compound Condition Builder for this?
« Reply #2 on: October 02, 2019, 04:32:25 PM »
Oh yea, that's a slap-dash example, the correct command array does contain "down" for the use of Command Segment 3

Also, thanks for the clarification on the brackets around gear.

Thanks for the great info (once again)!!  I'll use that check and forget about it.  Very happy customer.

U rock Pfeil! Cheers!