Sign in to follow this  
Followers 0
Champak

Wildcard in loop

4 posts in this topic

I want to cycle through variables where the first half are all the same, and the last portion is different, so the last half has to be a wildcard.

Ex.

The variables look like

$FFF_1_cat

$FFF_2_dog

$FFF_3_mouse

$FFF_4_rat

Then theoretically, my loop would look something like this

for $i = 1 to 4

$doing_something = $FFF_" & $i & $i "_*";<=============SEE THE WILDCARD?

next

Possible?

Share this post


Link to post
Share on other sites



I don't think so. Variables are unique. Using a wildcard will require to check every variable that matches the pattern one by one. You can't check all at once.

You can use Eval() to loop this way:

Not tested:

$FFF_1
$FFF_2
$FFF_3
$FFF_4

for $i = 1 to 4
   $doing_something = Eval("FFF_" & $i )
next

:)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I am actually doing an Eval loop, I just wanted to be able to keep some type of suffix on my names so I can quickly know what I am looking at in a glance, instead of numbers(I have numbers already included of course, for the Eval Loop). Well, I guess it's a no go with that.

Thanks.

Edited by Champak

Share this post


Link to post
Share on other sites

I am actually doing an Eval loop, I just wanted to be able to keep some type of suffix on my names so I can quickly know what I am looking at in a glance, instead of numbers(I have numbers already included of course, for the Eval Loop). Well, I guess it's a no go with that.

Thanks.

Then don't you think that the use of Wildcards and loops is a bit contradictory? If you understand how to use C/C++ style structures, then use DllStructCreate() and I think it'll get you a step closer.

Arrays are a good option too, in my opionion.

Good luck.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0