Page 1 of 1

Help with recurrinf 'If' statement

Posted: 29 Nov 2012, 03:43
by MarkyBoy
Hi all, I have a load of 'If' statements that look at the text in a text box and open a window according to what's in the text box... the code is as below:
TextBox1.GetSelectedText()===
If TextBox1.GetSelectedText()==="Answer A"
Open Window "window1"
End If
If TextBox1.GetSelectedText()==="Answer B"
Open Window "window1"
End If
If TextBox1.GetSelectedText()==="Answer C"
Open Window "window1"
End If
If TextBox1.GetSelectedText()==="Answer D"
Open Window "window1"
End If
If TextBox1.GetSelectedText()==="Answer E"
Open Window "window2"
End If
If TextBox1.GetSelectedText()==="Answer F"
Open Window "window2"
End If
If TextBox1.GetSelectedText()==="Answer G"
Open Window "window2"
End If

What I'd like to do is compact the script so that one If statement covers all options, so reducing the above code to something like:
TextBox1.GetSelectedText()===
If TextBox1.GetSelectedText()==="Answer A" OR "Answer B" OR "Answer "C" etc...
Open Window "window1"
End If
If TextBox1.GetSelectedText()==="Answer D" OR "Answer E" OR "Answer F" etc...
Open Window "window2"
End If

But I can't find an 'or' statement... Does anyone know how I can combine them something like above?

Help with recurrinf 'If' statement

Posted: 03 Dec 2012, 22:26
by Matthias Guenther (Quark)
Hi Mark,
first, you should use "==" for equal, not "===" please.
The OR statement is "||".
Thanks
Matthias

Help with recurrinf 'If' statement

Posted: 03 Dec 2012, 22:42
by MarkyBoy
Hi Matthias
Okay, it seems both "==" and "===" will work, why do you suggest using "==" ?
The OR statement?... Thank you! For some reason, I just could not find this in the list of operators, I must be going blind! Works fine!
I haven't quite finished this project, but would you be interested in seeing a preview?!

Help with recurrinf 'If' statement

Posted: 04 Dec 2012, 02:53
by Matthias Guenther (Quark)
Hi Mark,
=== is a strict equal, which means the datatype must also be correct. SO if you use this instead of == you alsways need to worry that you maybe compare two different datatypes and therefore ge a FALSE.
Regards
Matthias