Jump to content

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>
$Multi=ColloquioDomande()
_ArrayDisplay($Multi,"PORCO")
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)
        $DomandeDifferenti[$z-1]=$Domande[$GiroDomande]
        _ArrayDelete($Domande,$GiroDomande)
        Select
            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]
        EndSelect
        Local $RisposteInOrdine[4]=[$Risp1,$Risp2,$Risp3,$Risp4]
        For $i To $r
            Local $GiroRispInOrdine=Random(1,Ubound($RisposteInOrdine)-1,1)
            $RisposteMischiate[$i-1]=$RisposteInOrdine[$GiroRispInOrdine]
            _ArrayDelete($RisposteInOrdine,$GiroRispInOrdine)
        Next
        $i+=4
        $r+=4
    Next
    Local $MultiDomERisp[2][16]=[[$DomandeDifferenti[0],$DomandeDifferenti[1],$DomandeDifferenti[2],$DomandeDifferenti[3]], _
    [$RisposteMischiate[0],$RisposteMischiate[1],$RisposteMischiate[2],$RisposteMischiate[3],$RisposteMischiate[4], _
    $RisposteMischiate[5],$RisposteMischiate[6],$RisposteMischiate[7],$RisposteMischiate[8],$RisposteMischiate[9]]]
    Return $MultiDomERisp
EndFunc

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