Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with fopen
Message
From
28/05/1998 11:34:33
 
 
To
28/05/1998 01:53:35
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00102261
Message ID:
00102758
Views:
32
Tomeu,

You could have a routine something like the following to
determine the low-level file error.
-------------------------------------------------------------------------------------------
* ** Routine to open file for low-level processing ***
*: NAME:        y1FLOpn (tcFile)
*: Description: Low level file processing.
*:              Open low level file.
*: Other:       Refer to Flow_All.Prg
*: Parameters:  tcFile   = Low level file path & name to open.
*: Returns:     lnFile   = Low level file handle.
*:                         Defaults to -1 on error.

FUNCTION y1FlOpn

LPARAMETERS;
  tcFile

LOCAL;
  lcErrMsg,;
  lcFile  ,;
  lnFile

lcFile   = tcFile
lcErrMsg = []


*--Processing ..............................................................
*-- Open ASCII input file 
IF FILE(lcFile)	    	  			          && Make sure input file is present
  lnFile = FOPEN((lcFile))						  && Input file

  IF lnFile < 0												  && Ck for low-level file open error
	  lcErrMsg = y1FLErr(FERROR())			  && Encountered error
    lnFile = -1                         && Indicate error
  ENDIF
ELSE                                    && Did not find file
  lcErrMsg = [--> ERROR:  Input file not found: ] + lcFile
  lnFile = -1                           && Indicate error
ENDIF

*--Check for error
IF lnFile < 0
  =y1Msg01(;
    [File error encountered!] + CHR(13) +;
      lcErrMsg,;
    [Low Level File Processing])
ENDIF

-------------------------------------------------------------------------------------------
* ** Routine to handle error for low-level processing ***

*: NAME:        y1FLErr (tnFErr)
*: Description: Low level file processing.
*:              Error routine.
*: Other:       Refer to Flow_All.Prg
*: Parameters:  tnFErr   = AscII file error number
*: Returns:     lcErrMsg = Error message

FUNCTION y1FlErr
PARAMETER tnFErr

*--Set-Up ..................................................................
LOCAL ;
  lcErrMsg,;
  lnFErr

lnFErr = tnFErr


*--Processing ..............................................................
DO CASE
CASE lnFErr = 2
  lcErrMsg = [File Not Found]
CASE lnFErr = 4
  lcErrMsg = [Too Many Files Open -- Out of Handles]
CASE lnFErr = 5
  lcErrMsg = [Access Denied -- File Already Open, or Read-Only]
CASE lnFErr = 6 
  lcErrMsg = [Invalid File Handle Given]
CASE lnFErr = 8
  lcErrMsg = [Out Of Memory]
CASE lnFErr = 25
  lcErrMsg = [Seek Error -- Tried to seek before start of file]
CASE lnFErr = 29
  lcErrMsg = [Disk Full]
CASE lnFErr = 31
  lcErrMsg = [Error Opening File or General Failure -- EOD Encountered]
OTHERWISE
  lcErrMsg = [Unknown Error]
ENDCASE


*--Clean-Up ................................................................

RETURN lcErrMsg
-------------------------------------------------------------------------------------------
======================================================================

>Thanks for your help but i have found the bug.
>
>I'm novice in Visual FOXPRO and in order to document the app. i put the sequential file in the project (in other files - txt files). When I execute the exe file generated with this project, the program can't open the file and returns an invalid handler (-1).
>
>I agree if you can explain more than this.
----------------------------------
-myron kirby (mkirby2000@gmail.com)-
Previous
Reply
Map
View

Click here to load this message in the networking platform