Sign in to follow this  
Followers 0
gr1fter

help retrieve a value from a text file

4 posts in this topic

Hello. I have a log file:

Example of text file

THERE ARE LOTS OF VALUES IN THIS TEXT FILE BUT I ONLY WANT TO RETRIEVE WHAT IS IN BETWEEN THE EXIT CODE VALUES <ExitCode>14566</ExitCode>

I would like to search that log file and only get what is between the <ExitCode>??????</ExitCode> markers.

Can you help me with this please, I have an example and I can find the position in number format, but I dont know where to go from there to get the actual value. Do i want to string left from there??

$file = FileRead("C:\test.log")
$result = StringInStr($file, "</ExitCode>")


if $result then
    MsgBox(0, "Found it", "Found it at character position: " & $result)
Else
    MsgBox(0, 'Not Found', "String Not Found")
EndIf

Thanks,

Share this post


Link to post
Share on other sites



Look in the help-file for _StringBetween(), StringRegExp() :)

Share this post


Link to post
Share on other sites

Look in the help-file for _StringBetween(), StringRegExp() :)

Sweeet! Did not see that one. This is what I did and it worked perfectly

#Include <String.au3>


$file = FileRead("C:\test.log")


$aArray1 = _StringBetween($file, "<ExitCode>","</ExitCode>",-1)

MsgBox(48,"",$aArray1[0])

Share this post


Link to post
Share on other sites

Look in the help-file for _StringBetween(), StringRegExp() :)

Thanks for your help ;)

Share this post


Link to post
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
Sign in to follow this  
Followers 0