rootx Posted September 1, 2014 Share Posted September 1, 2014 #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $imgArray = _FileListToArray("C:\images\", "*.jpg",1) For $a = 1 to UBound($imgArray) -1 ConsoleWrite("<TR> "&@CRLF) ConsoleWrite(" <TD> "&@CRLF) For $b = 1 to 5 Next ConsoleWrite(" "&$imgArray[$a]&@CRLF) ;here!!! For $d = 1 to 5 Next ConsoleWrite(" </TD> "&@CRLF) ConsoleWrite("</TR> "&@CRLF&@CRLF) Next I would like to have this result, but something wrong, could someone help me? <TR> <TD> 01.jpg 02.jpg 03.jpg 04.jpg </TD> </TR> <TR> <TD> 05.jpg 06.jpg N.... thanks. Link to comment Share on other sites More sharing options...
Muzaiyan Posted September 1, 2014 Share Posted September 1, 2014 are you looking for this...? #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $imgArray = _FileListToArray("C:\images\", "*.jpg", 1) $output = "" For $a = 1 To UBound($imgArray) - 1 Step 4 ConsoleWrite("<TR> " & @CRLF) ConsoleWrite(" <TD> " & @CRLF) $output &= "<TR> " & @CRLF & " <TD> " & @CRLF For $b = $a To $a + 3 ConsoleWrite(" " & $imgArray[$b] & @CRLF) ;here!!! $output &= " " & $imgArray[$b] & @CRLF Next ConsoleWrite(" </TD> " & @CRLF) ConsoleWrite("</TR> " & @CRLF & @CRLF) $output &= " </TD> " & @CRLF & "</TR> " & @CRLF Next MsgBox(64, "now you can use this variable", $output) Link to comment Share on other sites More sharing options...
rootx Posted September 1, 2014 Author Share Posted September 1, 2014 Thanks Muzaiyan!!!! Perfect. I'm really tired today... Link to comment Share on other sites More sharing options...
Muzaiyan Posted September 1, 2014 Share Posted September 1, 2014 Link to comment Share on other sites More sharing options...
rootx Posted September 2, 2014 Author Share Posted September 2, 2014 when Step it is not a multiple of array does not work, Ex: if imgArray = 30 the result is wrong... For $a = 1 To UBound($imgArray) - 1 Step 4 ...dimension range exceeded becose 4 is not a multiple of 30 Muzaiyan solution is valid only if you already know the value of the array, in my case I do not know the value before the loop Any idea? thanks Link to comment Share on other sites More sharing options...
Solution Gianni Posted September 2, 2014 Solution Share Posted September 2, 2014 you could add empty elements in array for missing images till total elements is a multiple: #include <Array.au3> ; required to manage array #include <File.au3> Local $imgArray = _FileListToArray("C:\images\", "*.jpg", 1) Local $Step = 4 ; how many elements per row (you can change this number) ; if not multiple of $Step then add empty elements in array for missing *.jpg While $imgArray[0] / $Step <> Int($imgArray[0] / $Step) _ArrayAdd($imgArray, "") $imgArray[0] += 1 WEnd $output = "" For $a = 1 To UBound($imgArray) - 1 Step $Step ; <- use "$Step" variable instead of absolute number ConsoleWrite("<TR> " & @CRLF) ConsoleWrite(" <TD> " & @CRLF) $output &= "<TR> " & @CRLF & " <TD> " & @CRLF For $b = $a To $a + $Step - 1 ; <- use "$Step" variable instead of absolute number ConsoleWrite(" " & $imgArray[$b] & @CRLF) ;here!!! $output &= " " & $imgArray[$b] & @CRLF Next ConsoleWrite(" </TD> " & @CRLF) ConsoleWrite("</TR> " & @CRLF & @CRLF) $output &= " </TD> " & @CRLF & "</TR> " & @CRLF Next MsgBox(64, "now you can use this variable", $output) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
rootx Posted September 2, 2014 Author Share Posted September 2, 2014 Nice work!!! Very very thanks! And then just add an IF to have all rows with no empty rows!! #include <Array.au3> ; Only required to display the arrays #include <File.au3> Local $imgArray = _FileListToArray("C:\images\", "*.jpg", 1) Local $Step = 9 ; how many elements per row (you can change this number) ; if not multiple of $Step then add empty elements in array for missing *.jpg While $imgArray[0] / $Step <> Int($imgArray[0] / $Step) _ArrayAdd($imgArray, "") $imgArray[0] += 1 WEnd For $a = 1 To UBound($imgArray) - 1 Step $Step ; <- use "$Step" variable instead of absolute number ConsoleWrite("<TR> " & @CRLF) ConsoleWrite(" <TD> " & @CRLF) For $b = $a To $a + $Step - 1 ; <- use "$Step" variable instead of absolute number If $imgArray[$b] <> 0 Then ; exit from the loop when the images finish ConsoleWrite(" " & $imgArray[$b] & @CRLF) ;here!!! Else ExitLoop EndIf Next ConsoleWrite(" </TD> " & @CRLF) ConsoleWrite("</TR> " & @CRLF & @CRLF) Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now