Difference between revisions of "Return"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Dejunai
m
imported>Dejunai
m
Line 5: Line 5:


[[Category: Commands]]
[[Category: Commands]]
-------------------------------------------------------
( never used a Wiki before, hope I do this right )
-------------------------------------------------------
I had a glitch in a script, and careful debugging has taught me that RETURN is a little more powerful than first suspected.
The scripts are designed with the BEGIN <event> syntax.
I was considering these independednt functions called seperately.
However if within the same frame execution you have more than one <event> expected to be processed, and use RETURN in the first <event> for any reason. No other <event>s will be processed.
The clear example I discovered, was using RETURN within an OnLoad event. Which ultimately glitched the necessary OnReset event. Because OnLoad and OnReset are processed at the same frame during a cell load the OnLoad event exited the script before the OnReset had a chance to process.
''Begin OnLoad
  If doOnce == 1
    Return
  Endif
  ; Stuff to do once
End
Begin OnReset
  ; Stuff to do every Reset
End''
The "stuff to do every reset" will only process the one time OnLoad processes.
RETURN as clearly stated in the Wiki exits the script, not the OnLoad function.
Just thought I would add this bit of business so others would not make the same mistake I did. I hope it helps.
-Dejunai

Revision as of 15:01, 16 April 2006

Syntax:

 return

Return is used to force the script to stop processing. This can be useful inside if statements where you want to prevent lines following the return from being processed.