Announcement

Collapse
No announcement yet.

Instr

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • travisdh
    replied
    Thanks for the tips, most appreciated!

    Leave a comment:


  • reidfo
    replied
    Originally posted by travisdh View Post
    This is an example of one of my current script sections:

    If Instr(1,data,"ALERT",1) > 0 and Instr(1,data,"[BEUP]",1) > 0 then
    'do stuff
    End If
    So this will execute 'stuff' if both strings are contained within data.

    How can I set it so that in this example, if the string contains [BEUP] but not ALERT then to 'do stuff
    If Instr(1,data,"ALERT",1) = 0 and Instr(1,data,"[BEUP]",1) > 0 then
    'do stuff
    End If

    Instr returns 0 when string2 is not found within string1, so this example would execute if [BEUP] was found but not ALERT.

    String Contains Neither X or Y is simply:
    If Instr(1,data,"ALERT",1) = 0 and Instr(1,data,"[BEUP]",1) = 0 then

    Leave a comment:


  • travisdh
    started a topic Instr

    Instr

    Hi Guys,

    I am using a few scripts at the moment that use Instr to determine if there is a phrase in the string, and then to do something with that string, so e.g. If the String contains X and Y then do Z

    I am sure it is simple, but how can i do an instr where only one condition exists, e.g. the string contains X but not Y, then does Z.

    This is an example of one of my current script sections:

    If Instr(1,data,"ALERT",1) > 0 and Instr(1,data,"[BEUP]",1) > 0 then
    'do stuff
    End If

    How can I set it so that in this example, if the string contains [BEUP] but not ALERT then to 'do stuff

    Ideally id like to be able to have three conditions eventually,

    String contains both X + Y
    String Contains Only X
    String Contains Neither X or Y

    Thanks
Working...
X