Exemple de sous-routine
L’exemple suivant montre la déclaration de sous-routine et l’invocation.
[create $outputpath & $module & "output.txt"
' define sub SimpleSub() Sub SimpleSub() ]SimpleSub() called [endsub
' execute sub SimpleSub() Call SimpleSub()
$ParamByValue = "Original Value" ]ParamByValue = [=$ParamByValue] [$ParamByRef = "Original Value" ]ParamByRef = [=$ParamByRef]
' define sub CompleteSub() [Sub CompleteSub( $param, ByVal $paramByValue, ByRef $paramByRef ) ]CompleteSub called. param = [=$param] paramByValue = [=$paramByValue] paramByRef = [=$paramByRef] [$ParamByRef = "Local Variable" $paramByValue = "new value" $paramByRef = "new value" ] Set values inside Sub [$ParamByRef = "Local Variable" $paramByValue = "new value" $paramByRef = "new value" ]CompleteSub finished. [endsub
' run sub CompleteSub() Call CompleteSub( "FirstParameter", $ParamByValue, $ParamByRef ) ] ParamByValue=[=$ParamByValue] ParamByRef=[=$ParamByRef] [ Fermer ] |