T
Tim
Is there a way to force a sub to only use global variables when
explicitly told to?
I mean that if I forget to dim a a local variable but there is already
such a variable in the global scope then my function will use the global
variable without me intending it too.
Here is an example:
<html>
<% Option Explicit
sub corect()
Dim var
var=5
end sub
sub wrong()
var=5
end sub
Dim var
var=2
response.write(var) 'prints rightly 2
call corect()
response.write(var) 'Still prints rightly 2
call wrong()
response.write(var) 'Now it prints 5 because I forgott to Dim var
%>
<html>
I would have liked to be able to declare a Globals Explicit this should
force me to write
sub wrong()
global var=5
end sub
If I wanted wrong to change the behavior of the globaly defined variable
var.
Is there a way to acomplish this in ASP?
Thanks
Tim
explicitly told to?
I mean that if I forget to dim a a local variable but there is already
such a variable in the global scope then my function will use the global
variable without me intending it too.
Here is an example:
<html>
<% Option Explicit
sub corect()
Dim var
var=5
end sub
sub wrong()
var=5
end sub
Dim var
var=2
response.write(var) 'prints rightly 2
call corect()
response.write(var) 'Still prints rightly 2
call wrong()
response.write(var) 'Now it prints 5 because I forgott to Dim var
%>
<html>
I would have liked to be able to declare a Globals Explicit this should
force me to write
sub wrong()
global var=5
end sub
If I wanted wrong to change the behavior of the globaly defined variable
var.
Is there a way to acomplish this in ASP?
Thanks
Tim