Jump to content

FileOpen keeps erroring......


 Share

Recommended Posts

I have verified I have write access to the folder I am trying to write to.

;#####################################################################################################################################

;Get the current date, post it to the call logger, and format date for use in call log file name
$todaysDate = @MON & "/" & @MDAY & "/" & @YEAR
GuiCtrlSetdata($lblTodaysDate, $todaysDate)
$dateForFilename = @ScriptDir & "\call_logs\" & @MON & "-" & @MDAY & "-" & @YEAR & ".log"

;Check if there is already a running call log for the day
If FileExists($dateForFilename) Then
;there is a running call log for the day, so load it into the call logger

;code to populate the call logger will go here

Else ; Doesn't exist, so create a new call log for today

Local $myCallLogfile = FileOpen($dateForFilename, 82)

If $myCallLogfile = -1 Then
MsgBox(0, "Error", "Unable to create new call log.")
Exit
Endif
FileClose($myCallLogFile)
EndIf
;#######################################################################################################################################

This keeps returning -1 and erroring out every time. I also displayed a messagebox to troubleshoot and the $dateForFilename variable is the correct path to the file I want to open/create. On the FileOpen line I am using 8 & 2 modes to create the directory if the call_logs folder doesn't exist, and 2 to open in write mode. Any idea why it is unable to create the file?

-hogfan

Link to comment
Share on other sites

This line

Local $myCallLogfile = FileOpen($dateForFilename, 82)

Should be

Local $myCallLogfile = FileOpen($dateForFilename, 10)

When combining different modes you should add the values to gether. 82 is not a valid combination of modes as the unicode modes already include the read/write option.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...