Sign in to follow this  
Followers 0
eidolon74

Help with file read

4 posts in this topic

#1 ·  Posted (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 by eidolon74

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (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. :D

Edited by SweatyOgre

Share this post


Link to post
Share on other sites

Thanks a lot...worked like a champ!

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