|
|
 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

May 17th, 2007, 10:19 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
generate variable names dinamycally
Hi, I can't figure out how to do this so please I need advice.
Let's say that I have for next loop
like
for i = 1 to N
which N is dynamically generated so i dont know the exact value
now I need to create vars that goes from 1 to N in order to send them in an url
Example:
I need to generate
var1
var2 ..... varN
of course each one will have a value and that...
It cant be in an array since I'm sending those vars in an url.
TIA
|

May 17th, 2007, 10:28 PM
|
|
Wrox Author
Points: 12,801, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,023
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
You can't do this. You cant do, for example:
for i=0 to 5
Dim DynamicVariablei
next
In this case, this will create a variable named DynamicVariablei and not DynamicVariable0, DynamicVariable1, etc.
Variable values are not evaluated in a varible declartion, and this makes sense.
Why can't you use an array?
for i=0 to ubound(myArray)
Response.redirect "www.mydoamin.com/page.asp?var1=" + myArray(i)
next
That would work just fine.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|

May 17th, 2007, 10:50 PM
|
|
Registered User
|
|
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i understand what you say.
What I need to do is to get 5 questions (id and string) and 2-4 answer per question (id and string) and send them into a Flash in an url
Is there anther way to state that?
Another question how do I use the DynamicVariablei you created to recall data from it?
TIA
|

May 18th, 2007, 07:42 AM
|
|
Wrox Author
Points: 12,801, Level: 49 |
|
|
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,023
Thanks: 1
Thanked 42 Times in 42 Posts
|
|
In this instance you are probably going to want to use an array, as I demonstrated in my second example above, so just build your query string off of the values in your array.
You would use DynamicVariablei like any other variable you declare.
================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
|

May 21st, 2007, 10:20 AM
|
|
Registered User
|
|
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi gcorcuera
I think u can generate variable names using a perl-like notation like below:
for ($i to N)
${"var".$i};
This will generate var1, var2 ..... varN, which u can assign values to.
Hope this helps :)
|

May 21st, 2007, 10:21 AM
|
|
Registered User
|
|
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi gcorcuera
I think u can generate variable names using a perl-like notation like below:
for ($i to N)
${"var".$i};
This will generate var1, var2 ..... varN, which u can assign values to.
Hope this helps :)
|

May 21st, 2007, 10:53 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 685
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
You can use Execute() in ASP to generate variables:
Code:
For i = 1 To 5
Execute "var" & i & " = " & i
Execute "Response.Write var" & i & " & ""<br>"""
Next
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |