Jump to content
Sign in to follow this  
Jujo

Help needed... for.....variable :S

Recommended Posts

Jujo

Hi, folks.

I have become very familiar with AutoIt, and I just love it ^_^ I use it for everyday actions while starting up PC and that stuff, as well as in school.

So, today I need some help.

I have function that has 8 parameters named $1, $2, $3, etc. and in that function I have a For chain that is supposed to do an action depending on parameter's value (0 or 1).

This is what I have:

For $i = 1 To 7 Step 1
    If ($[$i] = 1) Then 
        USBSetDigitalChannel($i) 
    ElseIf ($[$i] = 0) Then
        USBClearDigitalChannel($i) 
    EndIf
Next

As you can see, I have the whole code except the $[$i] part, since I have no idea how to use current $i value as variable name.

So, please help me. Thanks ;)

P.S. I now use If... Else for every parameter (that is 8 loops), but that is pretty slow and I don't think it will work. Also, what would happen if I have random number of variables, or 100 variables :(

TY

Share this post


Link to post
Share on other sites
weaponx

Dim $aValues[8] = [0,1,0,0,0,0,0,1]

For $i = 0 to 7
    If ($aValues[$i] = 1) Then 
        USBSetDigitalChannel($i) 
    ElseIf ($aValues[$i] = 0) Then
        USBClearDigitalChannel($i) 
    EndIf
Next

Share this post


Link to post
Share on other sites
Jujo

Thanks

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  

×