Jump to content

How to catch need file


Recommended Posts

Dears

I have some information and need to catch what I need 

Information like this

Sstatus have Passed, notrun, canceled, fail

But I only want to cache failed item name.

How can I do this ......  Thanks!

 

Windows Client System Check For WDDM 1.3 Display Driver Support:Passed
Verifies PS2 Devices have a unique Plug and Play ID:NotRun
Camera Driver System Test - MediaCapture - TestValidateVariablePhotoSequenceFrameMetadata:Canceled

WGF Feature Level 9.3 Support (WoW64):Failed

Link to comment
Share on other sites

use FileReadToArray() to read the text into an array so you can process it line by line. on each line, use StringRight() to determine if the end of the string matches the required phrase. not that hard, really.

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
Share on other sites

Something like this:

Global $aTemp
Global $aMessages[] = ["Windows Client System Check For WDDM 1.3 Display Driver Support:Passed", "Verifies PS2 Devices have a unique Plug and Play ID:NotRun", _
    "Camera Driver System Test - MediaCapture - TestValidateVariablePhotoSequenceFrameMetadata:Canceled", "WGF Feature Level 9.3 Support (WoW64):Failed"]
For $i = 0 To UBound($aMessages) - 1
    $sTemp = StringSplit($aMessages[$i], ":")
    MsgBox(0, "Result", "Check: " & $sTemp[1] & @CRLF & "Result: " & $sTemp[2])
Next

If there is more than one colon in the text the code needs to be modified.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

An SRE version...

#include <array.au3>

; name of file containing messages to search for
local $infile = @scriptdir & '\find text test01.txt'

; open file in read mode (default)...if error exit with message
local $hfl = fileopen($infile)
if $hfl = -1 then exit msgbox(17,'Error','File open failed !' & @CRLF & 'File = ' & $infile)

; read file to string variable
local $sFileString = fileread($hfl)

; find all instances of ":Failed" in file and capture the name portion of the line
local $aFailed = stringregexp($sFileString,'(.*?):Failed',3)

; display the resulting array
_arraydisplay($aFailed)

File used = find text test01.txt

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

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...