using local object variables in vbscript subs and functions is extremely slow when not using dim!
compare...
Code: Select all
start_t = timer
for n = 0 to 1000
Set s = getvar()
next
logmessage("time=" & 1000*(timer-start_t) & " milliseconds")
function getvar()
Set i = Application.Selection
Set getvar = i
end function
outputs
whiletime=492,1875 milliseconds
Code: Select all
start_t = timer
for n = 0 to 1000
Set s = getvar()
next
logmessage("time=" & 1000*(timer-start_t) & " milliseconds")
function getvar()
Dim i
Set i = Application.Selection
Set getvar = i
end function
outputs
only difference is the "Dim i" !time=3,90625 milliseconds
It's probably a good idea to use "option explicit" at the top of the script so you're forced to declare everything