Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Beginner question !!
Message
General information
Forum:
Visual FoxPro
Category:
The Mere Mortals Framework
Miscellaneous
Thread ID:
00124070
Message ID:
00124408
Views:
26
>Hi !
>This CBMM framework is really wonderful... Just a question : I have 2 FLL libraries and some others classes I have done to add in my current development... Where do I have to put my calls (SET LIBRARY...) in the Application class ? Do I need to create a new property in App class ? (I don't know if it's clear enough...)
>
>Thanks !
>
>Gilles

Gilles,

I suggest you create a wrapper class around your FLL libraries as described by Menachem in the Codebook where he makes a wrapper around foxtools.

Here is an abbreviated version version of what I did for one DLL.

**************************************************
*-- Class: cdpid32 (c:\cdbk30\autosoft\libs\autils.vcx)
*-- ParentClass: ccustom (c:\cdbk30\common30\libs\ccontrls.vcx)
*-- BaseClass: custom
*-- A wrapper class around DPID32.DLL
*
#INCLUDE "c:\cdbk30\common30\include\framincl.h"
*
DEFINE CLASS cdpid32 AS ccustom

*-- le Handle de la société ouverte: si 0, failed.
nhandle = 0
Name = "cdpid32"

*-- Specifies if the DPID32.DLL library is loaded
lloaded = .F.

*-- Flag to track if RETRY fails in the error event method. Prevents event recursion.
PROTECTED lerror

*-- Specifies the fully qualified filename of DPID32.DLL
PROTECTED clibrary

*-- Loads the DPID32.DLL library
PROCEDURE loadlib
LOCAL lcLibrary, ;
lcDir

IF ! "DPID32" $ SET("library")
lcLibrary = ""
IF FILE (ADDBS(GETENV("WINDIR")) + "DPID32.DLL")
lcLibrary = ADDBS(GETENV("WINDIR")) + "DPID32.DLL"
ELSE
lcDir = SYS(16,1) && EXE name
lcDir = LEFT(lcDir, RAT("\", lcDir))
IF FILE (lcDir + "DPID32.DLL")
lcLibrary = lcDir + "DPIDI32.DLL"
ENDIF
ENDIF

IF ! EMPTY(lcLibrary)
*-- SET LIBRARY TO (lcLibrary) ADDITIVE is not required with a DLL
*-- DECLARE DLL is the method to use in VFP
this.cLibrary = lcLibrary
this.lLoaded = .T.
this.lError = .F.
this.DeclareDll()
ELSE
ErrorMsg(NODPID32_LOC)
ENDIF
ELSE
this.lLoaded = .T.
ENDIF

RETURN this.lLoaded
ENDPROC


*-- Holds our the Declare DLL statements
PROTECTED PROCEDURE declaredll
************************************************************
* DPIOpenSociete()
************************************************************
* Author............: José Constant
* Project...........: DPI
* Created...........: 06/04/97 12:10:20
* Copyright.........: (c) CSS jose@club.innet.be, 1997
*) Description.......: ouvre une société
* Calling Samples...: nHandle = DPIOpenSociete("JCM", "LIPEZB", "CSS" )
* Parameter List....: cUserName nom de l'utilisateur (Utilisat.Util C(20))
* : cPassWord mot de passe de l'utlisateur (Utilisat.mPass C(6))
* : cSocName nom de la société à ouvrir (societes.Rais C(40))
* Returns : nHandle, an Integer ou 0 en cas d'erreur
* : pour plus de détails, appeler DPIGetLastError()
* Major change list.:

DECLARE ;
INTEGER DPIOpenSociete ;
in DPID32 ;
STRING @cUserName, ;
STRING @cPassword, ;
STRING @cSocName

*-- some other Declare statements removed for clarity.

*-- Wrapper Class around DPIOpenSociete()
PROCEDURE dpiopensociete
************************************************************
* DPIOpenSociete()
************************************************************
* Method............: CDPID32.DPIOPENSOCIETE
* Author............: José Constant
* Project...........: DPI
* Created...........: 1/05/97 15:04:20
* Copyright.........: (c) CSS jose@club.innet.be, 1997
*) Description.......: Wrapper class around DPIOpenSociete in DPID32.DLL
* Calling Samples...: GoApp.oDPId32.OpenSociete()
* Parameter List....: None
* Major change list.:

LOCAL lcComptaFullPath, ;
lcComptaRelativePath, ;
lcComptaRootPath, ;
lcEmployeeId, ;
lnOldSel, ;
lcPassword, ;
lcUtilisat, ;
lcUserName, ;
lcSocietes, ;
lcSocName

lcComptaFullPath = ""
lccomptaRelativePath = ""
lcComptaRootPath= ""
lcEmployeeId = ""
lnOldSel = 0
lcPassword = ""
lcUtilisat = ""
lcUserName = ""
lcSocietes = ""
lcSocName = ""

*-- let us feed our parameters
lcComptaFullPath = ALLTRIM(GoApp.GetSetting(COMPTADIR_KEY, APPCLASS))
*-- par exemple "C:\SAARI\CSS\"
lcComptaRelativePath = SUBSTR(lcComptaFullPath, RAT("\", lcComptaFullPath, 2)+1)
*-- par exemple "CSS\"
lcComptaRelativePath = SUBSTR(lcComptaRelativePath, 1, LEN(lcComptaRelativePath)-1)
*-- par exemple "CSS"
lcComptaRootPath = SUBSTR(lcComptaFullPath, 1, LEN (lcComptaFullPath) - LEN(lcComptaRelativePath) -1)
*-- par exemple "C:\SAARI\"

lcEmployeeId = GoApp.GetEmployeeID()
lnOldSel = SELECT()

USE Employee IN 0
SELECT Employee
*-- the only possiblity to have an empty(lcEmployeeId) is while in DEBUG mode
*-- our convention is that the cid of the developper is SPACE(5)+"1"
IF EMPTY (lcEmployeeId)
lcPassword = ALLTRIM(UPPER(LOOKUP (cPassword, SPACE(5)+"1", cid, "Primary")))
ELSE
lcPassword = ALLTRIM(UPPER(LOOKUP (cPassword, lcEmployeeId, cid, "Primary")))
ENDIF
USE IN Employee

*-- sauter dans le root de Saari, et ouvrir UTILISAT pour trouver le nom de l'utilisateur
*-- ouvrir societes, pour avec le path, trouver la raison sociale

lcUtilisat = lcComptaRootPath + "UTILISAT"
USE (lcUtilisat) IN 0 ALIAS UTILISAT
SELECT UTILISAT
*-- je ne sais pas utiliser l'index
lcUserName = ALLTRIM(LOOKUP( Util, lcPassword, mPass))
USE IN UTILISAT

lcSocietes = lcComptaRootPath + "SOCIETES"
USE (lcSocietes) IN 0 ALIAS SOCIETES
SELECT SOCIETES
*-- je ne sais pas utiliser l'index
lcSocName = ALLTRIM(LOOKUP( Rais, lcComptaRelativePath, Path))
USE IN SOCIETES
SELECT (lnOldSel)

this.nHandle = (DPIOpenSociete(lcUserName, lcPassword, lcSocName))

IF this.nHandle = 0
ERRORMSG(DPIOPENSOCIETEERR_LOC)
ENDIF
ENDPROC

*-- several custom methods cut for clarity

PROCEDURE Error
LPARAMETERS nError, cMethod, nLine
LOCAL lcMessage

DO CASE
CASE nError = 1 && File not found, because the library is not loaded
this.lError = .T.

this.loadLib()

IF ! this.lError
RETRY
ELSE
Error nError
ENDIF

OTHERWISE
??CHR(7)
lcMessage = "Une erreur est survenue:" + CR + ;
"Erreur Numéro: " + PADR(nError, 25) + CR + ;
" Méthode: " + PADR(UPPER(cMethod), 25) + CR + ;
" Ligne Numéro: " + PADR(nLine, 25)

=MESSAGEBOX(lcMessage, MB_ICONEXCLAMATION, "Erreur cDpid32")
ENDCASE
ENDPROC


PROCEDURE Destroy
IF this.lLoaded AND this.nHandle # 0
this.DPICloseSociete()
ENDIF
ENDPROC


PROCEDURE Init
this.lLoaded = .F.
RETURN this.loadLib()
ENDPROC


PROCEDURE copyright
*---------------------- Location Section ----------------------
* Library...........:
* Class.............: Cdpid32
* Method............:
*-------------------------- Copyright -------------------------
* Author............: José Constant
* Project...........: DPI
* Created...........: 17/04/97 18:32:45
* Copyright.........: (c) CSS jose@club.innet.be , 1997
*----------------------- Usage Section ------------------------
*) Description.......:
* Scope.............:
* Parameters........:
*$ Usage.............:
*% Example...........:
* Returns...........:
*------------------- Maintenance Section ----------------------
*@ Inputs:...........:
* Outputs...........:
* Pre-condt. invar..: 1) Development mode: DLL dans C:\WINDOWS
* : Production mode: DLL dans le répertoire de l'EXE
* : Si la DLL n'est pas trouvée, l'INIT retournera .F.
* : et l'application s'arrêtera proprement.
* : 2) DLL va lire dans le WIN.INI pour trouver le path de la compta
* : 3) le contrôle de version se fait sur le fichier SOCIETES.DBF
* : cette version du DPI exige societes.Codep C(10)
* : 4) le UPPER(mot de passe utilisateur) dans Autosoft doit être identique
* : au mot de passe de la compta
* : 5) les préférences utilisateur (Compta) doivent être correctes
* :
* Post-condt.invar..:
*? Notes.............: Might be included within other projects under the following cond.
* : ! check include in appIncl: NODPID32_LOC
* : ! Lib includes FRAMINCL.H
* : ! Init has a hard coded path to DPIDP32.H
* : See Autosoft.LoadChildren() that does the necessary declare for us
* Collab.methods....: None
*--Process...........:
* Change log........:
*--------------------------------------------------------------
ENDPROC


ENDDEFINE
*
*-- EndDefine: cdpid32
**************************************************
Previous
Reply
Map
View

Click here to load this message in the networking platform