there is a variables when i dim a dynamic array 
Author Message
 there is a variables when i dim a dynamic array

I have 4 dynamic arrays
dim tt_1()
dim tt_2()
dim tt_3()
dim tt_4()
----------------
i want to do like this:
for i=1 to 4
dim tt_i()
next
-----------
but doesn't work
who can help me!!

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Fri, 30 Sep 2005 14:09:47 GMT  
 there is a variables when i dim a dynamic array
Of course that won't work.  Whats so wrong with the way you are doing it?
Its all of one more line of code!


Quote:
> I have 4 dynamic arrays
> dim tt_1()
> dim tt_2()
> dim tt_3()
> dim tt_4()
> ----------------
> i want to do like this:
> for i=1 to 4
> dim tt_i()
> next
> -----------
> but doesn't work
> who can help me!!

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Fri, 30 Sep 2005 17:53:35 GMT  
 there is a variables when i dim a dynamic array
Hi,

To work with modified variable names, or any script lines, concatenate and
use Execute.  For your example:

for i=1 to 4
  Execute "dim tt_" & i & "()"
next

Execute is slower thatn standard literal execution for large amounts of code
or repetitive operations, but that shouldn't matter here.  Execute also has
an undocumented quirk that allows it to set or assign an undimensioned
global variable, circumventing Option Explicit, which may or may not obviate
the need to Dim these variables, depending on the rest of your script.

Joe Earnest


Quote:
> I have 4 dynamic arrays
> dim tt_1()
> dim tt_2()
> dim tt_3()
> dim tt_4()
> ----------------
> i want to do like this:
> for i=1 to 4
> dim tt_i()
> next
> -----------
> but doesn't work
> who can help me!!

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sat, 01 Oct 2005 00:19:05 GMT  
 there is a variables when i dim a dynamic array
I have not tried the following, perhaps it will work:
For i = 1 to 4 : eval ("Dim tt_" & i & "()") : Next

Success!
Hans Stavleu


Quote:
> I have 4 dynamic arrays
> dim tt_1()
> dim tt_2()
> dim tt_3()
> dim tt_4()
> ----------------
> i want to do like this:
> for i=1 to 4
> dim tt_i()
> next
> -----------
> but doesn't work
> who can help me!!

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sat, 01 Oct 2005 00:23:14 GMT  
 there is a variables when i dim a dynamic array
With the one caveat that eval() is for javascript/jscript; the VBScript
equivalent (which would be appropriate for this NG) is Execute, as Joe has
already pointed out.

--
Very respectfully,
Todd Lewis

-- remove the capital letters to contact me --


Quote:
> I have not tried the following, perhaps it will work:
> For i = 1 to 4 : eval ("Dim tt_" & i & "()") : Next

> Success!
> Hans Stavleu



> > I have 4 dynamic arrays
> > dim tt_1()
> > dim tt_2()
> > dim tt_3()
> > dim tt_4()
> > ----------------
> > i want to do like this:
> > for i=1 to 4
> > dim tt_i()
> > next
> > -----------
> > but doesn't work
> > who can help me!!

> > *** Sent via Developersdex http://www.developersdex.com ***
> > Don't just participate in USENET...get rewarded for it!



Sat, 01 Oct 2005 00:35:11 GMT  
 there is a variables when i dim a dynamic array
Yip, You're right. Eval in vbscript exists, but is for evaluating
expressions in stead of statements.

hans stavleu


Quote:
> With the one caveat that eval() is for javascript/jscript; the vbscript
> equivalent (which would be appropriate for this NG) is Execute, as Joe has
> already pointed out.

> --
> Very respectfully,
> Todd Lewis

> -- remove the capital letters to contact me --



> > I have not tried the following, perhaps it will work:
> > For i = 1 to 4 : eval ("Dim tt_" & i & "()") : Next

> > Success!
> > Hans Stavleu



> > > I have 4 dynamic arrays
> > > dim tt_1()
> > > dim tt_2()
> > > dim tt_3()
> > > dim tt_4()
> > > ----------------
> > > i want to do like this:
> > > for i=1 to 4
> > > dim tt_i()
> > > next
> > > -----------
> > > but doesn't work
> > > who can help me!!

> > > *** Sent via Developersdex http://www.developersdex.com ***
> > > Don't just participate in USENET...get rewarded for it!



Sat, 01 Oct 2005 05:07:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. dynamically dim a variable ie dim "variable"&n

2. Dim Dynamic Variable Names?

3. Dynamic mem allocation via array names as variables

4. Create a dynamic array from set of Session variables

5. multi dim array / nested array

6. Dynamic Data Structures: Dynamic Arrays?

7. build dynamic Dim from computer names

8. dim dynamic?

9. Dynamic Dim'ing

10. Dynamic array within an array?

11. Dim and Array question

12. dim array

 

 
Powered by phpBB® Forum Software