kylomas Posted October 24, 2013 Posted October 24, 2013 (edited) On 10/24/2013 at 8:57 PM, guinness said: kylomas, You don't need to escape | in a character class. Thanks, good to know...non the less it works... edit: although I think I like UEZ's solution better... Edited October 24, 2013 by 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
guinness Posted October 24, 2013 Posted October 24, 2013 It's unforgiving, though it shouldn't be. Help file denotes which should be escaped and which special characters retaining their meaning. R doesn't which I found out the other day! UDF List: Reveal hidden contents _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
MadaraUchiha Posted October 24, 2013 Author Posted October 24, 2013 On 10/24/2013 at 8:55 PM, jdelaney said: here ya go...if you want an array for each line #include <array.au3> $string = "Info1||||Info2||||Info3||||Info4" & @CRLF & _ "Info5||||Info6||||Info7||||Info8" & @CRLF & _ "Info9||||Info10||||Info11||||Info12" ConsoleWrite($string) $aCRLFSplit = StringSplit($string,@CRLF,3) For $i = 0 To UBound($aCRLFSplit)-1 $aCRLFSplit[$i] = StringSplit($aCRLFSplit[$i],"||||",3) _ArrayDisplay($aCRLFSplit[$i]) Next Nearly I got it working when replacing @CRLF with @LF Otherwise if you use @CRLF this will happen:
jdelaney Posted October 24, 2013 Posted October 24, 2013 (edited) interesting, I can't reproduce that...i get an array of three arrays, each with 4 values edited to output the arrays: #include <array.au3> $string = "Info1||||Info2||||Info3||||Info4" & @CRLF & _ "Info5||||Info6||||Info7||||Info8" & @CRLF & _ "Info9||||Info10||||Info11||||Info12" ;~ ConsoleWrite($string & @CRLF) $aCRLFSplit = StringSplit($string,@CRLF,3) For $i = 0 To UBound($aCRLFSplit)-1 $aCRLFSplit[$i] = StringSplit($aCRLFSplit[$i],"||||",3) ConsoleWrite(_ArrayToString($aCRLFSplit[$i]) & @CRLF) Next where output is: Info1|Info2|Info3|Info4 Info5|Info6|Info7|Info8 Info9|Info10|Info11|Info12 Edited October 24, 2013 by jdelaney MadaraUchiha 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
MadaraUchiha Posted October 24, 2013 Author Posted October 24, 2013 Is it possible to add the splitted items in a listview, so i can view it more clear? Like Info1 is the Itemtext and for subitem 1 i get the first split which is info2 etc etc. And by @LF (Linefeed) I create a new ListViewItem, and also split into the subitems by ||| ? Because the console writeline is not that clear. Also I like to visualize my splitted stuff in a gui app (No Array_Display)
jdelaney Posted October 24, 2013 Posted October 24, 2013 (edited) not sure, exactly what you need...added 2 loops to create a 2d array, and to ouput through the array of arrays expandcollapse popup#include <array.au3> $string = "Info1||||Info2||||Info3||||Info4" & @CRLF & _ "Info5||||Info6||||Info7||||Info8" & @CRLF & _ "Info9||||Info10||||Info11||||Info12" ;~ ConsoleWrite($string & @CRLF) $aCRLFSplit = StringSplit($string,@CRLF,3) For $i = 0 To UBound($aCRLFSplit)-1 $aCRLFSplit[$i] = StringSplit($aCRLFSplit[$i],"||||",3) ;~ ConsoleWrite(_ArrayToString($aCRLFSplit[$i]) & @CRLF) Next For $i = 0 To UBound($aCRLFSplit)-1 $aTemp = $aCRLFSplit[$i] For $j = 0 To UBound($aTemp)-1 ConsoleWrite("Array[" & $i & "]; SubArray[" & $j & "] value=[" & $aTemp[$j] & "]." & @CRLF) Next Next ; sample of creating a 2d array Local $2DArray[UBound($aCRLFSplit)][1] For $i = 0 To UBound($aCRLFSplit)-1 $aTemp = $aCRLFSplit[$i] If UBound($aTemp) > UBound($2DArray,2) Then ReDim $2DArray[UBound($aCRLFSplit)][UBound($aTemp)] EndIf For $j = 0 To UBound($aTemp)-1 $2DArray[$i][$j] = $aTemp[$j] Next Next _ArrayDisplay($2DArray) ; sample of creating a transposed 2d array Local $2DArrayTransposed[1][UBound($aCRLFSplit)] For $i = 0 To UBound($aCRLFSplit)-1 $aTemp = $aCRLFSplit[$i] If UBound($aTemp) > UBound($2DArrayTransposed) Then ReDim $2DArrayTransposed[UBound($aTemp)][UBound($aCRLFSplit)] EndIf For $j = 0 To UBound($aTemp)-1 $2DArrayTransposed[$j][$i] = $aTemp[$j] Next Next _ArrayDisplay($2DArrayTransposed) added another case for a transposed 2d array gui demonstration: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> $string = "Info1||||Info2||||Info3||||Info4" & @CRLF & _ "Info5||||Info6||||Info7||||Info8" & @CRLF & _ "Info9||||Info10||||Info11||||Info12" ;~ ConsoleWrite($string & @CRLF) $iGuiWidth = 200 $iControlHeight = 20 $iControlBuffer = 10 $iControlWidth = $iGuiWidth-$iControlBuffer*2 $aCRLFSplit = StringSplit($string,@CRLF,3) $iGuiHeight = ((UBound($aCRLFSplit)+1)*$iControlBuffer) + (UBound($aCRLFSplit)*$iControlHeight) $hGui = GUICreate("something",$iGuiWidth,$iGuiHeight) For $i = 0 To UBound($aCRLFSplit)-1 $aCRLFSplit[$i] = StringSplit($aCRLFSplit[$i],"||||",3) GUICtrlCreateCombo("Line" & $i+1 & "'s split",$iControlBuffer,$iControlBuffer+($i*$iControlBuffer+$i*$iControlHeight),$iControlWidth,$iControlHeight) GUICtrlSetData(-1,_ArrayToString($aCRLFSplit[$i])) Next GUISetState(@SW_SHOW) Do Local $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE Exit Edited October 24, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
kylomas Posted October 24, 2013 Posted October 24, 2013 Boom...shot that moving target... ; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** #include <array.au3> #AutoIt3Wrapper_Add_Constants=n local $str $str &= 'Info1||||Info2||||Info3||||Info4' & @lf $str &= 'Info5||||Info6||||Info7||||Info8' & @lf $str &= 'Info9||||Info10||||Info11||||Info12' local $array = stringsplit($str,@lf,2) local $gui = guicreate('Huh ??!???') local $lv = guictrlcreatelistview('Item1|Item2|Item3|Item4',10,10,300,300) for $1 = 0 to ubound($array) - 1 ConsoleWrite($array[$1] & @LF) GUICtrlCreateListViewItem(stringreplace($array[$1],'||||','|'),$lv) next guisetstate() while 1 switch guigetmsg() Case $GUI_EVENT_CLOSE Exit endswitch wend 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
jdelaney Posted October 24, 2013 Posted October 24, 2013 copied, and made dynamic expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> $string = "Info1||||Info2||||Info3||||Info4" & @CRLF & _ "Info5||||Info6||||Info7||||Info8" & @CRLF & _ "Info9||||Info10||||Info11||||Info12" ;~ ConsoleWrite($string & @CRLF) $aCRLFSplit = StringSplit($string,@CRLF,3) For $i = 0 To UBound($aCRLFSplit)-1 $aCRLFSplit[$i] = StringSplit($aCRLFSplit[$i],"||||",3) Next $iSubItems = 0 For $i = 0 To UBound($aCRLFSplit)-1 $aTemp = $aCRLFSplit[$i] If UBound($aTemp) > $iSubItems Then $iSubItems = UBound($aTemp) Next For $i = 1 To $iSubItems If $i = 1 Then $sHeader = "Item" & $i Else $sHeader &= "|Item" & $i EndIf Next $iGuiWidth = 75*$iSubItems $iControlHeight = 20 $iControlBuffer = 10 $iControlWidth = $iGuiWidth-$iControlBuffer*2 $iGuiHeight = (2*$iControlBuffer) + (UBound($aCRLFSplit)*$iControlHeight)+20 $hGui = GUICreate("something",$iGuiWidth,$iGuiHeight) local $lv = guictrlcreatelistview($sHeader,$iControlBuffer,$iControlBuffer,$iGuiWidth-$iControlBuffer*2,$iGuiHeight-$iControlBuffer*2) for $i = 0 to ubound($aCRLFSplit) - 1 GUICtrlCreateListViewItem(_ArrayToString($aCRLFSplit[$i]),$lv) next GUISetState(@SW_SHOW) Do Local $msg = GUIGetMsg() Until $msg = $GUI_EVENT_CLOSE IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
dreamzboy Posted October 31, 2013 Posted October 31, 2013 This is great! This is what I need as well but less advanced. I just wanted to split the string by a list of input delimited by the "return" key. Are we having coding battle? If so, I'd like to know so I can pick side.
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