Sign in to follow this  
Followers 0
KPrior

FileReadLine

2 posts in this topic

:">

I am trying to look at a file and open it. This works fine.

Then I want to see if a line or word exists in the file (Not an INI file)

If this does exist then go to next function, if it does NOT exist then add it.

The following kinda works as it returns 0, 0, 53. In the real world it may not be 53 so I want to see if data or a line exists, if it does go to next if not then add a specifed line.

Here is part of the file: :">

;; Adding in for verification

$file3 = FileOpen($var1 & "\lib\Awt.Properties", 0)

; Check if file opened for reading OK

If $file3 = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

; Read in lines of text until the EOF is reached

While 1

$line = FileReadLine($file3, 3)

If @error = -1 Then ExitLoop

$result = StringInStr($line, "JavaSSOHook", 1, 1)

;MsgBox (0, "Title", $result)

;EndIf

If $result = 53 Then

MsgBox(0, "Note:", "We SHOULD NOT write to Awt.Properties file as it is already there")

Exit

Else

MsgBox(0, "Note:", "We SHOULD write to Awt.Properties file as it is NOT already there")

Call ("WriteFile3")

EndIf

Wend

FileClose($file3)

Share this post


Link to post
Share on other sites



StringInStr() returns the position of the found string.

You can do it this way (not 0 is a true condition)

If $result <> 0 Then
oÝ÷ ÚÛ¢^jx­tÆ­®ç¢wb¶*'jëh×6
If $result Then

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