Variables definidas por el usuario en VFP

523 views
Skip to first unread message

wilgueve

unread,
May 26, 2011, 3:26:40 PM5/26/11
to Comunidad de Visual Foxpro en Español
Hola a todos, alguien sabe si en VFP se pueden crear variables
definidias por el usuario como sucede en VB y otros lenguajes.

Ejemplo en VB, para que sepan de que estoy hablando.

Private Type DOCINFO
pDocName As String
pOutputFile As String
pDatatype As String
End Type

He intentado usando variables Custon o Collection y en ningun caso me
funciona.

oDocInfo = NEWOBJECT("Collection")
oDocInfo.AddProperty("pDocName", "ETIQUETAS")
oDocInfo.AddProperty("pDatatype", "")
oDocInfo.AddProperty("pOutputFile", "")

lDoc = StartDocPrinterA(lhPrinter, 1, oDocInfo)

La necesito para usar la función StartDocPrinterA del API WinSpool.drv
cuya sintaxis en VB es la siguiente:

DWORD StartDocPrinter(
__in HANDLE hPrinter,
__in DWORD Level,
__in LPBYTE pDocInfo
);

Parameters
hPrinter [in]
A handle to the printer. Use the OpenPrinter or AddPrinter function to
retrieve a printer handle.
Level [in]
The version of the structure to which pDocInfo points. This value must
be 1.
pDocInfo [in]
A pointer to a DOC_INFO_1 structure that describes the document to
print.

DCOC_INFO_1 es una estructura que cotiene los datos del documento que
se va a imprimir.

typedef struct _DOC_INFO_1 {
LPTSTR pDocName;
LPTSTR pOutputFile;
LPTSTR pDatatype;
} DOC_INFO_1;

Members
pDocName
Pointer to a null-terminated string that specifies the name of the
document.
pOutputFile
Pointer to a null-terminated string that specifies the name of an
output file. To print to a printer, set this to NULL.
pDatatype
Pointer to a null-terminated string that identifies the type of data
used to record the document.


De antemano, agradesco la ayuda, la necesito algo urgente.

Oscar Calderon Fuentes

unread,
May 26, 2011, 3:34:01 PM5/26/11
to publice...@googlegroups.com
Prueba con la clase EMPTY que crea una clase vacia a la que puedes agregarle las propiedades según nenecesidad del usuario:
 
oDocInfo = CREATEOBJECT("Empty")

AddProperty( oDocInfo, "pDocName", "ETIQUETAS")
AddProperty( oDocInfo, "pDatatype", "")
AddProperty( oDocInfo, "pOutputFile", "")
 
Saludos,
--
Oscar Calderón Fuentes
Santiago - Chile
 

wilgueve

unread,
May 30, 2011, 2:28:38 PM5/30/11
to Comunidad de Visual Foxpro en Español
Gracias por la respuesta, pero no me funciona, coloco el código
conpleto de la creación de la función, la declaración de la variable y
el uso de esta, por si la has usado y me puedes dar una luz.

* Función para determinar el inicio del documento *
DECLARE ;
LONG StartDocPrinter ;
IN winSpool.drv AS StartDocPrinterA ;
LONG @ hPrinter, ;
LONG @ Level, ;
OBJECT pDocInfo

*Creación del objeto
oDocInfo = NEWOBJECT("Empty")
AddProperty(oDocInfo, "pDocName", "ETIQUETAS")
AddProperty(oDocInfo, "pDatatype", "")
AddProperty(oDocInfo, "pOutputFile", "")

* Uso de la función
lDoc = StartDocPrinterA(lhPrinter, 1, oDocInfo)

El valor que me devuelve la función es siempre cero.

De antemano, gracias por la ayuda.

Hugo C.

unread,
May 30, 2011, 7:34:26 PM5/30/11
to Comunidad de Visual Foxpro en Español

Irlandes 1960

unread,
May 30, 2011, 11:20:58 PM5/30/11
to publice...@googlegroups.com
Hola, ¿probaste con los comandos public, local  private ? que se usan para declarar variables de diferentes alcances.
Suerte

Luis Maria Guayan

unread,
May 31, 2011, 8:14:38 AM5/31/11
to publice...@googlegroups.com
Lo que tu necesitas es definir una Estructura de Datos, que VFP no soporta. Existe una clase del alemán Christof Wollenhaupt llamada Struct.zip que te puede ayudar

Enlace para descargarla: http://www.foxite.com/downloads/default.aspx?id=3


Luis María Guayán
Tucumán, Argentina
_________________________
http://www.PortalFox.com
Nada corre como un zorro
_________________________

wilgueve

unread,
Jun 10, 2011, 3:29:11 PM6/10/11
to Comunidad de Visual Foxpro en Español
Descarga la clase y la adicione a mi proyecto para tratar de
implementarla, pero, aunque creo que estoy haciendo todo bien, la
función que requiere el tipo de dato "DOCINFO" no lo reconoce.

La declaración de la función y su uso son como siguen:

* Función para determinar el inicio del documento *
DECLARE ;
LONG StartDocPrinter ;
IN winSpool.drv AS WS_StartDocPrinter ;
LONG @ hPrinter, ;
LONG @ Level, ;
STRING pDocInfo

***********************************************************
* Se crea el objeto para administrar el documento *
oDocInfo = CREATEOBJECT("docInfo")
oDocInfo.cbSize = oDocInfo.SizeOf()
oDocInfo.lpszDocName = "ETIQUETAS"

*************************************************************************************
* Se usa el tipo de dato "DOCINFO" y se coloca al inicio del documento
*
lDoc = WS_StartDocPrinter(@lhPrinter, 1, oDocInfo.getString())

Y aunque no sale error alguno, tampoco funciona como debe.

Espero me puedas ayudar. De antemano, gracias.
Reply all
Reply to author
Forward
0 new messages