Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Tables closing unexpectatnly
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Tables closing unexpectatnly
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01635656
Message ID:
01635656
Vues:
77
Hi Gang!

Just need some suggestions as to where to look.

We have a LARGE application, written VFP 9.0 SP1, that until recently behaved ok. Since the last update, the users are reporting daily errors, which we capture in a table to examine.

The errors are occurring in 1 form, and this form has a PRIVATE DATA session

The errors, that are new errors, are predominantly of the kind where the tables are not being used or open, when normally they were.

I checked in the code for any

USE

by itself and maybe closing a table by accident.

Also looked for things like USE footable without a SELECT 0 before it, or IN 0 in it.

I also added a new method (base on ideas given to me from here, on the UT). The routine was to enable a DUPLEX capable printer to actually print in DUPLEX for reports and monographs printed out during prescriptions as they are being filled. Here is the code for DUPLEXING.... ( the idea here is that the report forms are IN the executable, so I have to copy the structure of the report form to my TEMP folder, there rename it to be a report again, modify one of the fields that holds the DUPLEX information, save it and then use this modified report to print the report information.)
LPARAMETERS tcReportName, tlDuplexOn, tcTempNumber

*TMT 12/01/2015 Add duplexing to the report
*****************************************************************************************************************************************************************************************

LOCAL lcReportName, laExpr, lnLen, ln, lcExpr, llFoundDuplex, lcOrientation, llOrientation
LOCAL lcTempReportName
LOCAL lcAliasName

lcAliasName = ''

*TMT 2016/04/14 Save the table name we are selected to, so we can reset to this when we exit this routine...
LOCAL lcInitialTable
lcInitialTable = ALIAS()
*TMT

DIMENSION laExpr[1]
llFoundDuplex = .F.
llOrientation = .F.

lcReportName = ALLTRIM(tcReportName)
lcTempReportName = gcpVistemp + '\' + "_" + lcReportName + tcTempNumber

*TMT 12/03/2015 Close the temporary table used for the output data if it is already open... 
*sometimes these temporary tables are named the same as the name of the report, which can cause problems
*below when we are creating the temp report table which may be the same name.... can't have the two
*tables open at the same time with the same name.....
IF USED(lcReportName)
	USE IN SELECT(lcReportname)
ENDIF 

*TMT 12/02/2015 Delete the temporary cursor table _DailyLog
DELETE FILE (lcTempReportName + '.*')

*-- TMT 12/02/2015 Since we don't send the REPORTS folder with the Reports to the customer, and the reports are stored in the EXE as cursors, I will need to copy the cursor FRX to the
*-- Temp folder and modify the copy.  I will use the copy to print from, then delete it when finished.
*--
* First, copy the cursor to the temp folder....
USE (lcReportName + '.frx') IN 0
SELECT (lcReportName)
*COPY STRUCTURE TO (lcTempReportName) 
*USE (lcTempReportName)
* Now copy the FRX data to the new copied table structure
*APPEND FROM lcReportName
COPY TO (lcTempReportName)
USE IN SELECT(lcTempReportName)
USE IN SELECT(lcReportName)

RENAME (lcTempReportName + '.DBF') TO  (lcTempReportName + '.FRX')
RENAME (lcTempReportName + '.FPT') TO  (lcTempReportName + '.FRT')

*TMT 04/28/2016 Add an extension to duplexreport
lcAliasName = 'duplexreport' + SYS(2015)

*TMT 2016/04/14 Assign an alias name so we can easily refer to it later
*TMT 04/28/2016 Use new duplexreport name
*USE (lcTempReportName + '.FRX') IN 0 ALIAS duplexreport
USE (lcTempReportName + '.FRX') IN 0 ALIAS (lcAliasName)

*TMT 04/28/2016 Select the alias table
SELECT (lcAliasName)

*-- Put EXPR in an array
GOTO TOP
lnLen = ALINES(laExpr, expr)

*-- Find the Orientation of the page - this will determine how we wish to duplex the pages - Portrait orientation will need the Vertical Duplex - 2
*-- Landscape Orientation requires the Horizontal Duplex - 3
FOR ln = 1 TO lnLen
	IF LEFT(laExpr[ln], 12) = 'ORIENTATION='
		lcOrientation = SUBSTR(laExpr[ln],13,2)		&& if duplex_reports is TRUE, then send 2 to printer in the report for duplex, else send 1 for simplex
		EXIT
	ENDIF
ENDFOR

*-- Find the DUPLEX= line and change it
FOR ln = 1 TO lnLen
	IF LEFT(laExpr[ln], 7) = 'DUPLEX='
		llFoundDuplex = .T.
		DO CASE 
			CASE tlDuplexOn = .F.	&& Turn off the duplexing
				laExpr[ln] = LEFT(laExpr[ln], 7) + '1'
			CASE ALLTRIM(lcOrientation) = '0'				&& Portrait - make the Orientation to be Vertical Duplex
*				laExpr[ln] = LEFT(laExpr[ln], 7) + '3'		&& Send 2 to printer in the report for Vertical duplex
				laExpr[ln] = LEFT(laExpr[ln], 7) + '2'		&& Send 2 to printer in the report for Vertical duplex
			CASE ALLTRIM(lcOrientation) = '1'				&& Lanscape - make the Orientation to be Horizontal Duplex
				laExpr[ln] = LEFT(laExpr[ln], 7) + '2'		&& Send 3 to printer in the report for Horizontal duplex
			OTHERWISE
*				laExpr[ln] = LEFT(laExpr[ln], 7) + '3'		&& Send 2 to printer in the report for Vertical duplex
				laExpr[ln] = LEFT(laExpr[ln], 7) + '2'		&& Send 2 to printer in the report for Vertical duplex
		ENDCASE 
		EXIT
	ENDIF
ENDFOR
IF NOT llFoundDuplex AND tlDuplexOn
	lnLen = lnLen + 1
	DIMENSION laExpr(lnLen)
	DO CASE 
		CASE ALLTRIM(lcOrientation) = '0'	&& Portrait - make the Orientation to be Vertical Duplex
*			laExpr(lnLen) = 'DUPLEX=3'
			laExpr(lnLen) = 'DUPLEX=2'
		CASE ALLTRIM(lcOrientation) = '1'	&& Lanscape - make the Orientation to be Horizontal Duplex
			laExpr(lnLen) = 'DUPLEX=2'
		OTHERWISE
*			laExpr(lnLen) = 'DUPLEX=3'
			laExpr(lnLen) = 'DUPLEX=2'
	ENDCASE 
ENDIF 

*-- Convert the array back to a string and save it in EXPR
lcExpr = ''  
FOR ln = 1 TO lnLen
	lcExpr = lcExpr + laExpr[ln] + CHR(13)
ENDFOR

*TMT 2016/04/14 Fix problem of the USE not looking at the lcTempReportName table because of timers firing....
*REPLACE expr WITH lcExpr 							&& IN (lcTempReportName)
*TMT 04/28/2016 Select the alias report
*REPLACE expr WITH lcExpr	IN duplexreport			&& IN (lcTempReportName)
REPLACE expr WITH lcExpr	IN (lcAliasName)			&& IN (lcTempReportName)
*TMT

 *-- Close the table
*TMT 2016/04/14 Fix problem of the USE not looking at the lcTempReportName table because of timers firing....
*USE 
*TMT 04/28/2016 Close the duplexreport
*USE IN SELECT('duplexreport')
USE IN SELECT(lcAliasname)
*TMT

*TMT 2016/04/14 now have the routine select the initial table we were looking at when we started the routine, in case a timer has us looking elsewhere...
IF NOT EMPTY(lcInitialTable)
	SELECT &lcInitialTable
ENDIF 
RETURN 
Any other things like this to look for, for accidentally closing a table when it should still be open?
Tommy Tillman A+ NetWork+ MCP
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform