Micro Focus QTP (UFT) Forums
invalid procedure - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: invalid procedure (/Thread-invalid-procedure)



invalid procedure - bangla - 08-26-2010

Hi I get "Invalid call or procedure error" when I run the below script. Can you pls help me fixing it? thx.

error line : If FS.GetFile(Path1).Size <> FS.GetFile(Path2).Size Then

'''''''''''''''complete script'''''''''''''''''
Code:
Public function CompareFiles(Path1, Path2)
Dim FS, FirstFile, SecondFile
Set FS = CreateObject ("Scripting.FileSystemObject")

If FS.GetFile(Path1).Size <> FS.GetFile(Path2).Size  Then
CompareFiles = True
Exit Function
End If

Set FirstFile = FS.GetFile(Path1).OpenAsTextStream(1,0)
Set SecondFile = FS.GetFile(Path2).OpenAsTextStream(1,0)

CompareFiles = False

Do while  FirstFile.AtEndOfStream = False

Str1 = FirstFile.Read(1000)
Str2 = SecondFile.Read(1000)

CompareFiles = StrComp(Str1, Str2, 0)
If CompareFiles <> 0  Then
CompareFiles = True
Exit Do
End If
Loop

FirstFile.Close()
SecondFile.Close()

End Function

File1 = Inputbox("Enter directory for first file  ")

File1 = Inputbox("Enter directory for seconf  file  ")

If  CompareFiles(File1, File2) = False Then
Msgbox File1 & " " &File2 &" are same"

else

Msgbox File1 & " " &File2 &" are not same."
End If