Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

How to separate an input string

$
0
0
I am trying to read in a file and display/change in in a gui.
When I read in the file I'm reading it a line at a time.
I need to separate out the information on the line and put the correct information into the correct columns.

[ autoit ]         
#include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> #include <WindowsConstants.au3> Global $hListView Global $Input1 = GUICtrlCreateInput("", 72, 16, 209, 21) _Main() FileClose($file) Func _Main() Local $GUI, $hImage $GUI = GUICreate("List of folders", 400, 300) $hListView = _GUICtrlListView_Create($GUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hListView, "wstr", "Explorer", "ptr", 0) ; Set "Vista" Style GUISetState() ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "FileID", 100) _GUICtrlListView_InsertColumn($hListView, 1, "FileName", 100) _GUICtrlListView_InsertColumn($hListView, 2, "FolderName", 100) ; Loop until user exits Do While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit ;    Case $Button1 Local $file = FileOpen("C:\Scratch\Scratch11\test.txt") If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $row = 0 While 1 GUICtrlSetData($Input1, FileReadLine($file)) ; reads only the first Line of the file If @error = -1 Then ExitLoop ; Add lines $column = 0 _GUICtrlListView_AddItem($hListView, $Input1, $column) ;Row 1: Col 1 $column = $column + 1 _GUICtrlListView_AddSubItem($hListView, $row, "Row 1: Col 2", $column) ;Row 1: Col 2 $column = $column + 1 _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) ;Row 1: Col 3 $row = $row + 1 WEnd EndSwitch WEnd Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main

The file I'm working with test.txt has this in it:
2,1,"72496884:My mailbox","","My mailbox"
0,0,"1BD73CF2:5FDA:AS400LST","72496884:My mailbox","AS/400 Info"
0,0,"0D503CFA:5FDB:BPCSINFO","72496884:My mailbox","zBPCS info"
0,0,"1F0B3D0E:5FDD:FILEMAIL","72496884:My mailbox","zFiles by Mail"
0,0,"1CF43D15:5FDE:IN-MAIL","72496884:My mailbox","In-comming Saved Mail "



I only want the lines with 0,0 at the begging of the line.
For column one I need the four characters after the first Colin.  So the first example would be 5FDA
For column two I need all characters after the second Colin up until the second ".  So the first example would be AS400LST
For column three I need all characters in between the last set of quotes.  So the first example would be AS/400 Info

I will be putting that just before  ; Add lines
I don't know how to manipulate strings to separate these out.

Thank you,

Docfxit

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>