[thelist] naming variables dynamically
Amazon Paulo
Amazon.Paulo at Amazoniacelular.com.br
Wed Jul 31 12:06:01 CDT 2002
Michael,
>Is it possible to name variables dynamically? I'm stuck.
yes you can name variables dynamically. This is an example:
for i = 1 to 10
execute ("variable" & i & " = " & i)
next
This is the same as:
variable1 = 1
variable2 = 2
variable3 = 3
etc.
But I'd rather use the Dictionary object:
Set sd = Server.CreateObject("Scripting.Dictionary")
for i = 1 to 10
sd("variable" & i) = i
next
So we'll have sd("variable1"), sd("variable2") etc. Do not forget to set it
to nothing.
The major difference is about performance: using the "execute" statement,
ASP will parse the code twice. IIS will first execute the "execute"
statement itself, and then the "variablex = x".
I hope I have helped you.
/Paulo Guedes
More information about the thelist
mailing list