Given the following:
wscript.echo "fx(0)=" & fx(0)
Function fx( v1 )
fx = 1 + 2
Wscript.echo "fx=" & fx
End Function
Both “echo” lines print the value 3. Why doesn’t the one inside the function cause a syntax error or recursive loop? Same question with following sample:
wscript.echo "fy()=" & fy()
wscript.echo "fy=" & fy
Function fy
fy = 1 + 2
Wscript.echo "fy=" & fy
End Function
All echo lines print 3.
I can’t find documentation that describes the behavior when a function definition references it’s name as an RVALUE.
TIA.
Inside a VBScript function, the name of the function is a locally scoped variable intended to be equivalent to the return value that comes out of the function. It’s no different from any other
Dim var = .... To treat it as a function, you need to use call semantics.Basically, you seem to have gotten used to languages that have first-class functions. VBScript doesn’t have them, so there is no ambiguity.