Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

strange error

Status
Not open for further replies.

mjcmkrsr

Technical User
Nov 30, 2010
840
Hi,

I have several PCs (W7 pro - 32 bit, W8 - 64 bit, W10 - 64bit). VFP9 with all the SPs and hotfixes is installed on the W7-PC. The run time files are installed on the other PCs. The data reside in a shared folder of a NAS, mapped as S:\. All the PCs access the date on S:\ through a GB Ethernet.

The following code is running well on all PCs, whether as PRG, APP or EXE with one exception: it throws an error (after FCLOSE) when run as EXE on the W7 machine where VFP9 is installed

Code:
Local ldBoMonth, ldEoMonth, lnFileHandle

ldBoMonth = oApp.dEofMonth(ThisForm.txtDEntry.Value) + 1
ldEoMonth = oApp.dEofMonth(ldBoMonth)

Select ;
		Houses.HCode AS "HouseCode", ;
		Houses.Name AS "HouseName", ;
		Houses.Room, ;
		Stagiaires.cName AS "STName", ;
		Stagiaires.cGender AS "Gender", ;
		TRANSFORM(Stagiaires.dBirth) AS "dBirth", ;
		TRANSFORM(Students.Rent ,"999.99") AS "Rent", ;
		TRANSFORM(Students.dEntry) AS "dEntry", ;
		TRANSFORM(Students.dExit) AS "dExit", ;
		TRANSFORM(Students.Pfa, "999.99") as "PFA" ;
		From Houses ;
			Join Students On Houses.PKey = Students.FKey ;
			Join Stagiaires On Stagiaires.PKey = Students.PKey ;
		Where Between(Students.dEntry, ldBoMonth, ldEoMonth) AND ;
			Students.PFA > 0 ;
		Order by HouseCode ;
		Into Cursor WfSTemp

IF _Tally > 0
	lnFileHandle = FOPEN(gcDrive + gcPath + "FullContracts.CSV", 12)
	= FCLOSE(lnFileHandle)

	IF lnFileHandle > 0
		COPY TO gcDrive + gcPath + "FullContracts" TYPE CSV
	
	ELSE
		= MESSAGEBOX("Le fichier "+ gcDrive + gcPath +"FullContracts est ouvert!", 64, "Création fichiers Word")
	
	
	ENDIF
ENDIF


	Select ;
		Houses.HCode AS "HouseCode", ;
		Houses.Name AS "HouseName", ;
		Houses.Room, ;
		Stagiaires.cName AS "STName", ;
		Stagiaires.cGender AS "Gender", ;
		TRANSFORM(Stagiaires.dBirth) AS "dBirth", ;
		TRANSFORM(Students.Rent ,"999.99") AS "Rent", ;
		TRANSFORM(Students.dEntry) AS "dEntry", ;
		TRANSFORM(Students.dExit) AS "dExit";
		From Houses ;
			Join Students On Houses.PKey = Students.FKey ;
			Join Stagiaires On Stagiaires.PKey = Students.PKey ;
		Where Between(Students.dEntry, ldBoMonth, ldEoMonth) AND ;
			Students.PFA = 0 ;
		Order by HouseCode ;
		Into Cursor WfSTemp

IF _Tally > 0
	lnFileHandle = FOPEN(gcDrive + gcPath + "ExtendedContracts.CSV",12)
	= FCLOSE(lnFileHandle)
	
	IF lnFileHandle > 0
		COPY TO gcDrive + gcPath + "ExtendedContracts" TYPE CSV
	
	ELSE
		= MESSAGEBOX("Le fichier "+ gcDrive + gcPath +"ExtendedContracts est ouvert!", 64, "Création fichiers Word")
	
	
	ENDIF
ENDIF

ERROR

Error_vbdmsy.png


This does not seem to be a VFP9 error and what strikes me more is that the message is in french - VFP is English, my Windows are English. Clicking on "Aide" doesn't do anything
My question: are there additional files incorporated in the EXE - as opposed to the APP - where this error might come from.

Any hint is appreciated

Thanks

MarcK
 
The message is indeed a VFP error: it is error 108. And the captions on the buttons are consistent with the captions you see in a standard error dialogue. The fact that it is in French suggests that you have accidentally or otherwise installed the French resource file in your application.

Look for a file with a name that is something like VFP9FRA.DLL. I stress "something like" because I am not sure of the exact name, but it will be a DLL and will have some indication that it is French ("FRA" perhaps?).

These files contain translations of the strings used in messages and dialogues built into VFP. If you remove the file from your build, the messages should revert to English.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
The start link or batchfile likely will load the french resource DLL, and yes, it's exactly called that.

On the error itself, you're stepping on your own foot, if you first want to ensure you can create the file gcDrive + gcPath + "FullContracts.CSV" by opening it in exclusive readwrite mode. The OS will return from FCLOSE before the file handle is really invalidated and the file closed, therefore the following COPY TO fails on the file a) existing and b) still - just - being in exclusive mode.

The simplest way to get the COPY TO working always is adding SYS(2015) to the name. If you want that specific file name, just check whether it's gone after you ERASE it:

Code:
ERASE (gcDrive + gcPath + "FullContracts.CSV")

IF ADIR(laDummy, gcDrive + gcPath + "FullContracts.CSV")= 0
		COPY TO gcDrive + gcPath + "FullContracts" TYPE CSV
ELSE
   ...
   = MESSAGEBOX("Le fichier "+ gcDrive + gcPath +"FullContracts est ouvert!", 64, "Création fichiers Word")
ENMDIF

If ERASE does not succeed it won't throw an error (just like FCLOSE() with a negative file handle also doesn't throw an error). If it succeeds, the file will also be deleted after it executed, and ADIR won't find it (you can also use NOT FILE(gcDrive + gcPath + "FullContracts.CSV") when you're sure such a CSV won't be found compiled into the EXE itself).

This has become known as PACK started to fail on Win7 in corner cases. Something changed in the file system about handling file handles, I guess.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Hi Olaf and Mike,

Thanks for the hints. I changed the code snippet as below - now it works.

Code:
IF _Tally > 0
	lnFileHandle = FOPEN(gcDrive + gcPath + "FullContracts.CSV", 12)

	IF lnFileHandle > 0 AND FCLOSE(lnFileHandle)
		DELETE File gcDrive + gcPath + "FullContracts.CSV" 
		COPY TO gcDrive + gcPath + "FullContracts" TYPE CSV
		= MESSAGEBOX("Le fichier "+ gcDrive + gcPath +"FullContracts est créé!", 64, "Création fichiers Word", 2000)
		
	
	ELSE
		= MESSAGEBOX("Le fichier "+ gcDrive + gcPath +"FullContracts est ouvert!", 16, "Création fichiers Word")
	
	
	ENDIF

ENDIF

MarcK
 
Glad to hear it is working, MarcK. You've got rid of the error, but that doesn't explain why the message was in French. On the other hand, I assume that that was not the problem, given that your program-generated messages are in French.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike,

I found VFP9FRA.DLL in C:\Program Files\Common Files\Microsoft Shared\VFP\ but not in C:\Program Files\Microsoft Visual FoxPro 9\ - I renamed it and checked again. The error message then was in English. I guess that VFP9 also loads this ...FRA file considering that under Start - Control Panel - Region and Language - Formats the Format is French(Luxembourg).

Thanks for the hint.

MarcK
 
Yes, today there are less and less single language Windows versions. I guess you only get Win10 with international MUI language packs and then this regional setting will determine what resource DLL VFP will use by default. C:\Program Files\Common Files\Microsoft Shared\VFP\ is both the default folder of resource DLLs and some more where you install VFP and also where you install the VFP runtimes with the Prolib runtime installer, for example. Or with merge modules coming with Installshield Express edition for VFP9.

It was already clear this DLL has to be the source of this error message as Mike found it is a native error message. The Aide button would work if help would be set to the VFP9 chm help file, which it will usually not when you are executing your own built EXE, but within the IDE. It's also a sign this isn't the Messagebox() function, it doesn't allow you to define custom buttons and the only buttons and button combination it does are documented, typically OK or YES/NO or CANCEL/OK, etc.

You don't need to delete that. It's okay, at least also french, as users are used to that interface language. If you want to establish your own error message and handling, establish an error handler, see ON ERROR.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top