eidolon74 Posted June 28, 2004 Share Posted June 28, 2004 (edited) I want this script to examine the second line of a file. And while I can get it to read the line, i can't get it to determine if the line contains the error i am looking for. The line in question is....if $line="Invalid object name 'hl7patient'." then.. the text is the actual error message I want it to find. so that if the second line is this specific error I can address it...any ideas? Bottom line if the text "Invalid object name 'hl7patient'." is in the second line of the file being read, i want the msgbox to appear, so far the msgbox does not appear even though the error is in line 2, and shows up in the 1st msgbox $line = FileReadline($file,2) Msgbox(0,"VIEW", $line) If @error = -1 Then MsgBox(0, "Error", "Unable to read file.") if $line="Invalid object name 'hl7patient'." then msgbox(0, "Error", "No Hl7patient table found") endif exit endif Edited June 28, 2004 by eidolon74 Link to comment Share on other sites More sharing options...
Developers Jos Posted June 28, 2004 Developers Share Posted June 28, 2004 (edited) You code has some logic errors in it: $LINE = FileReadLine($FILE, 2) MsgBox(0, "VIEW", $LINE) If @error = -1 Then MsgBox(0, "Error", "Unable to read file.") If $LINE = "Invalid object name 'hl7patient'." Then MsgBox(0, "Error", "No Hl7patient table found") EndIf Exit EndIf The If @error test should be the first line after the FileReadLine because you want to test the @error returncode from the read and not from the MsgBox. $LINE = FileReadLine($FILE, 2) If @error = -1 Then MsgBox(0, "Error", "Unable to read file.") Else MsgBox(0, "Debug","|" & $LINE & "|"); debug statement to show the actual content If $LINE = "Invalid object name 'hl7patient'." Then MsgBox(0, "Error", "No Hl7patient table found") EndIf EndIf Edited June 28, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
SweatyOgre Posted June 28, 2004 Share Posted June 28, 2004 (edited) Amazing, I was about to post, until I saw JdeB already had, and I was actually going to say the same, I feel like a scripting guru...but I'm not. Edited June 28, 2004 by SweatyOgre Link to comment Share on other sites More sharing options...
eidolon74 Posted June 28, 2004 Author Share Posted June 28, 2004 Thanks a lot...worked like a champ! Link to comment Share on other sites More sharing options...
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