NTDOCNTDOC Administrator
Registered: 2000-07-28
Posts: 11634
Loc: Space
Garg,
Not sure if you'v seen this or not as not everyone has read the entire manual and not too many have memorized it but using this method should prevent any file handle issue.
GargoyleGargoyle
MM club member
Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Thanks Doc, now that you say without opening a file, it would return the same value, it makes alot of sense. I geuss I have been lucky in that I only opened 1 file.
Great example.
_________________________
Today is the tomorrow you worried about yesterday.
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
To close this one off, my preferred method is to create a simple wrapper for the Open() function. This probably also answers your original question about the scope of file handles too
Code:
Dim $fhLogFile, $fhOutFile
; Open log file... $fhLogFile=udfOpenFile("C:\temp\log.txt",5) If @ERROR "CANNOT OPEN LOG FILE"+@CRLF Exit @ERROR EndIf ; Open out file $fhOutFile=udfOpenFile("C:\temp\Out.txt",5) If @ERROR "CANNOT OPEN OUT FILE"+@CRLF Exit @ERROR EndIf
Function udfOpenFile($sPath,Optional $iMode) If ""=$iMode $iMode=2 EndIf $udfOpenFile=FreeFileHandle() If @ERROR $udfOpenFile=0 Exit @ERROR EndIf If Open($udfOpenFile,$sPath,$iMode) $udfOpenFile=0 Exit @ERROR EndIf Exit @ERROR EndFunction