Avoidinig globals
From: Tim (al_at_gahnstrom.se)
Date: 03/07/05
- Next message: Lamberti Fabrizio: "Re: Using Virtual Directory to remote folder"
- Previous message: cdsoftware: "!! DOWNLOAD THE MOST POPULAR 2005's CRACKED SOFTWARE(CAD/CAE/CAM/EDA/GIS/PCB/FEA) !!"
- Next in thread: Mark Schupp: "Re: Avoidinig globals"
- Reply: Mark Schupp: "Re: Avoidinig globals"
- Reply: Phill. W: "Re: Avoidinig globals"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 07 Mar 2005 20:14:36 GMT
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
- Next message: Lamberti Fabrizio: "Re: Using Virtual Directory to remote folder"
- Previous message: cdsoftware: "!! DOWNLOAD THE MOST POPULAR 2005's CRACKED SOFTWARE(CAD/CAE/CAM/EDA/GIS/PCB/FEA) !!"
- Next in thread: Mark Schupp: "Re: Avoidinig globals"
- Reply: Mark Schupp: "Re: Avoidinig globals"
- Reply: Phill. W: "Re: Avoidinig globals"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|