Reserved word "Exit" ?

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Gnafu
Grandmaster Poster
Posts: 136
Joined: Thu Feb 02, 2006 7:29 am

Reserved word "Exit" ?

Post by Gnafu »

What does it do?
What is the difference between exit; and return; ?
User avatar
OldnGrey
POL Expert
Posts: 657
Joined: Sat Feb 04, 2006 6:26 pm

Post by OldnGrey »

Okay, correct me if I am wrong, but you should end all functions with a return x; statement.

As far a the program body itself, I have seen exit used to quit the program (eg inside a loop) However I notice that a lot of scripters use return to quit a program body - perhaps they are equivalent.
Bracco
Adept Poster
Posts: 80
Joined: Thu Dec 28, 2006 11:52 am

Post by Bracco »

that's a good question...

i believe that exit just terminates the current script, regardless from where it is called (for example inside a function)
while return just ends the current function (that can also be the main program of course)

also if there isn't a return then the function returns 0 automatically i guess
Danielle
Grandmaster Poster
Posts: 104
Joined: Tue Feb 07, 2006 3:32 pm

Post by Danielle »

I believe Bracco is correct.

Calling "exit" will terminate the current script immediately.

And calling "return" will end the current function/program. Return can, as mentioned, be called with or without a variable. When called without a variable, "return", it is the same as calling "return 0".

P.S. Good job on the wiki so far Gnafu!
Post Reply