Jump to content

Dynamic Varialbes


jezzzzy
 Share

Recommended Posts

I will start by saying I know this has been discussed in the past and I have read the topics below:

http://www.autoitscript.com/forum/index.ph...topic=10622&hl=

http://www.autoitscript.com/forum/index.ph...wtopic=8914&hl=

---

However I still need help. I am working on an application to monitor my live webcams. I will attach it. Click on the Bascom tab and the click the "Test" button to see the purpose. Hopefully the cam is operational for you to test. It should be.

In short, I need a way to dynamically create unique variable names in a For...Next loop. Read on for details...

I need to generate dynamic variable names from an .ini file to interact with in my script. If you run my script you will see the first tab has several cams listed with icons indicating their operation status. These names are generated in a For...next loop (line 169) from the .ini file. My problem is that each of the 6 groups of items in the For...Next loop all have the same variable name. So if I want to change an icon or change a Label's text -- only the last one created will change. I need the variable names to be dynamic so that they are unique. Anyway -- you see my problem.

I made a "Test2" button to demonstrate my problem. It sends a GUICtrlSetImage() to the variable name for the icon.

In summary, I need a way to dynamically create unique variable names in a For...Next loop so I can use them later in my script.

---

Please note: in order to troubleshoot my problem I am not cleaning up my file installs in the script. Files created are as follows for manual cleanup:

Created -- c:\wCam.ini

Created -- @tempdir & "\wCam" ;<-- icons and such

--

Sorry for the lengthy post and thanks for your help in advance.

Link to comment
Share on other sites

why don't you use arrays as variables

if your already doing an for ... next loop then you can do the variables as arrays as well

this should be dynamic enough for what you need

Yes. I saw this suggested in my forum searching. I was reluctant to try it because I couldn't think of a way to easily reference my variable. I'm sure I can work it out.

So to confirm: I can do something like this:

GUICtrlSetImage($mainicon[3],$green)

;and also this

GUICtrlSetImage($mainicon[4],$green)

...and that will affect the correct item in my GUI?

If the answer is yes, then my problem becomes this-- since the array will be generated based on entries in an INI file, my script will not know how many elements there are in the array. I will look into ReDim because I think I remember reading that I can redefine the size of my array with that. This all seems above my current skill level - but I'll never learn if I don't try.

Any advice/examples that my help me understand how to most efficiently create a dynamic array from an INI would probably help me stay sane.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...