Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: GoSub Subroutine User Defined Function UDF
In programming circles, the preference is to limit the scope, or visibility, of all variables as much as possible. This is a carefully considered preference, based on long experience with variables that have global scope being accidentally changed by a routine that should never have referred to it. This can happen quite easily, especially with index variables, and the like. Let's say, for example, that your main script defines and use a loop index, iLoopIndex. Now, you define a subroutine, Sub1, which also has a loop index variable, iLoopIndex. Now, inside the loop of Sub1, you call another subroutine, Sub2, which uses the same index variable. I leave the consequences as an exercise for my readers.
Article ID: W18332
Filename: !! UDFs vs Subroutines !!.txt
File Created: 2009:07:07:09:02:42
Last Updated: 2009:07:07:09:02:42