Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: UDS global scope caller scope
; WinBatch 2002F #definesubroutine bug/feature #definesubroutine BAR() message("BAR", strcat("In BAR G_VAR=", G_VAR)) #endsubroutine #definesubroutine BAZ() message("BAZ", strcat("In BAZ, about to call BAR, G_VAR=", G_VAR)) BAR() #endsubroutine #definefunction FOO() if (isdefined(G_VAR)) then message("FOO", strcat("In FOO, about to call BAR, G_VAR=", G_VAR)) else message("FOO", "In FOO, about to call BAR, G_VAR is *UNDEFINED*") endif bar() #endfunction G_VAR = 42 ; This works as expected since BAR() sees G_VAR in the caller's scope (the ; global scope in this case). BAR() ; This works as expected since BAR() sees G_VAR in the BAZ()'s scope which ; received it from the global scope. BAZ() ; This fails in 2002F. It should work according to the doc which claims ; #definesubroutines handle variables as globals. Instead it crashes because ; #definesubroutines really only take the caller's scope into consideration. FOO()
#DefineSubroutine runs at the caller's scope, not global scope.
Article ID: W15741
File Created: 2003:05:13:11:29:54
Last Updated: 2003:05:13:11:29:54