Blueman Posted May 24, 2018 Share Posted May 24, 2018 Hi there guys, I must be doing something wrong here, but i can't seem to figure it out.My Situation I have a 2D Array with 3 colums and around 500+ rows. I would like to access the array for filling a ComboBox with only the 0 Column. I am using the _ArrayToString function for this, but it only seems to be working with column 1 or higher. When i use Column 0 it shows all the columns, i think because '0' is a default parameter, but the question now is how to fix this? Array's Global $FZArray[500][3] Global $FUArray[120][5] Script (Not working, column 0) $Choice = GUICtrlCreateCombo("", 750, 105, 300, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "-- Choose One --|" & _ArrayToString($FZArray, "|", 0, 0,"|",0,0) & _ArrayToString($FUArray, "|", 0, 0,"|",0,0), "-- Choose One --") Script (works, but Column 1) $Choice = GUICtrlCreateCombo("", 750, 105, 300, 20, $CBS_DROPDOWNLIST) GUICtrlSetData(-1, "-- Choose One --|" & _ArrayToString($FZArray, "|", 0, 0,"|",1,1) & _ArrayToString($FUArray, "|", 0, 0,"|",1,1), "-- Choose One --") Thanks guys Link to comment Share on other sites More sharing options...
Bilgus Posted May 24, 2018 Share Posted May 24, 2018 Sometimes in the course of creating my simple reproducer script of a problem I end up finding the issue next time you should try something similar it really helps get a grasp on the issue at hand and makes it easier for others to help you. #include <array.au3> Global $FZArray[5][3] For $i = 0 to 4 $FZArray[$i][0]= "This IS " & $i & ",0" Next For $i = 0 to 4 $FZArray[$i][1]= "This IS " & $i & ",1" Next For $i = 0 to 4 $FZArray[$i][2]= "This IS " & $i & ",2" Next ConsoleWrite( _ArrayToString($FZArray, "|", 0, 0,"|",0,0)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) ConsoleWrite( _ArrayToString($FZArray, "|", 0, 1,"|",0,1)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) Output: Quote This IS 0,0 This IS 0,0|This IS 0,1|This IS 1,0|This IS 1,1 Link to comment Share on other sites More sharing options...
Blueman Posted May 24, 2018 Author Share Posted May 24, 2018 6 minutes ago, Bilgus said: Sometimes in the course of creating my simple reproducer script of a problem I end up finding the issue next time you should try something similar it really helps get a grasp on the issue at hand and makes it easier for others to help you. #include <array.au3> Global $FZArray[5][3] For $i = 0 to 4 $FZArray[$i][0]= "This IS " & $i & ",0" Next For $i = 0 to 4 $FZArray[$i][1]= "This IS " & $i & ",1" Next For $i = 0 to 4 $FZArray[$i][2]= "This IS " & $i & ",2" Next ConsoleWrite( _ArrayToString($FZArray, "|", 0, 0,"|",0,0)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) ConsoleWrite( _ArrayToString($FZArray, "|", 0, 1,"|",0,1)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) Output: HI Thanks! But output at my side = This IS 0,0|This IS 0,1|This IS 0,2|This IS 1,0|This IS 1,1|This IS 1,2|This IS 2,0|This IS 2,1|This IS 2,2|This IS 3,0|This IS 3,1|This IS 3,2|This IS 4,0|This IS 4,1|This IS 4,2 This IS 0,0|This IS 0,1|This IS 1,0|This IS 1,1 Strange right? Link to comment Share on other sites More sharing options...
Bilgus Posted May 24, 2018 Share Posted May 24, 2018 Next Question would be what version of AutoIt Does this work as expected? expandcollapse popup;;#include <array.au3> #include "AutoItConstants.au3" Global $FZArray[5][3] For $i = 0 to 4 $FZArray[$i][0]= "This IS " & $i & ",0" Next For $i = 0 to 4 $FZArray[$i][1]= "This IS " & $i & ",1" Next For $i = 0 to 4 $FZArray[$i][2]= "This IS " & $i & ",2" Next ConsoleWrite( _ArrayToString($FZArray, "|", 0, 0,"|",0,0)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) ConsoleWrite( _ArrayToString($FZArray, "|", 0, 1,"|",0,1)) If @error Then Msgbox(0,"Error", @error) ConsoleWrite(@crlf) ;Array.au3.. ; #FUNCTION# ==================================================================================================================== ; Author ........: Brian Keene <brian_keene at yahoo dot com>, Valik - rewritten ; Modified.......: Ultima - code cleanup; Melba23 - added support for empty and 2D arrays ; =============================================================================================================================== Func _ArrayToString(Const ByRef $aArray, $sDelim_Col = "|", $iStart_Row = -1, $iEnd_Row = -1, $sDelim_Row = @CRLF, $iStart_Col = -1, $iEnd_Col = -1) If $sDelim_Col = Default Then $sDelim_Col = "|" If $sDelim_Row = Default Then $sDelim_Row = @CRLF If $iStart_Row = Default Then $iStart_Row = -1 If $iEnd_Row = Default Then $iEnd_Row = -1 If $iStart_Col = Default Then $iStart_Col = -1 If $iEnd_Col = Default Then $iEnd_Col = -1 If Not IsArray($aArray) Then Return SetError(1, 0, -1) Local $iDim_1 = UBound($aArray, $UBOUND_ROWS) - 1 If $iStart_Row = -1 Then $iStart_Row = 0 If $iEnd_Row = -1 Then $iEnd_Row = $iDim_1 If $iStart_Row < -1 Or $iEnd_Row < -1 Then Return SetError(3, 0, -1) If $iStart_Row > $iDim_1 Or $iEnd_Row > $iDim_1 Then Return SetError(3, 0, "") If $iStart_Row > $iEnd_Row Then Return SetError(4, 0, -1) Local $sRet = "" Switch UBound($aArray, $UBOUND_DIMENSIONS) Case 1 For $i = $iStart_Row To $iEnd_Row $sRet &= $aArray[$i] & $sDelim_Col Next Return StringTrimRight($sRet, StringLen($sDelim_Col)) Case 2 Local $iDim_2 = UBound($aArray, $UBOUND_COLUMNS) - 1 If $iStart_Col = -1 Then $iStart_Col = 0 If $iEnd_Col = -1 Then $iEnd_Col = $iDim_2 If $iStart_Col < -1 Or $iEnd_Col < -1 Then Return SetError(5, 0, -1) If $iStart_Col > $iDim_2 Or $iEnd_Col > $iDim_2 Then Return SetError(5, 0, -1) If $iStart_Col > $iEnd_Col Then Return SetError(6, 0, -1) For $i = $iStart_Row To $iEnd_Row For $j = $iStart_Col To $iEnd_Col $sRet &= $aArray[$i][$j] & $sDelim_Col Next $sRet = StringTrimRight($sRet, StringLen($sDelim_Col)) & $sDelim_Row Next Return StringTrimRight($sRet, StringLen($sDelim_Row)) Case Else Return SetError(2, 0, -1) EndSwitch Return 1 EndFunc ;==>_ArrayToString Link to comment Share on other sites More sharing options...
Bilgus Posted May 24, 2018 Share Posted May 24, 2018 Update your AutoIt version. Link to comment Share on other sites More sharing options...
Blueman Posted May 24, 2018 Author Share Posted May 24, 2018 (edited) 1 hour ago, Bilgus said: Update your AutoIt version. Good one, tested it with newer version of AutoIT and it is working! Thanks man, was driving me crazy,... --- The previous example is working with older version ByTheWay Edited May 24, 2018 by Blueman Link to comment Share on other sites More sharing options...
Bilgus Posted May 24, 2018 Share Posted May 24, 2018 Well sure, I pulled the working function from my version and pasted it into the script. After all, the UDF's are simply functions in another .au3 file 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