Cobol Foro

Cobol Foro (https://www.cobolforo.es/index.php)
-   Fujitsu COBOL (https://www.cobolforo.es/forumdisplay.php?f=77)
-   -   [Sintaxis] Estructura de los COPYs mfole.cpy. y olesafea.cpy (https://www.cobolforo.es/showthread.php?t=1371)

Xavier 1 de septiembre de 2021 14:09

Estructura de los COPYs mfole.cpy. y olesafea.cpy
 
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,
Código COBOL:
  1.     CLASS OLE               AS "*OLE"
  2.     CLASS OLE-ARRAY   AS "*OLE-ARRAY"

Código COBOL:
  1. WORKING-STORAGE SECTION.
  2.  01 OServManager    pic x(27) value "com.sun.star.ServiceManager".
  3.  01 OServDesktop     pic x(26) value "com.sun.star.frame.Desktop".
  4.  01 ServManager      object reference OLE.
  5.  01 StarDesktop       object reference OLE.
  6.  01 aDoc                    object reference OLE.
  7.  01 atext                    object reference OLE.
  8.  
  9.  
  10.  01 Group1SafeArray        object reference OLE-ARRAY.
  11.  01 VARIANT-TYPE            PIC S9(9) COMP-5 VALUE 23.
  12.  01 LONG-INT-TYPE          PIC S9(9) COMP-5 VALUE 3.
  13.  01 ARRAY-DIMENSION    PIC S9(9) COMP-5 VALUE 1.
  14.  01 AXIS-1                           PIC S9(9) COMP-5 VALUE 3.
  15.  
  16.  01 celements                    PIC S9(9) COMP-5 VALUE 1.
  17.  01 llbound                         PIC S9(9) COMP-5 VALUE 0.
  18.  
  19.  01 Valor-1                          PIC X(23) value "private:factory/swriter".
  20.  01 Valor-2                          PIC X(10) value "_blank".
  21.  01 Valor-3                          PIC X(1)   value "0".
  22.  
  23.  01 Texto-Pas                     PIC X(10).
  24. *
  25.  01 tagSafeArrayBound is typedef.
  26.       05 celements               pic s9(9) comp-5.
  27.       05 llbound                    pic s9(9) comp-5.
  28.  01 SafeArrayBound   TYPE tagSafeArrayBound.
Código COBOL:
  1.      invoke OLE          "CREATE-OBJECT"        using OServManager  returning ServManager.
  2.      invoke ServManager  "createInstance"       using OServDesktop  returning StarDesktop.
  3.      MOVE 0 TO celements OF SafeArrayBound.
  4.      MOVE 0 TO llbound   OF SafeArrayBound.
  5.      invoke OLE-ARRAY    "NEW"                  using
  6.                       by reference VARIANT-TYPE
  7.                       by reference ARRAY-DIMENSION  
  8.                       by reference SafeArrayBound  
  9.                       returning Group1SafeArray.
  10.  
  11.      invoke StarDesktop  "loadComponentFromURL" using
  12.            by reference  Valor-1
  13.            by reference  Valor-2
  14.            by reference  valor-3
  15.            by reference  Group1SafeArray                  
  16.            returning aDoc.
  17.            
  18.      invoke aDoc "GET-Text" returning aText.
  19.      move "Hola Powercobol" to Texto-Pas .
  20.      invoke aText "SET-String" using Texto-Pas.
Saludos ,,,,

Kuk 1 de septiembre de 2021 15:11

1 Archivos Adjunto(s)
@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: Archivo Adjunto 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

Código COBOL:
  1.      invoke OLE-ARRAY    "NEW"                  using
  2.                       by reference VARIANT-TYPE
  3.                       by reference ARRAY-DIMENSION  
  4.                       by reference SafeArrayBound  
  5.                       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:
Código:

"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"


Comentario de Moderador

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 .......
Código COBOL:
  1.  01 VARIANT-TYPE     PIC S9(9) COMP-5 VALUE 12. *>new valor era 23
  2.  01 ARRAY-DIMENSION  PIC 9(9) COMP-5 VALUE 1.  *> new valor era s9.
  3.  01 tagSafeArrayBound is typedef.
  4.       05 celements   pic 9(9) comp-5. *>new  era S9(9)
  5.       05 llbound        pic s9(9) comp-5.
  6.  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
Código VB:
  1. 'The service manager is always the starting point
  2. 'If there is no office running then an office is started
  3. Set objServiceManager= Wscript._
  4.    CreateObject("com.sun.star.ServiceManager")
  5. 'Create the DesktopSet
  6. objDesktop= objServiceManager._
  7.   createInstance("com.sun.star.frame.Desktop")
  8. 'Open a new empty writer document
  9. Dim args()
  10. Set objDocument=objDesktop._
  11.  loadComponentFromURL("private:factory/swriter",_
  12.  "_blank", 0, args)
  13. 'Create a text object
  14. Set objText= objDocument.getText
  15. 'Create a cursor object
  16. Set objCursor= objText.createTextCursor
  17. 'Inserting some Text
  18. objText.insertString objCursor,_
  19.  "The first line in the created text document."&_
  20.        vbLf, false

Saludos


La franja horaria es GMT +2. Ahora son las 14:39.

Powered by: vBulletin, Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.