Cobol Foro
Navegación en el Foro
Retroceder   Cobol Foro Entornos de desarrollo y compiladores Cobol Fujitsu COBOL PowerCOBOL y COM/OLE
PowerCOBOL y COM/OLE La utilización de COM / OLE en PowerCOBOL
 
Otros temas que te pueden interesar
Tema Autor Foro Respuestas Último post
[Duda] Alguien utiliza Power-LibreOffice? Xavier PowerCOBOL (ActiveX, v4 - v11) 0 8 de julio de 2021 20:11
[Sintaxis] Convertir DECIMAL a NUMERO para COBOL Dasije WinDev 0 11 de agosto de 2019 23:44
[Duda] Eejempo: convertir string binario en valor Kuk Micro Focus COBOL 0 9 de agosto de 2019 16:24
[Herramienta] Convertir Label a JPG Anthony AcuCobol 2 23 de julio de 2016 00:54
[Componente] OCR para convertir la IMG a texto Roger PowerCOBOL (ActiveX, v4 - v11) 8 6 de marzo de 2015 12:24

Respuesta
 
Herramientas

  #1
Antiguo 23 de agosto de 2021, 13:47
Xavier
Forero Junior
Última Actividad 17.11.2021 12:04
Posts Posts: 24
Likes enviados Enviados: 13
Likes recibidos Recibidos: 3
Predeterminado Convertir LibreOffice Basic a COBOL¿?
0 Inactivo Inactivo

Buenos días. Alguien sabría "traducir" esta instrucción (marcada con --->) hecha con Basic de LibreOffice a instrucciones COBOL?:

Código VB:
  1. Sub AbriendoDocumentos4()
  2.  Dim sRuta As String
  3. --->  Dim mOpciones(0) As New "com.sun.star.beans.PropertyValue"
  4.  Dim oDoc As Object
  5.  
  6.      mOpciones(0).Name = "AsTemplate"
  7.      mOpciones(0).Value = True
  8.  
  9.      sRuta = ConvertToUrl( "/home/Mi archivo de Writer.odt" )
  10.      oDoc = StarDesktop.loadComponentFromURL( sRuta, "_blank", 0, mOpciones() )
  11.  
  12.  End Sub

Agradecería cualquier ayuda. Estoy intentando pasar mis aplicaciones hechas para acceder a Word a poder hacerlo con LibreOffice Writer
Xavier is offline   Responder Con Cita
  #2
Antiguo 23 de agosto de 2021, 16:07
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

@Xavier, intenta a ver:

Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4.  01  TXT             PIC X(50).
  5.  01  mOpciones       OBJECT REFERENCE COM.
  6.  PROCEDURE       DIVISION.
  7.      
  8.      MOVE "com.sun.star.beans.PropertyValue" TO TXT    
  9.      INVOKE COM "CREATE-OBJECT" USING TXT RETURNING mOpciones
  10.  
  11.      INVOKE mOpciones "set-Name" USING "AsTemplate"
  12.      INVOKE mOpciones "set-Value" USING -1 *>True
  13.  


Y échale un ojo a este post: [Aporte] Uso del ChartControl de Codejock - COBOL Foro



NORMAS DEL FORO - para garantizar el buen funcionamiento del Foro.
¿Te han ayudado? NO TE OLVIDES de darle a
¿Quieres dirigirte a alguien en tu post? Notifícale haciendo clic en su Nick
Kuk is offline   Responder Con Cita
  #3
Antiguo 24 de agosto de 2021, 10:36
Xavier
Forero Junior
Última Actividad 17.11.2021 12:04
Posts Posts: 24
Likes enviados Enviados: 13
Likes recibidos Recibidos: 3

Gracias Kuk, ya había intentado definir así la variable
Código COBOL:
  1.  01 ServProperty        PIC X(32) VALUE "com.sun.star.beans.PropertyValue".
  2.  01 objArgs         OBJECT REFERENCE COM.

Pero, al trazar el programa y ejecutar la instrucción:
Código COBOL:
  1.   "INVOKE COM "Create-Object" USING ServProperty RETURNING objArgs

Me da el siguiente error:
Código:
 "Exception ocurrence(Exception object)
Voy a echar una ojeada al "Aporte" que me has pasado


Comentario de Moderador

Utiliza las etiquetas de resalto de sintaxis (los botones, Cobol, SQL etc en el editor)
Xavier is offline   Responder Con Cita
  #4
Antiguo 24 de agosto de 2021, 12:41
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

@Xavier, habría que sacar la descripción del error más detallada.

Aquí tienes un ejemplo de cómo declarar las excepciones en DECLARATIVES: [Aporte] Exportar CmListview en Excel - COBOL Foro

También échale un ojo a esto: [Sintaxis] Como descifrar valores de COM-EXCEPTION - COBOL Foro



NORMAS DEL FORO - para garantizar el buen funcionamiento del Foro.
¿Te han ayudado? NO TE OLVIDES de darle a
¿Quieres dirigirte a alguien en tu post? Notifícale haciendo clic en su Nick
Kuk is offline   Responder Con Cita
  #5
Antiguo 24 de agosto de 2021, 17:28
fastpho
El Foro es mi casa
Innovación: Por aportar innovaciones - Issue reason: SQLite + OO Cobol class Concurso: Primer puesto: Ganador/a del Primer puesto en un concurso - Issue reason: Acceso a datos Cobol vía web 
Última Actividad 21.08.2026 18:08
Posts Posts: 365
Likes enviados Enviados: 252
Likes recibidos Recibidos: 243

@Xavier, Buscando en la web encontre dos ejemplos de OpenOffice en Net Express , creo que funcionan habria que convertirlos a powercobol
Ejemplo 1
Código COBOL:
  1. $set ooctrl(+P)
  2. IDENTIFICATION DIVISION.
  3. ENVIRONMENT DIVISION.
  4.  
  5. class-control.
  6. OServManager is class "$OLE$com.sun.star.ServiceManager"
  7. oleSafeArray is class "olesafea" OLE SafeArray class
  8. .
  9.  
  10. DATA DIVISION.
  11. WORKING-STORAGE SECTION.
  12.  
  13. copy mfole.cpy.
  14.  
  15.  
  16. *---SafeArray dimension structure SafeArrayBound
  17. * celements is the total number of elements
  18. * lBound is the lower boundary (usually 0)
  19. 01 tagSafeArrayBound is typedef.
  20. 05 celements usage ULONG.
  21. 05 llbound usage LONG.
  22. 01 SafeArrayBound is typedef usage tagSafeArrayBound.
  23. 01 saBound SafeArrayBound.
  24.  
  25.  
  26. 01 ServManager object reference.
  27. 01 StarDesktop object reference.
  28. 01 aDoc object reference.
  29. 01 atext object reference.
  30.  
  31. 01 Group1SafeArray object reference.
  32.  
  33. 01 theVarType VARTYPE.
  34.  
  35. 01 cDims UINT.
  36.  
  37. *-----------------------------------------------------------------
  38. PROCEDURE DIVISION.
  39.  
  40. Start-Up. # Start-Up
  41. *--- create the document
  42. perform CreateDocument-Stup.
  43.  
  44. *--- fill the document with some text
  45. perform FillDocument-Stup.
  46.  
  47. exit program.
  48. stop run.
  49.  
  50. *-----------------------------------------------------------------
  51. CreateDocument-Stup. # CreateDocument-Stup
  52. *---
  53. invoke OServManager "new" returning ServManager
  54.  
  55. *---
  56. invoke ServManager "createInstance"
  57. using "com.sun.star.frame.Desktop"
  58. returning StarDesktop.
  59.  
  60. *--- olesafearray
  61. move VT-VARIANT to thevarType.
  62. move 1 to cDims.
  63. move 0 to cElements OF saBound.
  64. move 0 to llBound OF saBound.
  65. invoke olesafearray "new" using by value thevarType
  66. by value cDims
  67. by reference saBound
  68. returning Group1SafeArray.
  69.  
  70. *--- loadComponentFromURL
  71. invoke StarDesktop "loadComponentFromURL"
  72. using "private:factory/swriter" change 'swriter' with 'scalc' to call openOffice Calc
  73. "_blank"
  74. "0"
  75. Group1SafeArray
  76. returning aDoc.
  77.  
  78. *-----------------------------------------------------------------
  79. FillDocument-Stup. # FillDocument-Stup
  80. invoke aDoc "GetText" returning aText. remove this line if you call 'Calc'
  81. invoke aText "SetString" using "Hello World". remove this line if you call 'Calc'
  82.  
  83. *-----------------------------------------------------------------
Ejemplo 2 :
Código COBOL:
  1.  $set sourceformat(variable)                                                                    
  2.       $set ooctrl( P)                                                                                
  3.        IDENTIFICATION DIVISION.                                                                      
  4.        ENVIRONMENT DIVISION.                                                                        
  5.                                                                                                      
  6.        class-control.                                                                                
  7.            OServManager is class "$OLE$com.sun.star.ServiceManager"                                  
  8.            oleSafeArray is class "olesafea"  *> OLE SafeArray class                                  
  9.            olesup is class "olesup"                                                                  
  10.            OLEVariant is class "olevar"                                                              
  11.             olebase is class "olebase"                                                              
  12.            .                                                                                        
  13.                                                                                                      
  14.        DATA DIVISION.                                                                                
  15.         WORKING-STORAGE SECTION.                                                                    
  16.                                                                                                      
  17.        copy mfole.cpy.                                                                              
  18.                                                                                                      
  19.        copy olesafea.cpy.            *> SafeArray records                                            
  20.                                                                                                      
  21.        01 theSafeArrayObj  object reference.                                                        
  22.                                                                                                      
  23.        01 saBound          SAFEARRAYBOUND.                                                          
  24.                                                                                                      
  25.        01 ServManager          object reference.                                                    
  26.        01 StarDesktop          object reference.                                                    
  27.        01 aDoc object reference.                                                                    
  28.        01 aSheets object reference.                                                                  
  29.        01 aSheet object reference.                                                                  
  30.        01 aCell object reference.                                                                    
  31.        01 aTempObj object reference.                                                                
  32.        01 oPropertyValue  object reference.                                                          
  33.        01 hResult            pic 9(9) comp-5.                                                        
  34.        01 iIndex               pic 9(9) comp-5 value 0.                                              
  35.            PROCEDURE DIVISION.                                                                      
  36.                                                                                                      
  37.            invoke OServManager "new" returning ServManager                                          
  38.                                                                                                      
  39.            invoke ServManager "createInstance" using "com.sun.star.frame.Desktop" returning StarDeskto
  40.                                                                                                      
  41.            move 0 to llBound   of saBound                                                            
  42.            move 1 to cElements of saBound                                                            
  43.            invoke olesafearray "new" using                                                          
  44.                by value VT-VARIANT                                                                  
  45.                by value 1                  *> Single dimension                                      
  46.                by reference saBound        *> Dimension boundaries                                  
  47.                returning theSafeArrayObj                                                            
  48.                                                                                                      
  49.            invoke StarDesktop "loadComponentFromURL" using                                          
  50.                by reference "private:factory/scalc"                                                  
  51.                by reference "_blank"                                                                
  52.                by value 0                                                                            
  53.                by reference theSafeArrayObj                                                          
  54.                returning aDoc                                                                        
  55.                                                                                                      
  56.            invoke aDoc "getSheets" returning aSheets                                                
  57.                                                                                                      
  58.            invoke olesup "setDispatchType" using by value 0   *> value 0 = next message forced to invoke
  59.            invoke aSheets "getByName" using by reference "Sheet1" returning aSheet                    
  60.                                                                                                      
  61.            invoke olesup "setDispatchType" using by value 0   *> value 0 = next message forced to invoke
  62.            invoke aSheet "getCellByPosition" using by value 0, by value 0 returning aCell            
  63.            invoke aCell "SetString" using "Hello World"                                              
  64.                                                                                                      
  65.            invoke ServManager "Bridge_GetStruct" using "com.sun.star.beans.PropertyValue" returning oP
  66.                                                                                                      
  67.            invoke olesup "setDispatchType" using by value 1   *> value 1 = next message forced to invoke
  68.            invoke oPropertyValue "Name" using z"FilterName"                                          
  69.                                                                                                      
  70.            invoke olesup "setDispatchType" using by value 1   *> value 1 = next message forced to invoke
  71.            invoke oPropertyValue "Value" using z"MS Excel 97"                                        
  72.            invoke theSafeArrayObj "putOLEObject"                                                    
  73.               using Iindex                                                                          
  74.                     by value oPropertyValue                                                          
  75.               returning hResult                                                                      
  76.            end-invoke.                                                                                
  77.            invoke aDoc "storeAsURL" using                                                            
  78.                by reference z"file:///C:/cobol/calctstx.xls"                
  79.                by reference theSafeArrayObj                                                          
  80.                                                                                                      
  81.       *>   Finalize all objects                                                                      
  82.            invoke aCell "finalize" returning aCell                                                  
  83.            invoke aSheet "finalize" returning aSheet                                                
  84.            invoke aSheets "finalize" returning aSheets                                              
  85.                                                                                                      
  86.            invoke aDoc "Close" using by value -1                                                      
  87.            invoke aDoc "Finalize" returning aDoc                                                    
  88.            invoke StarDesktop "Finalize" returning StarDesktop                                      
  89.            invoke ServManager "Finalize" returning ServManager                                      
  90.                                                                                                      
  91.            goback.                                                                                  
Saludos
fastpho is offline   Responder Con Cita
  #6
Antiguo 25 de agosto de 2021, 11:22
Xavier
Forero Junior
Última Actividad 17.11.2021 12:04
Posts Posts: 24
Likes enviados Enviados: 13
Likes recibidos Recibidos: 3

Hola @Kuk, ya hago uso de los controles para obtener una descripción más detallada del error, pero no me saca nada, solo un código de error, que lo he buscado por internet y no he conseguido ningún resultado
Esto es lo que me sale del error:

Código:
Error Type: 1
wCode: +0000
SCode: -147352571
SCode-Text: 
Error Descr:
---------- Post añadido : 11:22 ---------- Post anterior : 11:02 ----------

Hola @fastpho, me parece muy interesante tu aporte. Voy a trabajar en ello y ya os digo algo
Xavier is offline   Responder Con Cita
  #7
Antiguo 25 de agosto de 2021, 12:52
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

@Xavier, creo recordar que había que hacer llamadas adicionales para sacar la descripción del error.



NORMAS DEL FORO - para garantizar el buen funcionamiento del Foro.
¿Te han ayudado? NO TE OLVIDES de darle a
¿Quieres dirigirte a alguien en tu post? Notifícale haciendo clic en su Nick
Kuk is offline   Responder Con Cita
Respuesta



Derechos de Publicación
No puedes publicar nuevos temas
No puedes publicar posts/responder
No puedes adjuntar archivos
No puedes editar tus posts

BB code is habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado

Saltar a Foro


La franja horaria es GMT +2. Ahora son las 12:09.
Powered by: vBulletin, Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.