Cobol Foro

Cobol Foro (https://www.cobolforo.es/index.php)
-   COBOL - General (https://www.cobolforo.es/forumdisplay.php?f=44)
-   -   [Duda] Configuración Regional númerica (https://www.cobolforo.es/showthread.php?t=444)

Roger 26 de julio de 2016 01:44

Configuración Regional númerica
 
Necesito de alguna forma mediante el programa powecobol o algun activex detectar la configuración regional instalada en la maquina y si es posible cambiar al de mi pais, por defecto si es español viene 999.999,99 y mis programas estan echos para usar 999,999.99.

Hrmcobol 26 de julio de 2016 02:05

Hola Roger, yo uso esto para cambiar de punto y coma --> coma a punto

Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4.  01  caracter   pic x(255).
  5.  01  buffer pic s9(9) comp-5.
  6.  01  retcode    pic s9(9) comp-5.
  7.  01  errval pic 9.
  8.  PROCEDURE       DIVISION.
  9.  
  10.  
  11.       MOVE "." TO JRH-SGLI-MIL
  12.       MOVE "," TO JRH-SGLI-DEC
  13.       MOVE  0  TO retcode errval
  14.  
  15.  *>   Setear separador de decimales (numeros)
  16.          move spaces to caracter
  17.          move JRH-SGLI-DEC to caracter(1:1)
  18.          move X"00" to caracter(2:1)
  19.          CALL "SetLocaleInfoA" with stdcall linkage
  20.             using by value 1024
  21.                   by value 14
  22.                   by reference caracter
  23.             RETURNING     RETCODE
  24.          end-call
  25.          if retcode > 0
  26.             add 1 to errval
  27.          end-if
  28.  
  29.        
  30.          
  31.  *>        Setear separador de miles (numeros)
  32.          move spaces to caracter
  33.          move JRH-SGLI-MIL to caracter(1:1)
  34.          move X"00" to caracter(2:1)
  35.          CALL "SetLocaleInfoA" with stdcall linkage
  36.             using by value 1024
  37.                   by value 15
  38.                   by reference caracter
  39.             RETURNING     RETCODE
  40.          end-call
  41.          if retcode > 0
  42.             add 1 to errval
  43.          end-if
  44.  
  45.      INVOKE pow-self "Deactivate"

y el codigo siguiente lo da vuelta

Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4.  01  caracter   pic x(255).
  5.  01  buffer pic s9(9) comp-5.
  6.  01  retcode    pic s9(9) comp-5.
  7.  01  errval pic 9.
  8.  PROCEDURE       DIVISION.
  9.  
  10.  
  11.       MOVE "," TO JRH-SGLI-MIL
  12.       MOVE "." TO JRH-SGLI-DEC
  13.       MOVE  0  TO retcode errval
  14.  
  15.  *>   Setear separador de decimales (numeros)
  16.          move spaces to caracter
  17.          move JRH-SGLI-DEC to caracter(1:1)
  18.          move X"00" to caracter(2:1)
  19.          CALL "SetLocaleInfoA" with stdcall linkage
  20.             using by value 1024
  21.                   by value 14
  22.                   by reference caracter
  23.             RETURNING     RETCODE
  24.          end-call
  25.          if retcode > 0
  26.             add 1 to errval
  27.          end-if
  28.  
  29.        
  30.          
  31.  *>        Setear separador de miles (numeros)
  32.          move spaces to caracter
  33.          move JRH-SGLI-MIL to caracter(1:1)
  34.          move X"00" to caracter(2:1)
  35.          CALL "SetLocaleInfoA" with stdcall linkage
  36.             using by value 1024
  37.                   by value 15
  38.                   by reference caracter
  39.             RETURNING     RETCODE
  40.          end-call
  41.          if retcode > 0
  42.             add 1 to errval
  43.          end-if
  44.  
  45.      INVOKE pow-self "Deactivate"



Tenes qie incluir "KERNEL32.LIB"

Espero te sirva,
Saludos

Roger 26 de julio de 2016 02:58

Hrmcobol me da el siguiente ERROR
error LNK2001:unresolved external symbol_SETLOCALEINFOA@12
fatal error LNK1120: 1 unresolved externals

Estas variables JRH-SGLI-MIL JRH-SGLI-DEC donde se registran en la working
o son globales?

Hrmcobol 26 de julio de 2016 11:26

Perdon, me olvide la Working
Código COBOL:
  1.  01  JRH-SGLI-PARMS global external.
  2.      02 JRH-SGLI-DEC    PIC X.
  3.      02 JRH-SGLI-MIL    PIC X.
  4.      02 JRH-SGLI-SHOW   PIC X.  *> N:Numero M:Moneda
  5.      02 JRH-SGLI-RET    PIC X.

Kuk 26 de julio de 2016 17:40

Roger, tienes que añadir la opción de compilación ALPHAL(WORD) a las propiedades del código y recompilar todo.


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

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