Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF Statement

Status
Not open for further replies.

dbomrrsm

Programmer
Feb 20, 2004
1,709
GB
Just want confirmation on how if statements work.

If I have something like:

Code:
IF my_var < 10
THEN do something
elsif my_var < 100
THEN do something
else do something
end

if my_var was 9 this be picked up in the first evaluation ie the first if. That being the case my question is: Are the other elements of the if statement evaluated or will the process jump to the end of the code as soon as one of the ifs are met.

TIA

[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 
dbomrrsm,

it's all good except the last line, which should be
Code:
 end if;

For the sake of consistency I would capitalise the key words i.e.
Code:
IF my_var < 10
THEN do something
ELSIF my_var < 100
THEN do something
ELSE do something
END IF;


T

Grinding away at things Oracular
 
T

Thanks for the pointers but it wasnt the syntax I needed help on. It was how if operates and I have now proved for myself that the first if that is met will mean a jump to the end if.

Thanks anyhow.

[bandito] [blue]DBomrrsm[/blue] [bandito]

[blue]Software code, like laws and sausages, should never be examined in production[/blue][black] - [/black][purple]Edward Tenner[/purple]
 

It will execute the statements of the first true condition snd ignore the rest. [3eyes]



----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top