Sign in to follow this  
Followers 0
jack71

Have a loop create a multi-variable variable...

12 posts in this topic

I have a loop that I want to have create a multi-variable variable, dumbed down ex:

local $test[0]
local $i = 1
 
For $i 1 to 20
local $test$i = _ArrayAdd($test$i, "Color" & $i)
local $test$i = _ArrayAdd($test$i, "Type" & $i)
Next

 

I want to retrieve some information via WMI and keep each device in its separate array but can't figure out how to create multivariable variables, if that's even possible.

I've tried declaring it as $test & $i, $test&$i, and $test($i) and it's not working.  I'm probably screwing up syntax somewhere?

Thanks :)

Share this post


Link to post
Share on other sites



local $test[0]
local $i = 1
 
For $i 1 to 20
_ArrayAdd($test, "Color" & $i)
_ArrayAdd($test, "Type" & $i)
Next

Hey JohnOne,

The goal is to have 20 created arrays (or until @error):

$test1, $test2, $test3.....$test20

Each array will represent a hardware component, and in each array the component's settings. 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Just trying to understand your direction...

I would build an "ini" file with the info

Use iniread() to build its own array/variable

8)

 

So is it not possible to create an array via loop with a number appended to it based on $i?

$i = 1 therefore $test1[0]

$i = 2 then...$test2[0]

I just don't know how many arrays I need to declare because it depends on the number of keys found in the registry.  

Edited by jack71

Share this post


Link to post
Share on other sites

Yes it is.

you need a two dimensional array ( multi-dimensional)

Like... $Test[0][0]

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Yes it is.

you need a two dimensional array ( multi-dimensional)

Like... $Test[0][0]

8)

 

I wanted to keep it simple.  For example if I have 2 network cards installed, 1 wifi, 1 LAN I want $test1 to contain all the information of the wifi card, and $test2 to contain all the information of the LAN card.

Share this post


Link to post
Share on other sites

I'll try the iniwrite and iniread workaround.

Share this post


Link to post
Share on other sites

it is possible to do something like this

 

$Test1 = "WIFI,g,b,n,etc"

then later use stringsplit() by commas to create an array of the values needed

8)

1 person likes this

NEWHeader1.png

Share this post


Link to post
Share on other sites

it is possible to do something like this

 

$Test1 = "WIFI,g,b,n,etc"

then later use stringsplit() by commas to create an array of the values needed

8)

Good idea :)

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