Topic
6 replies Latest Post - ‏2014-06-11T23:18:25Z by jgstew
TLSM
TLSM
8 Posts
ACCEPTED ANSWER

Pinned topic If-Else statement with condition

‏2014-05-13T23:01:10Z |

Hi All,

I would like to create a task that can change the primary relay server to accordingly relay server.

I have the action but I still need a condition If-Else statement.

If (Condition = IP contain of 10.0.10. AND Primary Relay server NOT EQUAL TO 10.0.10.15)
{
setting "__RelaySelect_Automatic"="0" on "Wed, 26 Mar 2014 07:36:25 +0000" for client
setting "__RelayServer1"="http%3a%2f%2f10%2e0%2e10%2e15%3a52311%2fbfmirror%2fdownloads%2f" on "Wed, 26 Mar 2014 07:36:25 +0000" for client
setting "__RelayServer2"="http%3a%2f%2f10%2e0%2e10%2e15%3a52311%2fbfmirror%2fdownloads%2f" on "Wed, 26 Mar 2014 07:36:25 +0000" for client
} Else IF (Condition)
{
Action
}..
 

Can anyone help me to verify the condition?

I had try few but seem do not working.

I had 2 conditions needed:

1) Contain IP 10.0.10. (Example)

2) Primary relay Not Equal 10.0.10.15

Many thanks.

  • jgstew
    jgstew
    410 Posts
    ACCEPTED ANSWER

    Re: If-Else statement with condition

    ‏2014-05-14T19:39:25Z  in response to TLSM

     

    Your syntax for IF statements in actionscript does not appear correct. There seems to be issues with the relevance as well.

     

    if { (relevance) }

     

    elseif { (relevance) }

     

    endif

  • TLSM
    TLSM
    8 Posts
    ACCEPTED ANSWER

    Re: If-Else statement with condition

    ‏2014-05-22T16:43:36Z  in response to TLSM

    Hi jgstew,

     

    Thanks for your replied.

    But it is possible that I match 2 condition into the relevance?

    Because I wish to match the IP address segment (contain 10.0.10.) and Not match with the Relay server (Relay server != 10.0.10.15)

    Relevance 1:

    (exists true whose (if true then (exists (if ( exists true whose (if true then ( exists ip interfaces of network) else false) ) then addresses whose (it as string != "0.0.0.0") of ip interfaces whose (not loopback of it) of network as string else nothing) whose (it as string as lowercase contains "10.0.10." as lowercase)) else false))

    Relevance 2:

    (exists true whose (if true then (not exists (if ((it does not contain "127.0.0.1" and it does not contain "::1") of name of registration server) then (name of registration server) else if (exists setting "_BESRelay_PostResults_ParentRelayURL" of client and exists value of setting "_BESRelay_PostResults_ParentRelayURL" of client as string) then (preceding text of first "/" of (following text of first "//" of (value of setting "_BESRelay_PostResults_ParentRelayURL" of client))) else "BES Root Server") whose (it as string as lowercase = "10.0.10.15" as lowercase)) else false))

     

    Can we insert so long condition relevance into our task? or how should I shorten it and run the task?

    Anyone can guide or advice me?

    Thanks

    • Tim.Rice
      Tim.Rice
      79 Posts
      ACCEPTED ANSWER

      Re: If-Else statement with condition

      ‏2014-05-23T14:01:07Z  in response to TLSM

      Rather than creating a single Task to try and handle all the conditions, why not build the conditions into the Relevance for the Task itself?

      That way you don't need ANY if/then/else logic in the Action script at all.  Just create as many Tasks as you need to cover all the conditions.

      Updated on 2014-05-23T14:02:04Z at 2014-05-23T14:02:04Z by Tim.Rice
    • jgstew
      jgstew
      410 Posts
      ACCEPTED ANSWER

      Re: If-Else statement with condition

      ‏2014-06-01T21:09:27Z  in response to TLSM

       

      You can have as many relevance statements combined as you want.

       

      If{ ( (relevance1) AND (relevance2) ) OR relevance3 }

      endif

       

      Though, I do agree with Tim, that in most cases you should break up your tasks into smaller pieces that run separately when possible with the relevance required for each, then just take all of the actions simultaneously. 

       

      I am also wondering what you are trying to achieve, and if there might be an easier way to do it.

       

      Updated on 2014-06-01T21:12:54Z at 2014-06-01T21:12:54Z by jgstew
  • JasonWalker
    JasonWalker
    51 Posts
    ACCEPTED ANSWER

    Re: If-Else statement with condition

    ‏2014-06-08T19:50:29Z  in response to TLSM

    I'm confused.  Are you asking "What's the syntax for an IF / ELSE / ENDIF Statement", or are you asking "What inspectors can I use to retrieve my client's IP address and the current registration server"?

    • jgstew
      jgstew
      410 Posts
      ACCEPTED ANSWER

      Re: If-Else statement with condition

      ‏2014-06-11T23:18:25Z  in response to JasonWalker

       

      I wasn't sure either. I think both are at issue.