Jump to content

Recommended Posts

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 by eidolon74
Link to post
Share on other sites
  • Developers

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

    No registered users viewing this page.

×
×
  • Create New...