Sign in to follow this  
Followers 0
Pain

Need help with a loop

4 posts in this topic

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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

haha thanks alot, I told you the loops where driving me crazy :)

Share this post


Link to post
Share on other sites

I'm looking at that code posted earlier and cannot find any sense in that $count part :) . Lose it


♡♡♡

.

eMyvnE

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  
Followers 0