Jump to content

Recommended Posts

Posted

I have used get wintext to get the text and created a file and saved all the window text in it. there are four strings that i want to validate if it exist in the file or now, i am stuvck and i dont know how to do it could anyone help. I used the stringinstr but i am not able to read multiple text , i am really not getting it plz someone help 

Posted (edited)
53 minutes ago, shreya said:

... created a file and saved all the window text in it.

Please post a file or text that you want to scan, and name the strings you wish to validate.

Quote

There are four strings that i want to validate if it exist in the file.

Do all strings have to be present to fulfill the condition? A more detailed description of your request would be helpful ;).

Edited by Musashi

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted
1 hour ago, Musashi said:

Please post a file or text that you want to scan, and name the strings you wish to validate.

Do all strings have to be present to fulfill the condition? A more detailed description of your request would be helpful ;).

the attached is the file in which i want to check if the following text is present or not:

"DataMemory.hex in DATA MEMORY area  ...File successfully loaded."
"OTAServiceManager.hex in PROGRAM MEMORY area  ... File successfully loaded."
"OTAResetManager.hex in PROGRAM MEMORY area  ...File successfully loaded."
"DisplayModule.hex in PROGRAM MEMORY area  ...File successfully loaded."

Log.txt

Posted
1 hour ago, Musashi said:

Please post a file or text that you want to scan, and name the strings you wish to validate.

Do all strings have to be present to fulfill the condition? A more detailed description of your request would be helpful ;).

as i need to validate that all those files are successfully loaded so i need all the four string mentioned, if not one of the file is loaded it should provide an error

 

Posted
49 minutes ago, shreya said:

"DataMemory.hex in DATA MEMORY area  ...File successfully loaded."
"OTAServiceManager.hex in PROGRAM MEMORY area  ... File successfully loaded."
"OTAResetManager.hex in PROGRAM MEMORY area  ...File successfully loaded."
"DisplayModule.hex in PROGRAM MEMORY area  ...File successfully loaded." 

None of these strings exists in the log file. You will find i.e. DataMemory.hex in DATA MEMORY area and File successfully loaded separately, but not as a complete string.

 

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Posted

There are multiple runs in that log file, so there is an extra untold condition: all 4 lines should be adjacent and at the end of the file (I assume this is where the last run is logged).

The simpler would be to delete the log file after checking the 4 lines are there.  Listing them isn't hard:

Local $s = FileRead("log.txt")

Local $p = "((?:DataMemory.hex in DATA|" & _
    "OTAServiceManager.hex in PROGRAM|" & _
    "OTAResetManager.hex in PROGRAM|" & _
    "DisplayModule.hex in PROGRAM) MEMORY area  ...\R< File successfully loaded.)"

Local $a = StringRegExp($s, $p, 3)
ConsoleWrite(_ArrayToString($a, @LF & @LF) & @LF)

That should help you getting started.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
6 minutes ago, Musashi said:

None of these strings exists in the log file. You will find i.e. DataMemory.hex in DATA MEMORY area and File successfully loaded separately, but not as a complete string.

 

i tried putting the strings in array and looping but i am unable to read it 

eg 

$a="DataMemory.hex in DATA MEMORY area "

$b="File successfully loaded "

local $search[2]=["$a",$b]

or $i = 0 To $search[2] Step $init
      ConsoleWrite(" files : " & $search[$i] & @CRLF)

 

it only prints the value of $a and not $b

 

Posted
1 minute ago, jchd said:

There are multiple runs in that log file, so there is an extra untold condition: all 4 lines should be adjacent and at the end of the file (I assume this is where the last run is logged).

The simpler would be to delete the log file after checking the 4 lines are there.  Listing them isn't hard:

Local $s = FileRead("log.txt")

Local $p = "((?:DataMemory.hex in DATA|" & _
    "OTAServiceManager.hex in PROGRAM|" & _
    "OTAResetManager.hex in PROGRAM|" & _
    "DisplayModule.hex in PROGRAM) MEMORY area  ...\R< File successfully loaded.)"

Local $a = StringRegExp($s, $p, 3)
ConsoleWrite(_ArrayToString($a, @LF & @LF) & @LF)

That should help you getting started.

ok i ll try this..

Posted
11 minutes ago, jchd said:

There are multiple runs in that log file, so there is an extra untold condition: all 4 lines should be adjacent and at the end of the file (I assume this is where the last run is logged).

The simpler would be to delete the log file after checking the 4 lines are there.  Listing them isn't hard:

Local $s = FileRead("log.txt")

Local $p = "((?:DataMemory.hex in DATA|" & _
    "OTAServiceManager.hex in PROGRAM|" & _
    "OTAResetManager.hex in PROGRAM|" & _
    "DisplayModule.hex in PROGRAM) MEMORY area  ...\R< File successfully loaded.)"

Local $a = StringRegExp($s, $p, 3)
ConsoleWrite(_ArrayToString($a, @LF & @LF) & @LF)

That should help you getting started.

thank you so much it is finally working , i am new to autoit could you please explain me how you inserted multiple strings , what is \R required and why there is 3 in the line StringRegExp and what is LF USED and why it is used 

 

Posted
13 minutes ago, shreya said:

i tried putting the strings in array and looping but i am unable to read it 

eg 

$a="DataMemory.hex in DATA MEMORY area "

$b="File successfully loaded "

local $search[2]=["$a",$b]

or $i = 0 To $search[2] Step $init
      ConsoleWrite(" files : " & $search[$i] & @CRLF)

 

it only prints the value of $a and not $b

 

is it not possible to do using arrays?what is lacking in this could you please explain

Posted

the 3 is option $STR_REGEXPARRAYGLOBALMATCH  (see help)

\R is the escape for newline termination (that is @CRLF or @CR or @LF)

I use @LFs to make display more easily readable.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Posted
3 minutes ago, jchd said:

the 3 is option $STR_REGEXPARRAYGLOBALMATCH  (see help)

\R is the escape for newline termination (that is @CRLF or @CR or @LF)

I use @LFs to make display more easily readable.

Local $p = "((?:DataMemory.hex in DATA|" & _
    "OTAServiceManager.hex in PROGRAM|" & _
    "OTAResetManager.hex in PROGRAM|" & _
    "DisplayModule.hex in PROGRAM) MEMORY area  ...\R< File successfully loaded.)"

if ( StringRegExp($a, $p, 3)) then

   MsgBox(0,"msg","match",1)
Else
    MsgBox(0,"msg"," not match",1)
    EndIf

 

i changed a lil bit as i want a message box to tell that it matches or not but here the output says that it is not a match ?

Posted (edited)
9 minutes ago, shreya said:

Local $p = "((?:DataMemory.hex in DATA|" & _
    "OTAServiceManager.hex in PROGRAM|" & _
    "OTAResetManager.hex in PROGRAM|" & _
    "DisplayModule.hex in PROGRAM) MEMORY area  ...\R< File successfully loaded.)"

if ( StringRegExp($a, $p, 3)) then

   MsgBox(0,"msg","match",1)
Else
    MsgBox(0,"msg"," not match",1)
    EndIf

 

i changed a lil bit as i want a message box to tell that it matches or not but here the output says that it is not a match ?

got the issue , thank you so much for helping out.

I added a wrong message to validate the negative scenario it is still showing match, if i add an incorrect text  should it display that the text doesnt match.

 

Edited by shreya
Posted

Remove option 3 for your code to work, but ...

The pattern I used matches any of the 4 lines.  What you want is to match all 4 lines (in fact 8 in total).

In your case it's even more robust to look for the 8 lines as a single block.  I expect the order remains the same across runs, but I let the source files change as well as the checksums.

Local $s = FileRead("log.txt")

Local $p = "DataMemory\.hex in DATA MEMORY area  \.\.\.\R< File successfully loaded\.\N*\R" & _
    ".*?OTAServiceManager\.hex in PROGRAM MEMORY area  \.\.\.\R< File successfully loaded\.\N*\R" & _
    ".*?OTAResetManager\.hex in PROGRAM MEMORY area  \.\.\.\R< File successfully loaded\.\N*\R" & _
    ".*?DisplayModule\.hex in PROGRAM MEMORY area  \.\.\.\R< File successfully loaded\.\N*\R"
If Not StringRegExp($s, $p) Then MsgBox(0, "Error", "µC programming failed")

 

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

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