Post Reply 
multi criteria IF statement
06-11-2021, 11:06 AM
Post: #1
multi criteria IF statement
Hello,

I'm trying to write a program for directional angle calculation.

But my issue are the IF statements.

I have to test two variables in 4 different scenarios.

example Local y,x,n;

IF ( y>0 and x>0) then n:=ATAN( y/x); /// 1' scenario if the y or x is not greater next test
IF( y>0 and x<0) then n:=ATAN (y/x)+180; //// 2' scenario
IF( y<0 and x<0) then n:=ATAN(y/x)+180; //// 3' scenario
IF ( y<0 and x>0) then n:=ATAN(y/x)+360; ///// 4'

And i'm not sure how to write it.

Code:
IF ( y>0) THEN
    IF (x>0) THEN
    n:=ATAN(y/x);
    ELSE
IF ( y>0) THEN
    IF( x<0) THEN
    n:=(ATAN(y/x))+pi;
    ELSE
IF ( y<0) THEN
    IF(x<0) THEN
    n:=(ATAN(y/x))+pi;
    ELSE
    n:=(ATAN(y/x))+(2*pi);

I have tried like that, but i't doesnt give the correct awnser. And also at end of program i have to write END; like 6 times or so.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
multi criteria IF statement - Amer7 - 06-11-2021 11:06 AM
RE: multi criteria IF statement - Amer7 - 06-11-2021, 11:59 AM
RE: multi criteria IF statement - Dougggg - 06-12-2021, 03:05 AM
RE: multi criteria IF statement - Joe Horn - 06-13-2021, 01:10 PM



User(s) browsing this thread: 1 Guest(s)