Welcome to WebmasterWorld Guest from 220.127.116.11
Forum Moderators: ocean10000
Here's an example:
Var1 = "foo"
Var2 = "bar"
Response.write Var1 & Var2
Although MySub has no arguments and can't return a value, after it's called two variables automagically appear. Amazing! I've also come across similar subroutines that create connections, recordsets, etc.
Now, if I'm not mistaken a Sub is Public by default, but IMHO no arguments and creating variables to use outside the scope of the sub is just asking for trouble. Is this some old school technique or just plain bad coding?
Well, although VBscript apparently makes this kind of statement possible, it doesn't score high marks for readability.
A possible refactoring is to create a method that returns a class that contains the properties that are needed on each page (Var1, Var2).