Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FILE() Function - Pants on fire
Message
From
22/07/2004 07:46:18
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Other
Title:
FILE() Function - Pants on fire
Miscellaneous
Thread ID:
00926938
Message ID:
00926938
Views:
46
Hi, O Learned ones.

I've never trusted that lying toad of a function, FILE(). Now it's lying to my face whilst unblinkingly looking me in the eye. I have the following code:
Select SYSOPTIONS
If EMPTY( OPAFOLDER)                        && If location of Output A table not known
    = MESSAGEBOX( "You have not yet defined the Service Details Table Folder in which to" + CHR(13) + ;
		"store the Service Details Analysis Data.  First you will need to do this via" + CHR(13) + ;
		"the System Options Form.", MB_ICONSTOP, "No Service Details Folder/Directory")
    Thisform.cmdRunAnal.Enabled    = .F.
Else                                        && there is a location for Output A table
    lcOPAFolder	= ALLTRIM( OPAFOLDER)
    lcOPAPath   = lcOPAFolder + "OutputA.dbf"
    If not ( FILE( lcOPAPath))	        && But no Output A table there
        = MESSAGEBOX( "Service Details Data Table, 'OUTPUTA.DBF', does not exist in System Options' " ;
                      "specified folder, "  + ALLTRIM( lcOPAFolder) + "." + CHR(13) + ;
		    "Possibly it was deleted or moved to another location." + CHR(13) + ;
                      "The system will now create the table in the specified folder.", MB_ICONINFORMATION, ;
                      "No Service Details Data Table - System will Create")				  
        Wait WINDOW "Creating Service Details Data Table, 'OUTPUTA.DBF' ..." NOWAIT NOCLEAR
        lcDef	= SYS(5) + SYS(2003)
        Set Default To ( lcOPAFolder)
        Select csrOutputA               && Used as template
        Copy Structure to OutputA 
        Set Default To ( lcDef)
        Wait CLEAR
    EndIf not FILE()
    ...	
    USE ( lcOPAPath) In 0 Exclusive Alias OutputA
    Select OutputA
    ...
Endif
To complicate matters the user can have any number of "Working Area Directories" (WADs), under which are database folders. I've got a test WAD set up C:\Temp6. The dev. system is in C:\MCL_Windows. Now to the code:
SYSOPTIONS.OPAFOLDER is set to "C:\", so we get to the first ELSE
So lcOPAFolder becomes "C:\"
So lcOPAPath becomes "C:\OutputA.dbf"
If not ( FILE( lcOPAPath)) fails, i.e. it says there is such a table, when there isn't!
So the new table doesn't get created according to the user WAD settings.
To add insult to injury, the line USE ( lcOPAPath) In 0 Exclusive Alias OutputA then goes and opens the file "C:\MCL_Windows\SerData\OutputA.dbf", which does exist. To my mind, that should have failed with an error message, as it was supposed to open a non-existent file "C:\OutputA.dbf".

So I have 2 main questions:
1. Why is FILE() tellling me "porky pies"?
2. How does that Use manage to open a table other than what it was told to?


For debug purposes I'm running the system from native VFP, from the default folder C:\MCL_Windows. The path is set up to the data root (at the moment - "MCL_windows") + "\SerData"... et al, so "mcl_windows\Serdata" IS in the path, but ... COME ON!

Anyone help?

TIA

Terry
- Whoever said that women are the weaker sex never tried to wrest the bedclothes off one in the middle of the night
- Worry is the interest you pay, in advance, for a loan that you may never need to take out.
Next
Reply
Map
View

Click here to load this message in the networking platform