Programas VFP a "C"
Por favor, si alguien puede darme una mano en la traducción de unos simples programas fox a "c se los agradezco. Aquí van los prg's.
a)LPARAMETER pathKB ,VarError
PUBLIC KB
PUBLIC initialPath
PUBLIC kbPath
PUBLIC RST
ON ERROR VarError = "S"
kbPath = pathKB
initialPath = FULLPATH("")
KB = CreateObject("ADODB.Connection")
dataSourceName = pathKB
KB.Open("Provider=GXPublic.GXPublic.3;Data Source=" + pathKB)
SET DEFA TO &initialPath
b)LPARAMETER TableName, ValWhere
ON ERROR Messagebox("Error al abrir el archivo")
SET DEFA TO &kbPath
RST = CreateObject("ADODB.RecordSet")
RST.ActiveConnection = KB
commText = "select * from " + TableName
if type("ValWhere") == "C"
commText = commtext + " where " + valwhere
endif
RST.Open(commText )
ON ERROR
*RST.MoveFirst
SET DEFA TO &initialPath
c)LPARAMETER valToRet
initialpath = FULLPATH("")
SET DEFA TO &kbPath
ret = RST.EOF()
SET DEFA TO &initialPath
if ret
valToRet = '1'
else
valToRet = '0'
endif
d)LPARAMETER valores, cantCol
ON ERROR MessageBox("Error al leer el registro del archivo")
DIMENSION valores(RST.fields.count)
*SET DEFA TO &kbPath
for i = 1 to RST.fields.count
if RST.fields(i - 1).type == 3 && numerico
valores(i) = str(RST.fields(i - 1).value)
else
if RST.fields(i - 1).type == 135 && datetime
valores(i) = ttoc(RST.fields(i - 1).value)
else
valores(i) = RST.fields(i - 1).value
endif
endif
endfor
cantCol = RST.fields.count
*SET DEFA TO &initialPath
ON ERROR
RETURN
e)release RST
f)RELEASE RST
RELEASE KB
g)Param UbiDirMod MdlProcesar XPWDescrip ReqExpARef ObjADistr VerGx
* Almacenar área de trabajo
LOCAL o_area
o_area = SELECT()
SELECT 0
* Abre la Kb
*ON ERROR Messagebox("Could not open KB")
kbPath = UbiDirMod
initialPath = FULLPATH("")
KB = CreateObject("ADODB.Connection")
dataSourceName = UbiDirMod
If VerGx = 'XPW'
KB.Open("Provider=GXPublic.GXPublic.2;Data Source=" + UbiDirMod)
Else
KB.Open("Provider=GXPublic.GXPublic.3;Data Source=" + UbiDirMod)
Endif
SET path TO &kbPath
Rst = CreateObject("ADODB.RecordSet")
Rst.ActiveConnection = KB
Rst.Properties(15).Value = MdlProcesar
Rst.Properties(19).Value = ReqExpARef
Rst.Properties(20).Value = XPWDescrip
Rst.Properties(21).Value = 0
RST.Open(ObjADistr)
*RST.MoveFirst
SET DEFA TO &initialpath
* Restaurar área de trabajo
USE
SELECT( o_area)
*Cierra la KB
RELEASE RST
RELEASE KB
RELEASE o_area
RELEASE initialpath
RELEASE kbpath
return
a)LPARAMETER pathKB ,VarError
PUBLIC KB
PUBLIC initialPath
PUBLIC kbPath
PUBLIC RST
ON ERROR VarError = "S"
kbPath = pathKB
initialPath = FULLPATH("")
KB = CreateObject("ADODB.Connection")
dataSourceName = pathKB
KB.Open("Provider=GXPublic.GXPublic.3;Data Source=" + pathKB)
SET DEFA TO &initialPath
b)LPARAMETER TableName, ValWhere
ON ERROR Messagebox("Error al abrir el archivo")
SET DEFA TO &kbPath
RST = CreateObject("ADODB.RecordSet")
RST.ActiveConnection = KB
commText = "select * from " + TableName
if type("ValWhere") == "C"
commText = commtext + " where " + valwhere
endif
RST.Open(commText )
ON ERROR
*RST.MoveFirst
SET DEFA TO &initialPath
c)LPARAMETER valToRet
initialpath = FULLPATH("")
SET DEFA TO &kbPath
ret = RST.EOF()
SET DEFA TO &initialPath
if ret
valToRet = '1'
else
valToRet = '0'
endif
d)LPARAMETER valores, cantCol
ON ERROR MessageBox("Error al leer el registro del archivo")
DIMENSION valores(RST.fields.count)
*SET DEFA TO &kbPath
for i = 1 to RST.fields.count
if RST.fields(i - 1).type == 3 && numerico
valores(i) = str(RST.fields(i - 1).value)
else
if RST.fields(i - 1).type == 135 && datetime
valores(i) = ttoc(RST.fields(i - 1).value)
else
valores(i) = RST.fields(i - 1).value
endif
endif
endfor
cantCol = RST.fields.count
*SET DEFA TO &initialPath
ON ERROR
RETURN
e)release RST
f)RELEASE RST
RELEASE KB
g)Param UbiDirMod MdlProcesar XPWDescrip ReqExpARef ObjADistr VerGx
* Almacenar área de trabajo
LOCAL o_area
o_area = SELECT()
SELECT 0
* Abre la Kb
*ON ERROR Messagebox("Could not open KB")
kbPath = UbiDirMod
initialPath = FULLPATH("")
KB = CreateObject("ADODB.Connection")
dataSourceName = UbiDirMod
If VerGx = 'XPW'
KB.Open("Provider=GXPublic.GXPublic.2;Data Source=" + UbiDirMod)
Else
KB.Open("Provider=GXPublic.GXPublic.3;Data Source=" + UbiDirMod)
Endif
SET path TO &kbPath
Rst = CreateObject("ADODB.RecordSet")
Rst.ActiveConnection = KB
Rst.Properties(15).Value = MdlProcesar
Rst.Properties(19).Value = ReqExpARef
Rst.Properties(20).Value = XPWDescrip
Rst.Properties(21).Value = 0
RST.Open(ObjADistr)
*RST.MoveFirst
SET DEFA TO &initialpath
* Restaurar área de trabajo
USE
SELECT( o_area)
*Cierra la KB
RELEASE RST
RELEASE KB
RELEASE o_area
RELEASE initialpath
RELEASE kbpath
return
