Mikeman27294 Posted June 18, 2011 Share Posted June 18, 2011 Hello everyone, right now, I am making a few programs, one of which is a variable manager. What I am trying to do, I hope, will seem quite obvious, as I hope will be what I am doing wrong. Local $a=0 Do $a+=1 _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) Until $a = UBound($Variables) Does anybody have any ideas on what I am doing wrong? Also, just to clear up a little bit, I cannot add an array to this list view to the best of my knowledge, because my array is in this format - $Variables[x] and not in the format $Variables[x][y]. (Is that what is meant by 1D and 2D by the way? Thanks). Can anybody sopt what I am doing wrong here? Thanks. Hopefully, I will start helping more people with whatever I can soon, instead of leeching off all of you. I'm still learning and I have a far way to go so if I am doing something that seems illogical, go ahead and have a laugh, but please help me where you can. Hopefully, soon, I can and will start to help people. Thanks for any help people. Cya all later. Link to comment Share on other sites More sharing options...
martin Posted June 18, 2011 Share Posted June 18, 2011 Hello everyone, right now, I am making a few programs, one of which is a variable manager. What I am trying to do, I hope, will seem quite obvious, as I hope will be what I am doing wrong. Local $a=0 Do $a+=1 _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) Until $a = UBound($Variables) Does anybody have any ideas on what I am doing wrong? Also, just to clear up a little bit, I cannot add an array to this list view to the best of my knowledge, because my array is in this format - $Variables[x] and not in the format $Variables[x][y]. (Is that what is meant by 1D and 2D by the way? Thanks). Can anybody sopt what I am doing wrong here? Thanks. Hopefully, I will start helping more people with whatever I can soon, instead of leeching off all of you. I'm still learning and I have a far way to go so if I am doing something that seems illogical, go ahead and have a laugh, but please help me where you can. Hopefully, soon, I can and will start to help people. Thanks for any help people. Cya all later. An array has UBound elements, but th efirst is [0] and the last is [uBound($var) - 1] So Local $a=0 Do _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) $a+=1 Until $a = UBound($Variables) Or Local $a=0 while $a < UBound($Variables) _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) $a+=1 wend Or Local $a for $a = 0 to UBound($Variables) - 1 _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) next Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 18, 2011 Moderators Share Posted June 18, 2011 Mikeman27294,I suggest you use a For...Next loop like this:For $a = 0 To UBound($Variables) - 1 _GUICtrlListView_AddItem($VariableDialoge, $Variables[$a]) NextMuch easier to code that way. And before you ask: I assume your array runs from the first element [0] like this:[0] - value 1 [1] - value 2 [2] - value 3UBound will return 3 (as you have 3 elements) but you need to use [0] to [2] - hence For $a = 0 To UBound($Variables) - 1But rememeber that if you get your array from a an AutoIt function like FileListToArray or StringSplit, you usually get the count in the [0] element array so you could use For $a = 1 To $Variables[0] to do the same thing.All clear? 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...
smartee Posted June 19, 2011 Share Posted June 19, 2011 hi, You can also use this, if the data in the array is important, but their indices are not Local $aNames[4] = ["Mikeman27294", "martin", "Melba23", "smartee"] For $sName In $aNames MsgBox(64, "Demo3", $sName) Next -smartee Link to comment Share on other sites More sharing options...
Mikeman27294 Posted June 19, 2011 Author Share Posted June 19, 2011 Thanks guys, atleast now it is reporting back (Using Melba23's for...to...next script). The only problem is that it is returning only "1", and none of these variables. Would it be that $a isnt increasing by 1 and needs $a+=1 to be placed into the script, or would it automatically do that? Thanks. Link to comment Share on other sites More sharing options...
smartee Posted June 19, 2011 Share Posted June 19, 2011 (edited) Using the "for.. to" construct as M23 demonstrated will iterate through all the elements of the array. $i+=1 is not needed because after the "to" in "for...to", Step 1 is implied (unless otherwise specified) Lookup "for..to" in the helpfile for more details. Edit:Grammar Edited June 19, 2011 by smartee Link to comment Share on other sites More sharing options...
guinness Posted June 19, 2011 Share Posted June 19, 2011 (edited) Also not strictly on-topic, but when it comes to re-sizing your Arrays for whatever reason I suggest reading this post >> it's not a Function but information about being smart(ee) with Arrays. Edited June 19, 2011 by guinness 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...
Mikeman27294 Posted June 19, 2011 Author Share Posted June 19, 2011 Ok, sell I couldnt find anything in the help file that was "for.. to"but I found "for... to... step... next" but when I added that in to my script, that didnt work either... it just returned "1" again. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 19, 2011 Moderators Share Posted June 19, 2011 Mikeman27294, Add this to your script to see what is in your array and whether you are extracting the elements correctly: ; Put this at the top of your script #include <Array.au3> ; And use this for the loop code If IsArray($Variables) Then _ArrayDisplay($Variables, "$Variables") Else MsgBox(0, "Error", "$Variables is not an array!") EndIf For $a = 0 To UBound($Variables) - 1 ConsoleWrite("Element " & $a & " = " & $Variables[$a] & @CRLF) Next You should see a dialog appear which holds the whole array so you can check if the contents are what you expect - if $Variables is not an array, you will get an Error MsgBox. Assuming all is well you will then get a list of the individual elements appearing in the SciTE console. If you do not get this then we need to look at how you are filling the array and why you are not getting what you want. As several responders over the past few days have mentioned, it is ususal to provide a reasonable amount of code to debug when you ask for help. All you ever provide are small snippets which do not offer a lot to work on. I have also pointed out that short, staccato posts such as your one immediately above are of absolutely no use at all - what can we deduce from: I found "for... to... step... next" but when I added that in to my script, that didnt work eitherother than the code does not work? Have you made a syntax error? Have you declared the variables you are using? What error message did you get, if any? What returned "1"? If you do not provide code, the least you can do is explain in detail why you feel the code is not working as you wish and what symptoms you get. As with all newcomers to this forum, I am very happy to help you learn about AutoIt and to debug your script - that is one reason I am here after all. But if you carry on in this vein I will consider seriously whether I am prepared to continue offering assistance to someone who makes no effort to help those ready to help him. 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...
Mikeman27294 Posted June 19, 2011 Author Share Posted June 19, 2011 (edited) Thanks for that little line of code. The array is set to one, which means that I have to re-assess that other function which places those variables in an array.EDITAwesome, I figured out that other little problem, quite simple... it was not pointing to the file to read from properly. Thank you guys, I honestly could not have got this working without your help. Edited June 19, 2011 by Mikeman27294 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