Subject: getting asp variables dynamically
Posted By: marco_1 Post Date: 6/14/2004 4:59:05 AM
how do i get asp variables dynamically in asp?  (without hardcoding)
thnks!

Reply By: qazi_nomi Reply Date: 6/14/2004 5:34:47 AM
What do u mean by <b>asp variables dynamically in asp?  </B> make it clear

Love 4 all
Reply By: madhukp Reply Date: 6/14/2004 5:38:46 AM
Do you mean that you need more and more variables when you run through a loop etc. ? You can then use an array if the associated value is of normal data types (string / number).

If you want to use a series of objects, I think you cannot do it in ASP. A change in design may be needed.
Reply By: happygv Reply Date: 6/14/2004 12:24:00 PM
Hi Macro_1,

Can you explain that a little more?

Cheers!

_________________________
-Vijay G
Strive for Perfection
Reply By: mega Reply Date: 6/14/2004 1:31:07 PM
Hmm. Something like:
varVariable = Request("var1)
eval Execute(varVariable & "=" & varValue)

I need to look into it. I'll get back to you...

 - mega
Reply By: mega Reply Date: 6/14/2004 1:38:43 PM
Jep, this works..
<%
  For i=1 To 30
    Eval Execute("varVariable" & i & " = " & i)
    Response.Write(varVariable&i & "<br>")
  Next
%>

Just out of curiosity, what are you gonna use it for?

 - mega
Reply By: marco_1 Reply Date: 6/14/2004 9:44:27 PM
quote:
Originally posted by marco_1

how do i get asp variables dynamically in asp?  (without hardcoding)
thnks!





sorry guys for not explaining it, i mean, how do i get asp variables (w/c are defined using Dim) dynamically without hardcoding it, i need it together w/ the server variables for error tracking if the page fails. thnks

-marco

Reply By: qazi_nomi Reply Date: 6/15/2004 12:18:47 AM
Still confusing explain that why u want to use them and with declaring variable one can how do this ?

Love 4 all
Reply By: om_prakash Reply Date: 6/15/2004 12:30:38 AM
how do i get asp variables (w/c are defined using Dim) dynamically without hardcoding it, i need it together w/ the server variables for error tracking if the page fails.
<hr>
If i am correct, then are u talking about arrays? For the second part, do u want to navigate through forms collection?


Om Prakash
Reply By: rodmcleay Reply Date: 6/15/2004 12:46:41 AM
I think what Marco is asking is to store all the variable information be it a variable in the page, session variable or request.
So if the page fails he still has all the information?

Is this correct Marco.

If so, I don't think there is a way to loop through variables you create on the page.

You can only do your best to ensure that nothing on the page will cause an error to make the page fail. And failures other than that caused in code would prevent the saving of any variable at all at any rate.




======================================
They say, best men are moulded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
Reply By: marco_1 Reply Date: 6/15/2004 4:34:18 AM
@Om Prakash
quote:

how do i get asp variables (w/c are defined using Dim) dynamically without hardcoding it, i need it together w/ the server variables for error tracking if the page fails.
<hr>
If i am correct, then are u talking about arrays? For the second part, do u want to navigate through forms collection?


Om Prakash



nope not arrays, and not forms collections, just variables defined in Dim only

-----------------------
@qazi_nomi
quote:

Still confusing explain that why u want to use them and with declaring variable one can how do this ?

Love 4 all


i want to use them coz i wanna see why the error occurs in the page, btw, the error is irregular, it means that it doesnt happens all the time

----------------------
@rodmcleay
quote:

I think what Marco is asking is to store all the variable information be it a variable in the page, session variable or request.
So if the page fails he still has all the information?

Is this correct Marco.

If so, I don't think there is a way to loop through variables you create on the page.

You can only do your best to ensure that nothing on the page will cause an error to make the page fail. And failures other than that caused in code would prevent the saving of any variable at all at any rate.




yep, i only need the variables defined in Dim so that i can monitor it. the error is intermittent and i cannot replicate the error


@all
thanks guys! :)

Reply By: mega Reply Date: 6/15/2004 7:50:20 AM
You should look into the tree error object you got: the VBScript error object, the ADO error object and the ASP error object. Define them in your global.asa or in a include file on critical pages.
If you don't know these objects I'll suggest that you search google, there is tons of stuff on the subject out there.

 - mega
Reply By: tavo Reply Date: 12/7/2006 1:25:20 PM
Im trying to point to an array in a dynamic way, so i have only one function to do a task for multiple arrays.

the code is next.

def_tab_p1(0,0) = "label"
def_tab_p1(1,0) = "type"
def_tab_p1(2,0) = "value"

def_tab_f2(0,0) = "label"
def_tab_f2(1,0) = "type"
def_tab_f2(2,0) = "value"

function do_something(P_Tab)
   zTmp_tabla = Eval Execute("def_" & P_Tab)
   zTmp_long=UBound(zTmp_tabla,2)
   ...
   ...
end function


do_something "p1"
do_something "f2"

and i cant make it work.
am i thinking in wrong way the solution?

thanks

Reply By: mega Reply Date: 12/11/2006 4:39:00 PM
Your function should be

function do_something(P_Tab)
   Eval Execute(zTmp_tabla & P_Tab) ' I know the code looks weird
                                    ' but you're coding to whatever comes after the interpreter
   zTmp_long=UBound(zTmp_tabla & P_Tab,2)
   ...
   ...
end function

Haven't tested it though but it should work.. Nice idea

 - mega
Moving to C# .NET

Go to topic 53456

Return to index page 96
Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90
Return to index page 89
Return to index page 88
Return to index page 87