Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 17th, 2007, 09:19 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old May 17th, 2007, 09:28 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
Reply With Quote
  #3 (permalink)  
Old May 17th, 2007, 09:50 PM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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

Reply With Quote
  #4 (permalink)  
Old May 18th, 2007, 06:42 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

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
================================================== =========
Reply With Quote
  #5 (permalink)  
Old May 21st, 2007, 09:20 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :)
Reply With Quote
  #6 (permalink)  
Old May 21st, 2007, 09:21 AM
Registered User
 
Join Date: May 2007
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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 :)



Reply With Quote
  #7 (permalink)  
Old May 21st, 2007, 09:26 AM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

In ASP you can't do this.

================================================== =========
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
================================================== =========
Reply With Quote
  #8 (permalink)  
Old May 21st, 2007, 09:53 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

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
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASSIGNING A JAVA SCRIPT VARIABLE TO A XSL VARIABLE SOMANATHAN10 XSLT 1 February 21st, 2007 04:26 AM
dynamic variable/object names TheBFJ Excel VBA 2 November 13th, 2006 07:11 AM
Object variable or With block variable not set tparrish VB Databases Basics 1 May 25th, 2005 10:25 AM
Problem with variable names shenku Javascript 2 May 6th, 2005 03:46 PM
Generate userform' s variables names joewidmer VB Databases Basics 0 September 17th, 2004 03:02 AM



All times are GMT -4. The time now is 06:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.