p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
I forgot my password Register Now
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 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.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 17th, 2007, 10: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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old May 17th, 2007, 10:28 PM
Wrox Author
Points: 12,801, Level: 49
Points: 12,801, Level: 49 Points: 12,801, Level: 49 Points: 12,801, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,023
Thanks: 1
Thanked 42 Times in 42 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #3 (permalink)  
Old May 17th, 2007, 10: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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #4 (permalink)  
Old May 18th, 2007, 07:42 AM
Wrox Author
Points: 12,801, Level: 49
Points: 12,801, Level: 49 Points: 12,801, Level: 49 Points: 12,801, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,023
Thanks: 1
Thanked 42 Times in 42 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #5 (permalink)  
Old May 21st, 2007, 10: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 :)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #6 (permalink)  
Old May 21st, 2007, 10: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 :)



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #7 (permalink)  
Old May 21st, 2007, 10:26 AM
Wrox Author
Points: 12,801, Level: 49
Points: 12,801, Level: 49 Points: 12,801, Level: 49 Points: 12,801, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Akron, Ohio, USA.
Posts: 4,023
Thanks: 1
Thanked 42 Times in 42 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
================================================== =========
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #8 (permalink)  
Old May 21st, 2007, 10:53 AM
Friend of Wrox
Points: 1,374, Level: 14
Points: 1,374, Level: 14 Points: 1,374, Level: 14 Points: 1,374, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 685
Thanks: 0
Thanked 0 Times in 0 Posts
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

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 11:25 AM
Problem with variable names shenku Javascript 2 May 6th, 2005 04:46 PM
Generate userform' s variables names joewidmer VB Databases Basics 0 September 17th, 2004 04:02 AM



All times are GMT -4. The time now is 08:54 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc