17 posts in this topic
i receive a strange result from splitting strings elements contained in an array .(In attachment the resulting array)
My Array contains strings like:
INFO [26.01.2018 13:53:44] [XYZ] [XYZ, XYZ] Delta pack 5.2.25_17.01.2018 server version: 5.2.25_22.01.2018 not available. My code is:
For $a=0 to UBound($Array_info_4) -1 $Array_info_4[$a]=StringSplit($Array_info_4[$a],",",$STR_NOCOUNT) Next I tried also using a second Array to store the result, but the result was the same, like in the attachment.
Where is my mistake? :-)
i try to read Wlan Profiles from local Computer. First Step Command Prompt: netsh wlan show profiles >> C:\temp\test\wlan.txt.
Second Step (here's a sample script to find a solution for my problem. Script read each line of wlan.txt and Display Name of Wireless Connection which i have set up in the past. If i edit wlan.txt to wlan - sample.txt script works. wlan.txt containsline without : so i get error message. How can i read only lines beginning with All User Profile so i can use original file wlan.txt which i crate in the command prompt with: netsh wlan show profiles >> C:\temp\test\wlan.txt ?
Thanks for any suggestions.
$Form1 = GUICreate("Form1", 374, 268, 892, 512) $Button1 = GUICtrlCreateButton("button", 145, 35, 75, 25) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file = "C:\temp\test\wlan.txt" FileOpen($file, 0) For $i = 1 to _FileCountLines($file) $line = FileReadLine($file, $i) $after = StringSplit($line, ":") MsgBox(262144, "Result", $after, 0) Next FileClose($file) EndSwitch WEnd
wlan - sample.txt
My script currently reads a text file line by line. I want it to look for this the chat message below and skip the session messages.
There are some garbage lines that I want it to skip over. So if a line doesnt match that format then skip it. I tried experimenting with StringRegExp but I think I'm using it wrong. Heres my code
If StringRegExp($read, '\W\d\d\w\d\d\D.\W') = Not @error Then I was hoping that this would be able to see the open bracket, 2 digits, a colon, 2 digits, close bracket, a space and a <. But it doesn't seem to be working.
Eventually I want to be able to extract the username and chat message into separate strings but I haven't got that far yet.
Here is another WMIC script that parses properties from various alias classes.
ie: COMPUTERSYSTEM, CDROM, IDECONTROLLER, DISKDRIVE, etc.
I've encountered a strange problem while adding files (or rather file names) to a ListView.
Mechanics are simple:
1. Select files to add (FileOpenDialog + Multiselect)
2. Split selected string (filepath) into array (StringSplit)
3. File names appear on ListView (GUICtrlCreateListViewItem)
Writing starts from second array (since 0 is array size, and 1 is filepath).
Problem occurs when I try to add one file. Then, no filenames are added.
As far as I know, selecting one file generates only 2 strings (0 and 1) to split, therefore no string is written into ListView.
Is there any way / workaround to make this thing work properly?
Some code here:
While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idAddTest $sMessage = "Select test cases to load:" $sFileOpenDialog = FileOpenDialog($sMessage, @WorkingDir & "\data\tests\", "All (*.*)", $FD_FILEMUSTEXIST & $FD_MULTISELECT) If @error Then MsgBox($MB_SYSTEMMODAL, "", "No test(s) were selected.") FileChangeDir(@ScriptDir) Else FileChangeDir(@ScriptDir) $aFileList = StringSplit($sFileOpenDialog, "|", @CRLF) For $i = 2 to $aFileList MsgBox( 0, "test", $aFileList[$i]) ;just for testing purposes GUICtrlCreateListViewItem($aFileList[$i], $idTestCaseList) Next EndIf EndSwitch WEnd
And nothing more spectacular from ListView side:
Global $idTestCaseList = GUICtrlCreateListView("List of Tests ", 24, 24, 225, 502, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT)) GUICtrlSetTip(-1, "List of test cases."& @CRLF &"Hold CTRL to select multiple lines.")
Any help appreciated!