BlazerV60 Posted June 20, 2014 Share Posted June 20, 2014 Hello everyone, I was trying to store this string into my array: "Hamsters | Cute" But after I store it, I used _ArrayDIsplay and it showed "Hamster" being on one row and "Cute" being on the row after it. So it looks like the "|" symbol acts as a row seperator in an array. My question is: Is there a way for my array to display "Hamsters | Cute" in 1 row ? Thanks, Brian Link to comment Share on other sites More sharing options...
ghost11996 Posted June 20, 2014 Share Posted June 20, 2014 (edited) Hi BlazerV60 Can you post some of your script ? Maybe try check autoit wiki http://www.autoitscript.com/wiki/Arrays If im not wrong then you are using this : Local $iMax Local $data = "Element 1|Element 2|Element 3" ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, "|") If IsArray($arr) Then For $i = 1 to $arr[0] ConsoleWrite($arr[$i] & @LF) Next EndIf Try change "|" to "," and check stringsplit function : https://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm Local $iMax Local $data = "Hamster | Cute,Array2 | Array2" ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, ",") If IsArray($arr) Then For $i = 1 to $arr[0] ConsoleWrite($arr[$i] & @LF) Next EndIf Edited June 20, 2014 by ghost11996 [color=rgb(255,0,0);]C[/color][color=rgb(255,140,0);]a[/color][color=rgb(255,215,0);]n[/color] [color=rgb(255,255,0);]i[/color] [color=rgb(175,238,238);]e[/color][color=rgb(0,255,255);]a[/color][color=rgb(64,224,208);]t[/color] [color=rgb(0,0,205);]S[/color][color=rgb(0,0,255);]i[/color][color=rgb(0,0,128);]g[/color][color=rgb(75,0,130);]n[/color][color=rgb(128,0,128);]at[/color][color=rgb(238,130,238);]u[/color][color=rgb(221,160,221);]r[/color][color=rgb(230,230,250);]e[/color] [color=rgb(0,255,0);]?[/color] :ermm: [color=rgb(0,255,0);]Project: Mini Youtube BETA[/color] Link to comment Share on other sites More sharing options...
BlazerV60 Posted June 20, 2014 Author Share Posted June 20, 2014 Hi BlazerV60 Can you post some of your script ? Maybe try check autoit wiki http://www.autoitscript.com/wiki/Arrays If im not wrong then you are using this : Local $iMax Local $data = "Element 1|Element 2|Element 3" ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, "|") If IsArray($arr) Then For $i = 1 to $arr[0] ConsoleWrite($arr[$i] & @LF) Next EndIf Try change "|" to "," and check stringsplit function : https://www.autoitscript.com/autoit3/docs/functions/StringSplit.htm Local $iMax Local $data = "Hamster | Cute,Array2 | Array2" ; The string in data will be split into an array everywhere | is encountered Local $arr = StringSplit($data, ",") If IsArray($arr) Then For $i = 1 to $arr[0] ConsoleWrite($arr[$i] & @LF) Next EndIf Hi ghost , Thanks for responding! For certain reasons, I need the separator to be "|" and not a comma or any other symbol. Here is what my code looks like: #include <Array.au3> #include <MsgBoxConstants.au3> $Ham1 = "Hamster" $Ham2 = "Cute" Local $aArray_Base[2] = ["Org item 1", "Org item 2"] _ArrayAdd($aArray_Base, $Ham1&"|"&$Ham2) _ArrayDisplay($aArray_Base, "1D - Base array") Link to comment Share on other sites More sharing options...
guinness Posted June 20, 2014 Share Posted June 20, 2014 Did you read the help file for _ArrayAdd()? Change the $sDelim_Item to something other than |. Ticket closed! BlazerV60 1 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...
czardas Posted June 20, 2014 Share Posted June 20, 2014 (edited) If you avoid using _ArrayAdd() then you should not encounter such problems. It is best if you know the size of the array in advance, then you can simply assign values to the array elements as and when needed. ; #include <Array.au3> Local $aArray[3] ; 3 elements are needed $aArray[0] = "Hamster" $aArray[1] = "Cute" $aArray[2] = $aArray[0] & "|" & $aArray[1] _ArrayDisplay($aArray) ; Also take a look at ReDim in the help file (for resizing arrays). Edited June 20, 2014 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted June 20, 2014 Moderators Solution Share Posted June 20, 2014 BlazerV60,See my posts >here and later in the same thread for more explanation. M23 BlazerV60 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...
czardas Posted June 20, 2014 Share Posted June 20, 2014 The changes to _ArrayAdd() certainly make the function more flexible, which I see as a definite improvement. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 20, 2014 Moderators Share Posted June 20, 2014 czardas,Thanks for that. 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...
mikell Posted June 20, 2014 Share Posted June 20, 2014 Using the OP's code in post #3 and assuming that the expected output is a 1D array - and using _ArrayAdd and its really nice improvement #include <Array.au3> $Ham1 = "Hamster" $Ham2 = "Cute" Local $aArray_Base[2] = ["Org item 1", "Org item 2"] _ArrayAdd($aArray_Base, $Ham1&"|"&$Ham2, 0, ";") _ArrayDisplay($aArray_Base, "1D - Base array") 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