Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Low Level File Command Error
Message
From
11/09/2003 09:38:33
 
 
To
11/09/2003 04:26:48
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro Product Documentation
Miscellaneous
Thread ID:
00827799
Message ID:
00828129
Views:
17
>>>>>>I am experiencing an intermittant problem creating or opening text files. FOPEN and FCREATE both will occationally return an empty string rather than a numeric file handle. If I exit VFP and restart it works fine. I am running VFP7 SP1 on Win2k Pro Build 5 SP4. Any thoughts on this would be appreciated.
>>>>>
>>>>>
>>>>>Jeff,
>>>>>
>>>>>Just finished reading your answer to Cetin.
>>>>>
>>>>>It is most likely imo that you have a currently selected table/cursor with a field name that is the same as your variable
>>>>>
>>>>>this is consistent with the behaviour of gets() && fputs() you described
>>>>>
>>>>>
>>>>>&& 6sp5
>>>>>?fgets('  ', 20) && returns empty string, no error
>>>>>?fgets('  ', 20) && no error
>>>>>
>>>>
>>>>That's a good thought but what i'm doing is calling a method that builds a string using date and file type for next available file name and assigning the return value a variable which is only used here lsEdiOutFile. Then using that variable to create a file.
>>>>
>>>>
>>>>lsEdiOutFile = this.Get837name(lcFormType)
>>>>lnEdiOutFile = FCREATE(lsEdiOutFile)
>>>>IF ! lnEdiOutFile > 0
>>>>	WAIT WINDOW 'Cannot Create OutPut File ' + lsEdiOutFile
>>>>	RETURN
>>>>ENDIF
>>>>
>>>>* Code to build output strings
>>>>
>>>>=FPUTS(lnEdiOutFile, lsHLSegment)
>>>>
>>>>
>>>>
>>>>lsEdiOutFile is a string containing the name of the file built. lnEdiOutFile usually is a numeric containing the file handle. But about once a week lnEdiOutFile contains a blank string. lsEdiOutFile is built but cannot be accessed by the file handle and is not returning any errors. The file can only be closed by exiting VFP. I did not think that it was possible for FOPEN or FCREATE to return anything other than a numeric.
>>>>
>>>>thanks jeff
>>>
>>>Jeff,
>>>
>>>If fcreate() were to return anything other than numeric and null, then you would get an error on the line where you test it to be greater than zero.
>>>
>>>Do you get an error there ?? If not, would anything in the program be resetting it ?
>>
>>No on both counts which is strange. Although I have a blank string assigned to lnEdiOutFile it is not giving a data mismatch error. I have caught the problem and suspended the program to look in the debugger but didn't think to look at vartype. it shows as a blank string (not null) but i didn't test for null. Also, why is Fputs not complaining about a non-numeric file handle. (To compound the strangeness, I have the same thing happening with other code on an FOPEN where FGETS returns empty strings from a file with the same non-numeric file handle.)
>
>Fputs() and fgets() not complaining about a non numeric fd is a bug imo.
>Test the return type of fcreate(). If this one passes and you still find lnEdiOutFile to be blank it is one of the following possibilities
>
>(1) vfp's memory has gone bezerk ( not very likely)
>(2) you have an alias with field name lnEdiOutFile
>(3) you re-assign lnEdiOutFile somewhere by one means or another (if it is a private var, make it local, just in case)
>(4) You wouldn't be confusing lnEdiOutFile and lsEdiOutFile, would you ?
>(5) ... (out of ideas)
>
>Success,

I'm still waiting for it to occur again. Hasn't happened in a couple of days. I'm actually leaning toward number 1 at this point as I just had another strange incident occur. I was looking at some date specific data and used the DATE() as a parameter in a SQL statement. The data returned was for all dates. I then did a BROWSE for date = DATE() and got all data again. I shut down VFP and restarted and the DATE() function worked properly. I talked to my hardware guy and am going to get the machine scrubbed and reinstalled. As for confusing the numeric and string vars, that was my first thought but in fact FCREATE and FOPEN are returning a string rather than a numeric value. Bizarre. thanks, jeff
Previous
Reply
Map
View

Click here to load this message in the networking platform