Home > Language Reference > Program Flow Functions > End

End

The End function ends current execution and can return a value.

Usage

Used to stop immediately an execution and return a value to a calling script where the return code can be processed.

Syntax

End([<ret>])

Parameter

<ret>, optional, integer, constant. This value can then be used by the calling script. The default value is 0.

See also

Stop
Parameters passed from one script to another

Example

' Script 1
    'Loop until script2 returns 0 for a maximum of 3 iterations
    i=0
    repeat
        'Kill Internet Explorer as script2 launches it
        KillApp("Iexplore.exe",1)
        ret=Run("script2")
        i=i+1
    until ret=0 OR i=3 


'Script 2
    #IgnoreErrors=1  'Ignore errors
    StartBrowser("IE","www.wintask.com/demos")
    ' Test the return code of UsePage, if the page is not loaded within 30 seconds (default timeout), 
    'end the script with a return code of 2
    ret=UsePage("WinTask Demonstration")
    If ret <> 0 then   'If the return code of UsePage is not 0, there is an error, end the script with return code 2
        End(2)
    Else
        End(0)      'The UsePage succeeded, end the script with return code 0
    EndIf