Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace a Forms Array with a Table ??
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01635886
Message ID:
01635894
Views:
53
>>
>>Normally you would use a form manager object that will use a collection of forms. Also _screen.forms already holds array of all opened forms.
>>
>>In any case, I don't think this is the most slow part, most likely it's how you're accessing it. E.g. it doesn't really matter if you would hold open forms in the table or an array. You can show some of your code and we can see, what exactly may be the slow part.
>
>Here is the code to SESSIONMGR.prg that creates the forms.
>
>
>* The first 5 paramaters are common to all forms
>* The other params vary based on which form is being called
>LPARAMETERS tcForm,tcClass,tnInstances,tcCaption,tlShowLater,txParam1,txParam2,txParam3,txParam4,txParam5,txParam6,txParam7,txParam8,txParam9,txParam10,txParam11
>
>* PATIENT SEARCH FORM
>	* txParam1 - Search Type (C): Identifies whether the form is being used
>	* for a regular patient search or an A/R add account patient search
>	
>* RX FORM - See frmRx for descriptions of these properties
>	* txParam1 -  (C): Fills in the property p_FullRx
>	* txParam2 -  (N): Fills in the property p_FormType
>	* txParam3 -  (L): Fills in the property p_RxVbl
>	* txParma4 -  (L): Fills in the property p_NoReverseEdit
>	* txParam5 -  (L): Fills in the property p_ChargeAR
>	* txParam6 -  (C): Fills in the property p_sstxctrl
>	* txParam7 -  (L): Fills in the property p_FilledFromCheckRefill
>	* txParam8 -  (L): Fills in the property p_FilledFromQueue
>	* txParam9 -  (C): Fills in the property p_ssicr		(SS 10.6 new parameter - Initiator Control Reference value)
>	* txParam10 - (L): Fills in the property p_RefillDrugOverRide - for the Hydrocodone change for 10/6/2014 - all 3's become 2's except for Refills
>	
>LOCAL lnCnt,lcTemp
>
>*!* CSH  20121001	Spanish Conversion
>tcCaption = translatewrd(tcCaption)
>*!* CSH  20121001		
>
>IF tnInstances = -1	&& Use Max Avail
>	tnInstances = gnMaxSessions
>ENDIF
>
>lnCnt = 1
>
>DO WHILE lnCnt <= ALEN(gaSession)
>	IF TYPE("gaSession[lnCnt]") != "O"
>		IF ALLTRIM(UPPER(tcForm)) = "FRMPATIENTSEARCH"
>			IF ALLTRIM(UPPER(txParam1)) = "AR PATIENT SEARCH"
>				goPharmApp.m_append(tcForm,tcClass,tnInstances,.F.,.F.)
>				EXIT
>			ELSE
>				gaSession[lnCnt] = goPharmApp.m_append(tcForm,tcClass,tnInstances,.F.,.T.) 
>			ENDIF
>		ELSE
>			IF tlShowLater
>   				gaSession[lnCnt] = goPharmApp.m_append(tcForm,tcClass,tnInstances,.T.)
>   			ELSE
>   				gaSession[lnCnt] = goPharmApp.m_append(tcForm,tcClass,tnInstances,.F.)
>   			ENDIF
>   		ENDIF
>   		IF TYPE("gaSession[lnCnt]") = "O"
>   			gaSession[lnCnt].p_Session = lnCnt
>   			lcTemp = "cmd" + ALLTRIM(STR(lnCnt))
>   			goTbrSideBar.p_Session = lnCnt
>   			goTbrSideBar.AddObject(lcTemp,"cmdSideBar")
>   			goTbrSideBar.m_AdjButtonHeights()
>
>   			* 11-20-02 STB added a check for tlShowLater = .F. so when doing
>   			* multi refills off profile, the correct rx is highlight on sidebar
>   			IF !tlShowLater
>   				goTbrSideBar.m_HighlightButton(lnCnt)
>   			ENDIF
>   			* 02-14-05 STB moved ChangeCaption above the IF statement
>   			* so any changes to the caption made by the form will stick
>   			goTbrSideBar.m_ChangeCaption(lnCnt,tcCaption)
>   			IF ALLTRIM(UPPER(tcForm)) = "FRMRX"   				
>   				gaSession[lnCnt].p_FullRx = txParam1
>   				gaSession[lnCnt].p_FormType = txParam2
>				gaSession[lnCnt].p_NoReverseEdit = txParam4
>				gaSession[lnCnt].p_ChargeAR = txParam5
>				gaSession[lnCnt].p_SSTxCtrl = txParam6
>
>				*TMT 11/07/06 Added p_FilledFromCheckRefill to let FrmRx know when we have selected a Therapeutically
>				*Equivalent Rx to substitute for a Rx that does not have any Refills left.
> 				gaSession[lnCnt].p_FilledFromCheckRefill = txParam7
>
> 				*TMT 08/26/2011 Added p_FilledFromQueue to let FrmRx know if this Rx was being processed from the directly from the Queue
> 				*If nothing passeed to paramater txParam8, then it will default to .F., which is what we want
>				gaSession[lnCnt].p_FilledFromQueue = txParam8
> 
>				*TMT 05/08/13 Added p_icr for SureScripts 10.6 new parameter to passed from NEWRX or REFRES to any new REFREQ.
>				gaSession[lnCnt].p_ssicr = txParam9
> 				*If nothing passeed to paramater txParam9, then it will default to .F., which is what we want
>
>				*TMT 11/11/2014 Added p_RefillDrugOverRide - for the Hydrocodone change for 10/6/2014 - all 3's become 2's except for Refills			
>				gaSession[lnCnt].p_RefillDrugOverRide = txParam10
>				*TMT
>
>				* JBH 9/9/15 134496
>				gaSession[lnCnt].p_editmode = txParam11
>
>   				IF TYPE("txParam3") = "L"
>   					gaSession[lnCnt].p_RxVbl = txParam3
>   					gaSession[lnCnt].show
>   				ENDIF
>   			ENDIF
>   			goTbrSideBar.setall("visible",.T.)
>   		ENDIF
>   		EXIT
>   	ENDIF
>   	lnCnt = lnCnt + 1
>ENDDO
>IF lnCnt > ALEN(gaSession)
>	MESSAGEBOX(translatewrd("You have reached the limit of the total number") + CHR(13) +;
>		translatewrd("of sessions that can be open at once."),64,translatewrd("Cannot Open Another Session"))
>	RETURN .F.
>ELSE
>	RETURN gaSession[lnCnt]
>ENDIF
>
>gaSession = .NULL.
>
>
>So, would using a Table instead of gasession be an improvement? And how would you implement it here......I was starting to make code changes when it dawned on me that I could not use a ROW of the table for the same thing that an ELEMENT of the array gasession did.... which was BE a form.
>
>By the way, goPharmApp.m_append creates a form and returns a pointer to the object.
>
>Tommy

This is a long and confusing code. I suggest to use vartype function instead of type where applicable and do other minor improvements as well. Setting gaSession to null at the end should be removed (this line of code is never executed anyway).

In my opinion using table to hold the forms is not going to change the performance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform