Sign in to follow this  
Followers 0
Danman

Variable number of Variables

4 posts in this topic

Essentially I am creating a master GUI for all the scripts that we run. But the number of scripts available at any given time could be between 15 and 50+. I'm trying to hard code as little as possible. It should look something like this:

$counter = 0
do
    $counter = $counter + 1
    search for .exe files in folder
    if found .exe then
       $checkbox$counter = [Create GUI Check Box]
until no more .exe's

So I have no idea how many .exe's will be there and I want to create a new variable for each one (to keep track of them all). Is there anyway to do this? (i.e. in this script, the fist 3 files would create checkboxes which return id's of $checkbox1, $checkbox2, and $checkbox3)

Right now I just have 10 variables declared, and have a select-case setup to create a check box depending on what $counter is. It's easy enough, but like I said, I want to hard code as little as possible.

I've toyed with the idea of having this script write everything it needs to a text file, then saving that text file as a .au3, compiling it, and running it, but that's just straight ridiculous for what I'm trying to do. :whistle:

Share this post


Link to post
Share on other sites



Try _FileListToArray in conjuntion with a few For...Next loops

Share this post


Link to post
Share on other sites

To answer your question you're looking for Assign (writing) and Eval (reading).

If I were to do the same however, then I would use an array instead, which I

would consider being a lot "cleaner". Just a tip.

Share this post


Link to post
Share on other sites

Beautiful!!! This works perfect. Heh, it tooks some time for me to re-wrap my mind around arrays. I hadn't used 'em since I first learned code however many years ago :whistle: (Even though that's what I was trying to create)

Meh! This'll help make my code *much* cleaner from here on out. Thanks guys! ;)

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