Hi,
I've created a a custom dll in VFP 6.0 with procedures and everything, then I upgrade the program to VFP 7.0 but I find a bug and that is it's create the procedure as a method but it doesn't create the parametters. Here is the code just compile a single Dll. Any advice would be great.
Thanks for your support.
Define Class VFP_OLE_Server As Custom OlePublic
Procedure Init
*!* * The Procedure INIT is automatically
*!* * executed when the DLL is loaded.
CTALK = Set("Talk"
CSAFE = Set("Safe"
CEXCLUSIVE = Set("Exclusive"
CSAFETY = Set("SAFETY"
CCENTURY = Set("CENTURY"
Set Talk Off
Set Safe Off
Set Exclusive Off
Set Safety Off
Set Century On
Set Procedure To Sys(5) + "\TRAY\PROGRAMS\VFP1" Additive
*!* On Error Do Ole_Err With Error(),Lineno(),;
*!* Message(),Program()
On Error Do Ole_Err With Error(),Lineno(),;
Message(),Program()
Endproc
Procedure SetDir
Parameter cDir
Set Default To (m.cDir)
Endproc
Function ExeSql
Parameter cSql
Private nRecs,i,cFile,cFileSrc,cFullPath,;
cDestpath,IsVFPFile,;
cDbfFileName,nHandle
lIsVFPFile = .F.
cFullPath = Set('FullPath')
*
* Show Main VFP Window so File
* dialog box will be visible
* if VFP can't find a file that
* is needed for the SQL command.
*
Show Window Screen
*
*-- Execute SQL Statement --*
*
cSql = Alltrim(m.cSql)
&cSql
*
Hide Window Screen
*
nRecs = _Tally
*
Set Fullpath On
cFileSrc = Dbf()
Use
**************************************
*-- Check TableType.
*-- If Type Is Visual FoxPro Convert
*-- to Fox2x
**************************************
nHandle = Fopen(m.cFileSrc)
If nHandle <> -1
lIsVFPFile = (Fgets(m.nHandle,1)=Chr(48))
=Fclose(m.nHandle)
Endif
Use (m.cFileSrc) Exclusive
cDestpath = Left(Dbf(),Rat('\',Dbf()))
If m.lIsVFPFile
*-- Convert Result To Fox2x Format --*
cFile = 'T'+Right(Sys(3),7)
Copy To (m.cDestpath+m.cFile) Type Fox2x
Use
Erase (m.cFileSrc)
If File(Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Erase (Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Endif
Rename (m.cDestpath+m.cFile+'.DBF') ;
TO (m.cFileSrc)
If File(m.cDestpath+m.cFile+'.FPT')
Rename (m.cDestpath+m.cFile+'.FPT');
TO (Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Endif
Use (m.cFileSrc) Exclusive
Endif
*-- Restore FullPath Setting --*
Set Fullpath &cFullPath
**-- Return Result Record Count --**
Return (m.nRecs)
Endfunc
Procedure IndexOn
**-- Create Index Tags --*
Parameter cDBF,cKey,cTag,lDeleteTags
Use (m.cDBF) Exclusive In 0 Alias IndexDBF
Select IndexDBF
If m.lDeleteTags
Delete Tag All
Endif
Index On &cKey Tag &cTag
Use
Endproc
Procedure SetPath
Parameter cPath
Set Path To (m.cPath)
Endproc
Procedure FoxCommand
Parameter cCMD
&cCMD
Endproc
Function FoxFunction
Parameter cFunc
Private Rtn
Rtn = Eval(m.cFunc)
Return (m.Rtn)
Endfunc
Procedure Destroy
If CTALK
Set Talk On
Endif
If CSAFE
Set Safe On
Endif
If CEXCLUSIVE
Set Exclusive On
Endif
If CSAFETY
Set Safety On
Endif
Endproc
Procedure ADDFEEFIX
If Not Used('advrsary')
Use "\\Usbc_pr00\Apps\Courtapps\dbase3\bankdata\advrsary"
Endif
Sele advrsary
Set Filter To Empty(filfeepaid)
Repl filfeepaid With 'N' All
Use
Return(1)
Endproc
Procedure CopyFles
Parameters SrcPath, DstPath
Private FullCmd
FullCmd = ""
FullCmd = "xcopy " + SrcPath + " " + DstPath + " /E /C /Q /H /R /Y "
loWshShell = Createobject("WScript.Shell"
** xcopy is the program to run
** ls_fullname is the variable holding thr filename with fullpath
** ln_rtnval <> 0 means successful run
ln_rtnval=loWshShell.Run(FullCmd, 0, .T.)
Endproc
Procedure CALMAINT
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\CALENDAR\PROG40"
Do CALEINIT
Return(1)
Endproc
Procedure caresval
*Set path to SYS(5) & "\newreg"
Set Default To "\\Usbc_pr00\Apps\courtapps\NEWREG"
Use Setup
prefix = Substr(Str(Year(Date()+1),4),3,2)
If Month(Date()) = 12 And Day(Date())= 31
If Substr(casenum,1,2) <> prefix
Replace casenum With prefix+"-00000"
Replace Advnum With prefix+"-00000"
caso = prefix+"-00000"
?caso
Wait
Endif
Endif
Endproc
Procedure open_excl
On Error Store .T. To file_error
If m.again
Select &file_again
Use
Endif
Select &file_name
Use
Use &File In 0 Alias &Alias Exclusive
*!* * ON ERROR DO fatal WITH PROGRAM(),LINENO(),MESSAGE(),;
*!* MESSAGE(1), ERROR()
Endproc
Procedure open_reg
Use &File In 0 Alias &Alias
If m.again
Use &File In 0 Alias &file_again Again
Endif
Endproc
Procedure CALUAPPT
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\CALENDAR\PROG40"
Do CALUAPTT
Endproc
Procedure DBFMERGE
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\COURTCST"
Do DBFMERGE
Endproc
Procedure UST
Do UST
Endproc
Procedure AUTOPSC
*Parameters startdt, enddt
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\SYTOS\PACERFTP"
Do AUTOPSC With "%1", "%2"
Endproc
Enddefine
Procedure Ole_Err
**-- Handle DLL internal Errors --**
Parameter nErr,nLine,cMessage,cPRG
If (m.nErr=1707)
*-- CDX not present, OK to Retry --*
Retry
Else
Messagebox( m.cMessage+Chr(13)+Chr(13)+;
'Error# '+Str(m.nErr,5)+Chr(13)+;
'At Line#'+Str(m.nLine,5)+Chr(13)+;
'In '+m.cPRG+Chr(13)+Chr(13)+;
'See File:OLE_ERR.TXT for details.';
,16,'ERROR in VFP_OLE.DLL Module')
*
*-- Dump Memory and File Status To Text File.
*
Create Cursor OleError (ErrText M(10))
List Status Noconsole To File OLE_STAT.TMP
List Memory Like * Noconsole To File OLE_MEM.TMP
Append Blank
Replace ErrText With ;
Replicate('*',80)+Chr(13)+Chr(10)+;
DTOC(Date())+' '+Time()+;
Chr(13)+Chr(10)+;
PadC(' STATUS ',80,'*')+;
Chr(13)+Chr(10)
Append Memo ErrText From OLE_STAT.TMP
Replace ErrText With Chr(13)+Chr(10)+;
PadC(' MEMORY ',80,'*')+;
Chr(13)+Chr(10) AddI
Append Memo ErrText From OLE_MEM.TMP
Replace ErrText With Chr(13)+Chr(10)+;
PadC('-- End Error --',80,'*')+;
Chr(13)+Chr(10) AddI
If File('OLE_ERR.TXT')
Copy Memo ErrText To Ole_Err.TXT AddI
Else
Copy Memo ErrText To Ole_Err.TXT
Endif
Erase OLE_STAT.TMP
Erase OLE_MEM.TMP
*
Close Data
*-- Cancel causes Delphi or VB to raise an
*-- error.
Hide Window Screen
*-- The CANCEL command causes Delphi
*-- to be able to trap the error.
Cancel
Endif
Endproc
I've created a a custom dll in VFP 6.0 with procedures and everything, then I upgrade the program to VFP 7.0 but I find a bug and that is it's create the procedure as a method but it doesn't create the parametters. Here is the code just compile a single Dll. Any advice would be great.
Thanks for your support.
Define Class VFP_OLE_Server As Custom OlePublic
Procedure Init
*!* * The Procedure INIT is automatically
*!* * executed when the DLL is loaded.
CTALK = Set("Talk"
CSAFE = Set("Safe"
CEXCLUSIVE = Set("Exclusive"
CSAFETY = Set("SAFETY"
CCENTURY = Set("CENTURY"
Set Talk Off
Set Safe Off
Set Exclusive Off
Set Safety Off
Set Century On
Set Procedure To Sys(5) + "\TRAY\PROGRAMS\VFP1" Additive
*!* On Error Do Ole_Err With Error(),Lineno(),;
*!* Message(),Program()
On Error Do Ole_Err With Error(),Lineno(),;
Message(),Program()
Endproc
Procedure SetDir
Parameter cDir
Set Default To (m.cDir)
Endproc
Function ExeSql
Parameter cSql
Private nRecs,i,cFile,cFileSrc,cFullPath,;
cDestpath,IsVFPFile,;
cDbfFileName,nHandle
lIsVFPFile = .F.
cFullPath = Set('FullPath')
*
* Show Main VFP Window so File
* dialog box will be visible
* if VFP can't find a file that
* is needed for the SQL command.
*
Show Window Screen
*
*-- Execute SQL Statement --*
*
cSql = Alltrim(m.cSql)
&cSql
*
Hide Window Screen
*
nRecs = _Tally
*
Set Fullpath On
cFileSrc = Dbf()
Use
**************************************
*-- Check TableType.
*-- If Type Is Visual FoxPro Convert
*-- to Fox2x
**************************************
nHandle = Fopen(m.cFileSrc)
If nHandle <> -1
lIsVFPFile = (Fgets(m.nHandle,1)=Chr(48))
=Fclose(m.nHandle)
Endif
Use (m.cFileSrc) Exclusive
cDestpath = Left(Dbf(),Rat('\',Dbf()))
If m.lIsVFPFile
*-- Convert Result To Fox2x Format --*
cFile = 'T'+Right(Sys(3),7)
Copy To (m.cDestpath+m.cFile) Type Fox2x
Use
Erase (m.cFileSrc)
If File(Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Erase (Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Endif
Rename (m.cDestpath+m.cFile+'.DBF') ;
TO (m.cFileSrc)
If File(m.cDestpath+m.cFile+'.FPT')
Rename (m.cDestpath+m.cFile+'.FPT');
TO (Left(m.cFileSrc,;
Len(m.cFileSrc)-4)+'.FTP')
Endif
Use (m.cFileSrc) Exclusive
Endif
*-- Restore FullPath Setting --*
Set Fullpath &cFullPath
**-- Return Result Record Count --**
Return (m.nRecs)
Endfunc
Procedure IndexOn
**-- Create Index Tags --*
Parameter cDBF,cKey,cTag,lDeleteTags
Use (m.cDBF) Exclusive In 0 Alias IndexDBF
Select IndexDBF
If m.lDeleteTags
Delete Tag All
Endif
Index On &cKey Tag &cTag
Use
Endproc
Procedure SetPath
Parameter cPath
Set Path To (m.cPath)
Endproc
Procedure FoxCommand
Parameter cCMD
&cCMD
Endproc
Function FoxFunction
Parameter cFunc
Private Rtn
Rtn = Eval(m.cFunc)
Return (m.Rtn)
Endfunc
Procedure Destroy
If CTALK
Set Talk On
Endif
If CSAFE
Set Safe On
Endif
If CEXCLUSIVE
Set Exclusive On
Endif
If CSAFETY
Set Safety On
Endif
Endproc
Procedure ADDFEEFIX
If Not Used('advrsary')
Use "\\Usbc_pr00\Apps\Courtapps\dbase3\bankdata\advrsary"
Endif
Sele advrsary
Set Filter To Empty(filfeepaid)
Repl filfeepaid With 'N' All
Use
Return(1)
Endproc
Procedure CopyFles
Parameters SrcPath, DstPath
Private FullCmd
FullCmd = ""
FullCmd = "xcopy " + SrcPath + " " + DstPath + " /E /C /Q /H /R /Y "
loWshShell = Createobject("WScript.Shell"
** xcopy is the program to run
** ls_fullname is the variable holding thr filename with fullpath
** ln_rtnval <> 0 means successful run
ln_rtnval=loWshShell.Run(FullCmd, 0, .T.)
Endproc
Procedure CALMAINT
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\CALENDAR\PROG40"
Do CALEINIT
Return(1)
Endproc
Procedure caresval
*Set path to SYS(5) & "\newreg"
Set Default To "\\Usbc_pr00\Apps\courtapps\NEWREG"
Use Setup
prefix = Substr(Str(Year(Date()+1),4),3,2)
If Month(Date()) = 12 And Day(Date())= 31
If Substr(casenum,1,2) <> prefix
Replace casenum With prefix+"-00000"
Replace Advnum With prefix+"-00000"
caso = prefix+"-00000"
?caso
Wait
Endif
Endif
Endproc
Procedure open_excl
On Error Store .T. To file_error
If m.again
Select &file_again
Use
Endif
Select &file_name
Use
Use &File In 0 Alias &Alias Exclusive
*!* * ON ERROR DO fatal WITH PROGRAM(),LINENO(),MESSAGE(),;
*!* MESSAGE(1), ERROR()
Endproc
Procedure open_reg
Use &File In 0 Alias &Alias
If m.again
Use &File In 0 Alias &file_again Again
Endif
Endproc
Procedure CALUAPPT
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\CALENDAR\PROG40"
Do CALUAPTT
Endproc
Procedure DBFMERGE
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\COURTCST"
Do DBFMERGE
Endproc
Procedure UST
Do UST
Endproc
Procedure AUTOPSC
*Parameters startdt, enddt
Do SetDir1 With "\\Usbc_pr00\Apps\Courtapps\SYTOS\PACERFTP"
Do AUTOPSC With "%1", "%2"
Endproc
Enddefine
Procedure Ole_Err
**-- Handle DLL internal Errors --**
Parameter nErr,nLine,cMessage,cPRG
If (m.nErr=1707)
*-- CDX not present, OK to Retry --*
Retry
Else
Messagebox( m.cMessage+Chr(13)+Chr(13)+;
'Error# '+Str(m.nErr,5)+Chr(13)+;
'At Line#'+Str(m.nLine,5)+Chr(13)+;
'In '+m.cPRG+Chr(13)+Chr(13)+;
'See File:OLE_ERR.TXT for details.';
,16,'ERROR in VFP_OLE.DLL Module')
*
*-- Dump Memory and File Status To Text File.
*
Create Cursor OleError (ErrText M(10))
List Status Noconsole To File OLE_STAT.TMP
List Memory Like * Noconsole To File OLE_MEM.TMP
Append Blank
Replace ErrText With ;
Replicate('*',80)+Chr(13)+Chr(10)+;
DTOC(Date())+' '+Time()+;
Chr(13)+Chr(10)+;
PadC(' STATUS ',80,'*')+;
Chr(13)+Chr(10)
Append Memo ErrText From OLE_STAT.TMP
Replace ErrText With Chr(13)+Chr(10)+;
PadC(' MEMORY ',80,'*')+;
Chr(13)+Chr(10) AddI
Append Memo ErrText From OLE_MEM.TMP
Replace ErrText With Chr(13)+Chr(10)+;
PadC('-- End Error --',80,'*')+;
Chr(13)+Chr(10) AddI
If File('OLE_ERR.TXT')
Copy Memo ErrText To Ole_Err.TXT AddI
Else
Copy Memo ErrText To Ole_Err.TXT
Endif
Erase OLE_STAT.TMP
Erase OLE_MEM.TMP
*
Close Data
*-- Cancel causes Delphi or VB to raise an
*-- error.
Hide Window Screen
*-- The CANCEL command causes Delphi
*-- to be able to trap the error.
Cancel
Endif
Endproc