PDA

Ver la Versión Completa : [Sintaxis] Estructura de los COPYs mfole.cpy. y olesafea.cpy


Xavier
1 de septiembre de 2021, 14:09
Buenos días a todos.
Estoy intentando trabajar con LibreOffice desde NetCobol, para ello he mirado algunos ejemplos que me pasó @fastpho, pero me encuentro que están escritos en Cobol de Micro Focus y no consigo saber cual es el contenido de los copys "mfole.cpy" y "olesafea.cpy", con lo que me resulta un poco difícil seguir en la adaptación a NetCobol.
¿Alguien conoce el contenido de estos copy's?
Agradecería cualquier información

fastpho
1 de septiembre de 2021, 14:33
Hola @Xavier, proba con estas lineas .... que te opinas @Kuk,

CLASS OLE AS "*OLE"
CLASS OLE-ARRAY AS "*OLE-ARRAY"



WORKING-STORAGE SECTION.
01 OServManager pic x(27) value "com.sun.star.ServiceManager".
01 OServDesktop pic x(26) value "com.sun.star.frame.Desktop".
01 ServManager object reference OLE.
01 StarDesktop object reference OLE.
01 aDoc object reference OLE.
01 atext object reference OLE.


01 Group1SafeArray object reference OLE-ARRAY.
01 VARIANT-TYPE PIC S9(9) COMP-5 VALUE 23.
01 LONG-INT-TYPE PIC S9(9) COMP-5 VALUE 3.
01 ARRAY-DIMENSION PIC S9(9) COMP-5 VALUE 1.
01 AXIS-1 PIC S9(9) COMP-5 VALUE 3.

01 celements PIC S9(9) COMP-5 VALUE 1.
01 llbound PIC S9(9) COMP-5 VALUE 0.

01 Valor-1 PIC X(23) value "private:factory/swriter".
01 Valor-2 PIC X(10) value "_blank".
01 Valor-3 PIC X(1) value "0".

01 Texto-Pas PIC X(10).
*
01 tagSafeArrayBound is typedef.
05 celements pic s9(9) comp-5.
05 llbound pic s9(9) comp-5.
01 SafeArrayBound TYPE tagSafeArrayBound.



invoke OLE "CREATE-OBJECT" using OServManager returning ServManager.
invoke ServManager "createInstance" using OServDesktop returning StarDesktop.
MOVE 0 TO celements OF SafeArrayBound.
MOVE 0 TO llbound OF SafeArrayBound.
invoke OLE-ARRAY "NEW" using
by reference VARIANT-TYPE
by reference ARRAY-DIMENSION
by reference SafeArrayBound
returning Group1SafeArray.

invoke StarDesktop "loadComponentFromURL" using
by reference Valor-1
by reference Valor-2
by reference valor-3
by reference Group1SafeArray
returning aDoc.

invoke aDoc "GET-Text" returning aText.
move "Hola Powercobol" to Texto-Pas .
invoke aText "SET-String" using Texto-Pas.

Saludos ,,,,

Kuk
1 de septiembre de 2021, 15:11
@fastpho, yo creo que llevas razón.

De todos modos hay que hacer una traducción, porque MF tiene su propio dialecto de Cobol, la sintaxis del cual no es de ningún estándar en concreto.

@Xavier, aquí tienes: 684

Xavier
7 de septiembre de 2021, 10:26
Hola @FastPho, he copiado el ejemplo que me has mandado y al ejecutar la siguiente instrucción

invoke OLE-ARRAY "NEW" using
by reference VARIANT-TYPE
by reference ARRAY-DIMENSION
by reference SafeArrayBound
returning Group1SafeArray.

me da el siguiente error


---------- Post añadido : 10:26 ---------- Post anterior : 10:19 ----------

Vaya, creo que no he insertado bien la imagen. Por si no se ve la imagen, aquí transcribo el mensaje de error:
"An error was detected during execution. See User program standar I/O. jmp0933I-U [PID:0000C48 TID:00001EB8]
TYPE CONVERSION ERROR OCCURRED IN USING PARAMETER OF THE 'NEW' METHOD OF THE SPECIAL CLASS'*COM-ARRAY/*OLE-ARRAY". PARAMETER=3 PGM=A5_COBOL-LIBOF LINE 52.1"



Si le pones la ruta de la imagen en tu PC como "e:\Error en ejecución.png" no va a funcionar porque la WEB no tiene acceso a tu PC.
Tienes que subirla primero a algún host de imágenes o adjuntarla aquí en el foro.

;)

fastpho
7 de septiembre de 2021, 15:47
Hola @Xavier, parce ser un problema de traducción como comento @Kuk, revisa los archivos que adjunto para la conversión, podes probar de cambiar estos valores .......

01 VARIANT-TYPE PIC S9(9) COMP-5 VALUE 12. *>new valor era 23
01 ARRAY-DIMENSION PIC 9(9) COMP-5 VALUE 1. *> new valor era s9.
01 tagSafeArrayBound is typedef.
05 celements pic 9(9) comp-5. *>new era S9(9)
05 llbound pic s9(9) comp-5.
01 SafeArrayBound TYPE tagSafeArrayBound.

Y te paso un ejemplo que encontre en la web en VBScript for manipulating OpenOffice.org Writer
para que pruebes a parte

'The service manager is always the starting point
'If there is no office running then an office is started
Set objServiceManager= Wscript._
CreateObject("com.sun.star.ServiceManager")
'Create the DesktopSet
objDesktop= objServiceManager._
createInstance("com.sun.star.frame.Desktop")
'Open a new empty writer document
Dim args()
Set objDocument=objDesktop._
loadComponentFromURL("private:factory/swriter",_
"_blank", 0, args)
'Create a text object
Set objText= objDocument.getText
'Create a cursor object
Set objCursor= objText.createTextCursor
'Inserting some Text
objText.insertString objCursor,_
"The first line in the created text document."&_
vbLf, false


Saludos