Welcome Guest

Pages: 1
Elseif or Case Statement?
cpkPostMarch 2, 2015, 01:09
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicElseif or Case Statement?

Well I'm wondering now if there is a way (besides nested if statements) to get something like a Case or Switch statement or even just something like an elseif so that I can do a series of tests against one field nice and concise. I tried copying the else but it didn't like that which didn't surprise me but I was hoping anyway.

2MR2PostMarch 2, 2015, 07:59
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Elseif or Case Statement?

Nope. Many of the test oriented functions can AND or OR their result which gives you some compound testing abilities. For now the test construct is a simple if-else-endif

cpkPostMarch 2, 2015, 08:09
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicRe: Elseif or Case Statement?

I saw that and and or there but reading the help on it didn't make sense to me. It said something like if I AND then the result will be false and if I OR then the result will be true but it was never clear to me what exactly I was applying these operators to. Each of those logical operators should take two arguments and I don't see what the second one is. It is like should have two tests perhaps prior to the IF and that would make sense to me then. But I haven't played with them yet. I used nested IFs instead.

2MR2PostMarch 2, 2015, 09:23
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Elseif or Case Statement?

The action test state is what is tested by the 'if' statement. Many functions have the ability to set the action test state. Some also have the ability to AND or OR their result into the test state.

eg.

Test if the numeric value of the Variable 1 field >= "5" (Set result)
Test if the numeric value of the Variable 1 field <= "10" (And result)
if true
else
endif

cpkPostMarch 2, 2015, 19:47
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicRe: Elseif or Case Statement?

Hmm, I not really used to seeing tests like this outside and prior to the conditional statements and not seeing binary logical operators like AND not explicitly with both operands in any of the programming languages I am familiar with. Let us see if I understand what you are saying - in pseudocode, are you saying...

IF (Variable1 >= 5) AND (Variable1 <= 10) THEN
{DO something}
ELSE
{DO some other thing}
ENDIF

Or are you saying something else entirely?

2MR2PostMarch 2, 2015, 19:53
Avatar photo
Administrator
Posts: 2085
Registered:
August 23, 2012, 19:27
Normal topicRe: Elseif or Case Statement?

Yep, to be exact:

actionTestState = (Variable 1 >= 5)
actionTestState &= (Variable 1 <= 10)
if (actionTestState) then
...
else
...
end if

cpkPostMarch 2, 2015, 19:56
Advanced
Posts: 95
Registered:
March 1, 2015, 02:55
Normal topicRe: Elseif or Case Statement?

Ah! I see now! Thanks! I will be able to use this I'm sure of it.

Pages: 1
Mingle Forum by Cartpauj | Version: 1.1.0beta | Page loaded in: 0.018 seconds.