Jump to content
Sign in to follow this  

Strange error in For Cycle for Array assigning

Recommended Posts


Why this gives error? I don't get it. When declaring a for cycle the 1st variable MUST be in any case in the format $i=1? Take a look, the error is in the second for...

#include <array.au3>
Func ColloquioDomande()
    Local $Domande[5]=["doma","domb","domc","domd","dome"]
    Local $Risposte[20]=["a","b","c","d","a1","b1","c1","d1","a2","b2","c2","d2","a3","b3","c3","d3","a4","b4","c4","d4"]
    Local $DomandeDifferenti[4]
    Local $RisposteMischiate[16]
    Local $i=1
    Local $r=4
    For $z=1 To 4
        Local $GiroDomande=Random(1,Ubound($Domande)-1,1)
            Case $GiroDomande=0
                Local $Risp1=$Risposte[0],$Risp2=$Risposte[1],$Risp3=$Risposte[2],$Risp4=$Risposte[3]
            Case $GiroDomande=1
                Local $Risp1=$Risposte[4],$Risp2=$Risposte[5],$Risp3=$Risposte[6],$Risp4=$Risposte[7]
            Case $GiroDomande=2
                Local $Risp1=$Risposte[8],$Risp2=$Risposte[9],$Risp3=$Risposte[10],$Risp4=$Risposte[11]
            Case $GiroDomande=3
                Local $Risp1=$Risposte[12],$Risp2=$Risposte[13],$Risp3=$Risposte[14],$Risp4=$Risposte[15]
            Case $GiroDomande=4
                Local $Risp1=$Risposte[16],$Risp2=$Risposte[17],$Risp3=$Risposte[18],$Risp4=$Risposte[19]
        Local $RisposteInOrdine[4]=[$Risp1,$Risp2,$Risp3,$Risp4]
        For $i To $r
            Local $GiroRispInOrdine=Random(1,Ubound($RisposteInOrdine)-1,1)
    Local $MultiDomERisp[2][16]=[[$DomandeDifferenti[0],$DomandeDifferenti[1],$DomandeDifferenti[2],$DomandeDifferenti[3]], _
    [$RisposteMischiate[0],$RisposteMischiate[1],$RisposteMischiate[2],$RisposteMischiate[3],$RisposteMischiate[4], _
    Return $MultiDomERisp

Well, i solved it.

You have to do For $k=$i to $r.

Therefore you can't declare the 1st condition of a for loop from outer the loop directly.

Edited by niubbone

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.