DBF Index Files and Dialect Core
- gianluca.pinoli
- Posts: 36
- Joined: Mon Nov 02, 2015 1:13 pm
- Location: Italy
DBF Index Files and Dialect Core
Hi All,
I'm testing Vulcan DBF RDD trying using it in a WinForm Application.
I've created a simple test class in a DLL x86 only Dialect Vulcan (VulcanTest.dll):
If i use it from a Dialect Vulcan (both console and winform) application (x86) work fine, but in a Dialect Core application (x86) it's seem impossible open the index file (DBF file opens and is readable)
Reference:
VulcanRT
VulcanRTFuncs
VulcanVORDDClasses
VulcanVOSystemClasses
Anyone have a suggestion?
Regards
Gianluca
**********************************************************************************************************************
PRIVATE METHOD button1_Click(sender AS OBJECT, e AS System.EventArgs) AS VOID STRICT
local oClass AS ClassDBF
local sRet as string
oClass := ClassDBF{}
sRet :=oClass:GetDescrizione("0001009")
Messagebox.Show( sRet )
return
**********************************************************************************************************************
*********************************************************************************************
// ClassDBF.prg
// Created by : Gianluca
// Creation Date : 8/31/2018 3:19:01 PM
// Created for :
// WorkStation : NB-GIANLUCA
USING System
USING System.Collections.Generic
USING System.Text
BEGIN NAMESPACE VulcanTest
/// <summary>
/// The ClassDBF class.
/// </summary>
CLASS ClassDBF
CONSTRUCTOR()
RETURN
method GetDescrizione(sCodice as string) as STRING
local sRet := "" as string
LOCAL oDB as DBServer
local oFSIndex as FileSpec
oDB := DBServer{"C:GDOSHOPARCHIVI9ARTICOK.DBF",FALSE,TRUE,"DBFCDX"}
oFSIndex := FileSpec{ "ARTICOK.CDX" }
oFSIndex:Path := "C:GDOSHOPARCHIVI9"
if !oFSIndex:Find()
oDB:Close()
Return "File Indice non trovato"
endif
if !oDB:SetIndex(oFSIndex)
oDB:Close()
Return "Indice non Applicato"
endif
oDB:GoTop()
if !oDB:Seek("0001009")
oDB:Close()
Return "Articolo non trovato"
endif
sRet := (STRING)oDB:FIELDGET("CODICE") + " "+ (STRING)oDB:FIELDGET("DESCRIZIO")
oDB:Close()
return sRet
END CLASS
END NAMESPACE // VulcanTest
*********************************************************************************************
I'm testing Vulcan DBF RDD trying using it in a WinForm Application.
I've created a simple test class in a DLL x86 only Dialect Vulcan (VulcanTest.dll):
If i use it from a Dialect Vulcan (both console and winform) application (x86) work fine, but in a Dialect Core application (x86) it's seem impossible open the index file (DBF file opens and is readable)
Reference:
VulcanRT
VulcanRTFuncs
VulcanVORDDClasses
VulcanVOSystemClasses
Anyone have a suggestion?
Regards
Gianluca
**********************************************************************************************************************
PRIVATE METHOD button1_Click(sender AS OBJECT, e AS System.EventArgs) AS VOID STRICT
local oClass AS ClassDBF
local sRet as string
oClass := ClassDBF{}
sRet :=oClass:GetDescrizione("0001009")
Messagebox.Show( sRet )
return
**********************************************************************************************************************
*********************************************************************************************
// ClassDBF.prg
// Created by : Gianluca
// Creation Date : 8/31/2018 3:19:01 PM
// Created for :
// WorkStation : NB-GIANLUCA
USING System
USING System.Collections.Generic
USING System.Text
BEGIN NAMESPACE VulcanTest
/// <summary>
/// The ClassDBF class.
/// </summary>
CLASS ClassDBF
CONSTRUCTOR()
RETURN
method GetDescrizione(sCodice as string) as STRING
local sRet := "" as string
LOCAL oDB as DBServer
local oFSIndex as FileSpec
oDB := DBServer{"C:GDOSHOPARCHIVI9ARTICOK.DBF",FALSE,TRUE,"DBFCDX"}
oFSIndex := FileSpec{ "ARTICOK.CDX" }
oFSIndex:Path := "C:GDOSHOPARCHIVI9"
if !oFSIndex:Find()
oDB:Close()
Return "File Indice non trovato"
endif
if !oDB:SetIndex(oFSIndex)
oDB:Close()
Return "Indice non Applicato"
endif
oDB:GoTop()
if !oDB:Seek("0001009")
oDB:Close()
Return "Articolo non trovato"
endif
sRet := (STRING)oDB:FIELDGET("CODICE") + " "+ (STRING)oDB:FIELDGET("DESCRIZIO")
oDB:Close()
return sRet
END CLASS
END NAMESPACE // VulcanTest
*********************************************************************************************
DBF Index Files and Dialect Core
Hi Gianluca,
this cannot work since you need the macro compiler for the index maintenance.
And the Core dialect does not know what to to with the Date datatype.
If you like to use DBF files in a Core dialect application, you have to put all the DBF management in a VO or Vulcan dialect intermediate library.
This may be true also when the RDDs are released, because also they will rely on the macrocompiler and the specific VO datatypes.
Wolfgang
this cannot work since you need the macro compiler for the index maintenance.
And the Core dialect does not know what to to with the Date datatype.
If you like to use DBF files in a Core dialect application, you have to put all the DBF management in a VO or Vulcan dialect intermediate library.
This may be true also when the RDDs are released, because also they will rely on the macrocompiler and the specific VO datatypes.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
- gianluca.pinoli
- Posts: 36
- Joined: Mon Nov 02, 2015 1:13 pm
- Location: Italy
DBF Index Files and Dialect Core
Thanks Wolfgang.
What do you mean suggesting an intermediate library? A Library with a static method exposed?
Regards
Gianluca
What do you mean suggesting an intermediate library? A Library with a static method exposed?
Regards
Gianluca
DBF Index Files and Dialect Core
Hi Gianluca,
no. A library that contains a sort of proxy classes.
If you need a sample how this could work, let me know.
Personally I would not use a Core dialect class when I need to access DBF files. Now that the X# runtime is available I will use it because it has a very positive effect on my productivity <g>.
Wolfgang
no. A library that contains a sort of proxy classes.
If you need a sample how this could work, let me know.
Personally I would not use a Core dialect class when I need to access DBF files. Now that the X# runtime is available I will use it because it has a very positive effect on my productivity <g>.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
- gianluca.pinoli
- Posts: 36
- Joined: Mon Nov 02, 2015 1:13 pm
- Location: Italy
DBF Index Files and Dialect Core
Hi Wolfgang,
In this phase i'm more testing that developing a real application.
When X# RDD will be ready I'll indeed use it, but in the while if you can send me a smple of your proxy class I'd appreciate it.
Regards
Gianluca
In this phase i'm more testing that developing a real application.
When X# RDD will be ready I'll indeed use it, but in the while if you can send me a smple of your proxy class I'd appreciate it.
Regards
Gianluca
DBF Index Files and Dialect Core
Hi Gianluca,
my proxy class was so specific that I have to rewrite it as sample. I will do this over the weekend.
Wolfgang
my proxy class was so specific that I have to rewrite it as sample. I will do this over the weekend.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
- gianluca.pinoli
- Posts: 36
- Joined: Mon Nov 02, 2015 1:13 pm
- Location: Italy
DBF Index Files and Dialect Core
Thanks Wolfgang
DBF Index Files and Dialect Core
Hi Gianluca,
you will find the entire code attached also as XIDE export files.
This is the library code, compiled with X#, VO dialect, x86 mode:
and this is the application, compiled with X# Core dialect, x86 mode:
This code is missing any error handling and was written only for demonstration purposes. So please don't take it as sample how to write correct code.
Wolfgang
you will find the entire code attached also as XIDE export files.
This is the library code, compiled with X#, VO dialect, x86 mode:
Code: Select all
using Vulcan.VO
class DBFReader
protect _cFilePath as string
protect _cIndex as string
protect _cRDD as string
protect _oDBServer as DBServer
constructor( cFilePath as string, cIndex as string, cRDD as string )
_cFilePath := cFilePath
_cIndex := cIndex
_cRDD := cRDD
_oDBServer := DBServer{ _cFilePath, true, false, _cRDD }
_oDBServer:SetIndex( _cIndex )
return
property Eof as logic
get
local lReturn as logic
if _oDBServer == null
lReturn := true
else
lReturn := _oDBServer:EOF
endif
return lReturn
end get
end property
method Skip() as logic
local lReturn as logic
lReturn := _oDBServer:Skip()
return lReturn
method GetValue( cFieldName as string ) as object
local oReturn as object
oReturn := _oDBServer:FieldGet( cFieldName )
return oReturn
destructor()
if _oDBServer != null
if _oDBServer:Used
_oDBServer:Close()
endif
endif
return
end class
Code: Select all
using System
function Start( ) as void
local oReader as DBFReader
local cDBFFile as string
local cDBFIndex as string
local cFirstName as string
local cLastName as string
local cCustId as string
cDBFFile := "C:cavo28SamplesSsatutorCustomer.dbf"
cDBFIndex := "Cust1.ntx"
Console.WriteLine( i"Trying to open {cDBFFile}..." )
oReader := DBFReader{ cDBFFile, cDBFIndex, "DBFNTX" }
while ! oReader:Eof
cCustId := oReader:GetValue( "Cust_ID" ):ToString()
cFirstName := oReader:GetValue( "First_Name" ):ToString()
cLastName := oReader:GetValue( "Last_Name" ):ToString()
Console.WriteLine( i"Customer {cCustId} is {cFirstName} {cLastName}" )
oReader:Skip()
end
return
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
- gianluca.pinoli
- Posts: 36
- Joined: Mon Nov 02, 2015 1:13 pm
- Location: Italy
DBF Index Files and Dialect Core
Hi Wolfgang,
Thank you for the samples.
I tested your code, but I have the same problem, CoreDBF works, but if you try to apply "Cust2.ntx" instead of "Cust1.ntx" you'll get the same result.
Setting Vulcan dialect and adding reference to VulcanRT.dll and VulcanRTfunc.dll it start working as required.
Have you got the same problem?
If not, any idea of were is my mistake?
Regrds
Gianluca
Thank you for the samples.
I tested your code, but I have the same problem, CoreDBF works, but if you try to apply "Cust2.ntx" instead of "Cust1.ntx" you'll get the same result.
Setting Vulcan dialect and adding reference to VulcanRT.dll and VulcanRTfunc.dll it start working as required.
Have you got the same problem?
If not, any idea of were is my mistake?
Regrds
Gianluca
DBF Index Files and Dialect Core
Hi Gianluca,
you are right - I have forgottten something very important. The Vulcan runtime needs to be initialized.
Please add this class to the library:
and add the following line before opening the first DBF file:
This is again an export of both files. When using the Vulcan or VO dialect, X# does this under the hood.
Wolfgang
you are right - I have forgottten something very important. The Vulcan runtime needs to be initialized.
Please add this class to the library:
Code: Select all
class VulcanLoader
static method InitVulcan() as void
local t as Type
local mi as System.Reflection.MethodInfo
t := typeof(VulcanLoader)
mi := t:GetMethod( "InitVulcan" )
Vulcan.Runtime.State.AppModule := mi:Module
return
end class
Code: Select all
VulcanLoader.InitVulcan()
This is again an export of both files. When using the Vulcan or VO dialect, X# does this under the hood.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it