Jump to content

How to Change var with array when loop ..?


Recommended Posts

How to Change "$change" results , with array "$pr[0]" and "$pr[1]" - - - $pr[5] every time when the loop ...?

I have this code .....

Dim $pr[5] 
$pr[0] = "cccc"
$pr[1] = "dddd"
$pr[2] = "eeee"
$pr[3] = "artt"
$pr[4] = "huge"


$loop = 1
$var1 = 0
While $loop = 1
    $var1 = $var1 + 1 
    $change = $pr[0]
    
    If $var1 = 1 Then 
        
        MsgBox(0, "ms", $change)
       
    Else
        MsgBox(0, "ms", "not1")
        
        If $var1 = 2 Then  
        MsgBox(0, "msg", "ok-2")
            Else
        MsgBox(0, "ms", "not2")
        EndIf
    EndIf


    $loop = 1
WEnd
Link to comment
Share on other sites

@GameIDevelp

I dont understand you :P

$change = $pr[0+$loop]oÝ÷ Ù«­¢+ØÀÌØí¡¹ôÀÌØíÁÈ()%ÀÌØíÙÈÄôÄQ¡¸(½ÈÀÌØí¤ôÄѼU ½Õ¹ ÀÌØíÁȤ´Ä(5Í   ½à À°ÅÕ½ÐíµÌÅÕ½Ðì°ÀÌØí¡¹¤(9áÐ)¹%

Hope that helps

Cheers, FireFox.

Link to comment
Share on other sites

the $change results is "ccc" from $pr[0] ,, I make this var "$change for me to understand the change value var to another value var . I hop you understand .. :P

The code not work ,, return just 1 ,2 ,3 ,4 , not value of $pr[0] , $pr[1] etc --- $pr[5] ...

Link to comment
Share on other sites

can you exaplain each line of your code ?

Local $pr[5] 
$pr[0] = "cccc"
$pr[1] = "dddd"
$pr[2] = "eeee"
$pr[3] = "artt"
$pr[4] = "huge"

$loop = 1
$var1 = 0
While $loop < 5; While $loop = 1
    $var1 += 1; $var1 = $var1 + 1 
    $change = $pr[0]; "cccc"
    
    If $var1 = 1 Then       
        MsgBox(0, "ms", $pr[$i]); $change)     
    Else
        MsgBox(0, "ms", "not1")     
        If $var1 = 2 Then  
        MsgBox(0, "msg", "ok-2")
            Else
        MsgBox(0, "ms", "not2")
        EndIf
    EndIf
$loop += 1
WEnd

Cheers, FireFox.

Link to comment
Share on other sites

can you exaplain each line of your code ?

Local $pr[5] 
$pr[0] = "cccc"
$pr[1] = "dddd"
$pr[2] = "eeee"
$pr[3] = "artt"
$pr[4] = "huge"

$loop = 1
$var1 = 0
While $loop < 5; While $loop = 1
    $var1 += 1; $var1 = $var1 + 1 
    $change = $pr[0]; "cccc"
    
    If $var1 = 1 Then       
        MsgBox(0, "ms", $pr[$i]); $change)     
    Else
        MsgBox(0, "ms", "not1")     
        If $var1 = 2 Then  
        MsgBox(0, "msg", "ok-2")
            Else
        MsgBox(0, "ms", "not2")
        EndIf
    EndIf
$loop += 1
WEnd

Cheers, FireFox.

Your code is not displayed corectly ..

I wont to make this variable "$change" to change every time when the loop code to change into the 1 value of variable $pr ,,

When Loop 1 the I wont to change value of variable "$change" into the value of variable "$pr[0] ,,,,, and for loop 2 change $change to $pr[1] and next next next and again ..

Link to comment
Share on other sites

Edit: You could change all the $i to $var1 if you wanted to..basically that one $i was messing you up.

Edit2: Meh code tags (use his version below (less to write and easier to use).

Local $pr[5]
$pr[0] = "cccc"
$pr[1] = "dddd"
$pr[2] = "eeee"
$pr[3] = "artt"
$pr[4] = "huge"

$i = 0
$loop = 1
While $loop < 5; While $loop = 1
    $i += 1; $var1 = $var1 + 1
    $change = $pr[0]; "cccc"
    
    If $i = 1 Then       
        MsgBox(0, "ms", $pr[$i]); $change)    
    Else
        MsgBox(0, "ms", "not1")     
        If $i = 2 Then  
        MsgBox(0, "msg", "ok-2")
            Else
        MsgBox(0, "ms", "not2")
        EndIf
    EndIf
$loop += 1
WEnd
Edited by Gondus

-----------Current Programming Language Status:Beginner: J#, Ruby Intermediate: Autoit, Java, C#, C++Advanced: Basic, Visual Basic, Fortran

Link to comment
Share on other sites

Your code is not displayed corectly ..

I wont to make this variable "$change" to change every time when the loop code to change into the 1 value of variable $pr ,,

When Loop 1 the I wont to change value of variable "$change" into the value of variable "$pr[0] ,,,,, and for loop 2 change $change to $pr[1] and next next next and again ..

You normally use For-loops for that kind of thing, like in Firefox first post. Here is another example:

Local $pr[5] 
$pr[0] = "cccc"
$pr[1] = "dddd"
$pr[2] = "eeee"
$pr[3] = "artt"
$pr[4] = "huge"

For $X = 0 To 4
    $change = $pr[$X]
    MsgBox(0, "", $change)
Next
Link to comment
Share on other sites

wooo ,,,, thanks guys . :P .

Sorry for my misunderstanding I dont know very good autoit ..

Thats why this forums is here :unsure:

-----------Current Programming Language Status:Beginner: J#, Ruby Intermediate: Autoit, Java, C#, C++Advanced: Basic, Visual Basic, Fortran

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...