antmar904 Posted August 3, 2016 Posted August 3, 2016 Hi, I am trying to find the string "Cert1" in a txt file and if found display a message and if not found display a message but i'm stuck. Local $CertLog = @ScriptDir & "\CompCertChk.txt" Local $hFileOpen = FileOpen($CertLog, 0) Local $Content = FileRead($hFileOpen) FileClose($hFileOpen) Local $aString = StringRegExp($Content, "Cert1", 0, "") If @error = "1" Then MsgBox("", "", "Cert is installed") Exit Else If @error = "0" Then MsgBox("", "", "Cert is NOT installed") Exit (63) EndIf EndIf
jguinch Posted August 3, 2016 Posted August 3, 2016 Why don't you use StringInStr ? If StringInStr($content, "Cert1") Then MsgBox("", "", "String found") Else MsgBox("", "", "String not found") EndIf Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
antmar904 Posted August 3, 2016 Author Posted August 3, 2016 Yes that worked, thanks. I figured I was over complicating things
antmar904 Posted August 4, 2016 Author Posted August 4, 2016 How would I properly use the @error being returned?
jguinch Posted August 4, 2016 Posted August 4, 2016 Local $aString = StringRegExp($Content, "Cert1") If @error Then MsgBox("", "", "String NOT found") Else MsgBox("", "", "String found") EndIf Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now