Clark Posted April 23, 2013 Share Posted April 23, 2013 Hi there This has been bugging me for sometime now, but usually I just work around it. I think now is a good time for me to get me head around what is going on. In the following code, the _ArrayDisplay function works, indicating that $aRet is an array. (It definitely is an array as that is what the function returns.) Yet, when I try to use $aRet[0][0] so that I can see it's value, I get the "Subscript used with non-Array variable." error. Why is this when $aRet is definitely an array? $aRet = _GUIListViewEx_Editonclick($iEditMode) ; Allow keys to move edit location _ArrayDisplay($aRet) if $aRet[0][0]=1 then $lvitem=_GUIListViewEx_ReturnArray(1) _Display_Icons() EndIf Link to comment Share on other sites More sharing options...
Xandy Posted April 23, 2013 Share Posted April 23, 2013 (edited) A function that 'can' return an array does not always do so. if isarray($aRet)= 1 then consolewrite("$aRef is array") else consolewrite("$aRef is not array, suspect no items found") endif Edited April 23, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Clark Posted April 23, 2013 Author Share Posted April 23, 2013 Hmmm, but wouldn't _ArrayDisplay bork if that was the case? But let's assume for a second that it is not returning an array (even though _DisplayArray is showing the contents I need at element 0,0 and at 1,0), is there a way I can retrieve the elements that have been returned somehow, so I can use them? Xandy 1 Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 23, 2013 Share Posted April 23, 2013 It seems that $aRet isn't a 2D array it may be 1D. Have you tried $aRet[0] = 1 Then? Xandy 1 My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Clark Posted April 23, 2013 Author Share Posted April 23, 2013 It seems that $aRet isn't a 2D array it may be 1D. Have you tried $aRet[0] = 1 Then? Nope, that gives the same result. Here is the return variable definition in the udf: Local $aEdited[1][3] = [[0]] Could it be something to do with my autoit installation, as I have had similar problems with array variables before? Link to comment Share on other sites More sharing options...
Xandy Posted April 23, 2013 Share Posted April 23, 2013 (edited) Could it be something to do with my autoit installation, as I have had similar problems with array variables before?I don't know.Have you tried re-installing AutoIt and 'AutoIt Script Editor'?http://www.autoitscript.com/site/autoit/downloads/ Edited April 23, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted April 23, 2013 Share Posted April 23, 2013 (edited) I'll setup _GUIListViewEx_Editonclick(), that's Melba's function from here ?Run your example, and tell you how it works on my machine?edit: please show me how you declare and define $iEditMode. Edited April 23, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 23, 2013 Share Posted April 23, 2013 What doesUBound($aRet, 0)Return in your case ? My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
guinness Posted April 23, 2013 Share Posted April 23, 2013 UBound is preferred over IsArray. IsArray is useful for those starting out with arrays and have no clue what UBound is for. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Clark Posted April 23, 2013 Author Share Posted April 23, 2013 I'll setup _GUIListViewEx_Editonclick(), that's Melba's function from here ?Run your example, and tell you how it works on my machine?edit: please show me how you declare and define $iEditMode.Thanks Xandy,Global $lvitem,$iLV_List,$listbox,$hImage,$iEditMode = 0 is how it is declared and defined.Phoenix, ubount($aRet,0) returns 0 in all cases, i.e. when editing and when not editing.I can post my code here tomorrow if it helps? (Obviously I will cut it down to the pertinent parts.) Link to comment Share on other sites More sharing options...
PhoenixXL Posted April 23, 2013 Share Posted April 23, 2013 Phoenix, ubount($aRet,0) returns 0 in all cases, i.e. when editing and when not editing.It means the return isn't an array, check out the @error macro after calling the respective function to find out where the error occured, if still not sure you should ask to the author of the function through the Topic where the Function is present/uploaded. My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Xandy Posted April 23, 2013 Share Posted April 23, 2013 (edited) Have you loaded example2 from Melba's UDF? You should have a look if you haven't ;Do you: ;create a gui $hGUI = GUICreate("LVEx Example 2", 640, 430) ;create a listbox $cListView_Left = GUICtrlCreateListView("Tom", 10, 40, 250, 300, $LVS_SINGLESEL) ; Create array and fill the listview with items Global $aLV_List_Left[$iCount_Left + 1] = [$iCount_Left] For $i = 1 To UBound($aLV_List_Left) - 1 $aLV_List_Left[$i] = "Tom " & $i - 1 GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left) Next ; Initiate ListViewEx with the listbox control you just made $iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False, 2) ;have the _GUIListViewEx_Editonclick($iEditMode) in a loop? I don't know this UDF but that's what I would check at this point. Edited April 23, 2013 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 23, 2013 Moderators Share Posted April 23, 2013 (edited) Clark,I can explain what is happening. The function does indeed return an array - but only if an item in the ListView was doubleclicked. If nothing was double-clicked (i.e on most passes through the idle loop) then the function does not return an array but just an empty string. As I was just using _ArrayDisplay to display the returned array (and which just passes over a non-array parameter) I did not realise that this would cause a problem. There are several AutoIt functions and UDFs that do not always return arrays (e.g. IniReadSection, _FileListToArray) and quite frankly I did not expect the user to try and access the return without checking that there was actually an array present. It seems I was wrong. I will amend the function header to make clear that an array is only returned from an edit process launched by a double-click and that the user needs to check for the existence of an array before trying to access it. M23Edit:; Return values .: If no double-click: Empty string ; After double-click: 2D array of zero-based [row][column] items edited - total edits in [0][0] ; Failure: Sets @error as follows: ; 1 - ListView not editable ; 2 - Empty ListView ; 3 - Column not editable [...] ; The function only returns an array after an edit process launched by a double-click. If no ; double-click has occurred, the function returns an empty string. The user should check that a ; valid array is present before attempting to access it. Edited April 23, 2013 by Melba23 Xandy 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Clark Posted April 24, 2013 Author Share Posted April 24, 2013 Well thanks all, problem solved! (I feel guilty about causing all this fuss, but all is good in the end. I don't think I deserved to be called a "user" though. ) Thanks again all, especially Melba23 for making such a useful udf. Link to comment Share on other sites More sharing options...
kylomas Posted April 24, 2013 Share Posted April 24, 2013 clark, Hmmm, but wouldn't _ArrayDisplay bork if that was the case? It is but you are not checking the return #include <array.au3> local $scalar_var _arraydisplay($scalar_var) switch @error case 1 ConsoleWrite('Not an array' & @LF) case 2 ConsoleWrite('more than 2D array' & @LF) endswitch kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 24, 2013 Moderators Share Posted April 24, 2013 Clark,I don't think I deserved to be called a "user" thoughPurely generic usage of the term on my part - nothing personal. Glad you like the UDF. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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