Jump to content

Need help with a loop


Pain
 Share

Recommended Posts

I need some help with this loop.

Global $FileList=_FileListToArray(@ScriptDir & "\images\", "*", 1)

pic()

Func pic()
For $top = 50 To 510 Step 230
$count = 1
$side = 20
For $y = 1 To UBound($FileList) - 1
GUICtrlCreatePic(@ScriptDir & "\images\" & $FileList[$count], $side, $top, 0, 0)
$count += 1
$side += 320
Next
Next
EndFunc

This one will create 3 rows with pictures next to each other on my gui, all rows use same picture and never ends (it depends on how many pictures there is in the folder).

I want it to create 3 pictures on row one and then start on a new row and keep doing like that until all pictures from the folder are used.

All these loops are driving me crazy :)

Link to comment
Share on other sites

I need some help with this loop.

Global $FileList=_FileListToArray(@ScriptDir & "\images\", "*", 1)

pic()

Func pic()
For $top = 50 To 510 Step 230
$count = 1
$side = 20
For $y = 1 To UBound($FileList) - 1
GUICtrlCreatePic(@ScriptDir & "\images\" & $FileList[$count], $side, $top, 0, 0)
$count += 1
$side += 320
Next
Next
EndFunc

This one will create 3 rows with pictures next to each other on my gui, all rows use same picture and never ends (it depends on how many pictures there is in the folder).

I want it to create 3 pictures on row one and then start on a new row and keep doing like that until all pictures from the folder are used.

All these loops are driving me crazy :)

That's because you are looping too much >_<

Try this:

Global $FileList=_FileListToArray(@ScriptDir & "\images\", "*", 1)

pic()

Func pic()
    
    Local $top = 50
    Local $count = 0
    Local $side = 20
    
    For $y = 1 To UBound($FileList) - 1
        
        GUICtrlCreatePic(@ScriptDir & "\images\" & $FileList[$count + 1], $side, $top, 0, 0)

        $count += 1
        $side += 320

        If Mod($count, 3) = 0 Then
            $top += 230
            $side = 20
        EndIf

    Next

EndFunc

♡♡♡

.

eMyvnE

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