Ver Mensaje Individual
  #2
Antiguo 5 de diciembre de 2023, 21:31
Kuk
Administrador
Última Actividad 19.09.2026 20:11
Posts Posts: 2.500
Likes enviados Enviados: 1037
Likes recibidos Recibidos: 1207

@jmeza, mira a ver, no lo he probado casi pero algo así debes hacer. Lo mismo tienes que ajustar algo:

Código COBOL:
  1.  ENVIRONMENT     DIVISION.
  2.  DATA            DIVISION.
  3.  WORKING-STORAGE SECTION.
  4.  01  idx-1       pic 9(4).
  5.  01  idx-2       pic 9(4) comp-5.
  6.  
  7.  01  max         pic 9(4) comp-5.
  8.  
  9.  01  sw-enontr   pic x.
  10.      88  sw-enontr-si       value 's'.
  11.      88  sw-enontr-no       value 'n'.
  12.  
  13.  01  lineaCombo  pic x(20).
  14.  
  15.  01  buscar      pic x(20).
  16.  01  buscLength  pic 9(4) comp-5 value 0.
  17.  
  18.  
  19.  01  msg         pic x(100).
  20.  
  21.  PROCEDURE       DIVISION.
  22.  
  23.      move 'de5' to buscar
  24.      
  25.      compute buscLength = function stored-char-length(buscar)
  26.      
  27.      move 1 to idx-1
  28.      move "ListCount" OF CmCombo1 to max
  29.      
  30.      set sw-enontr-no to true
  31.      
  32.      perform until idx-1 > max or sw-enontr-si
  33.          move "ListString"(idx-1) OF CmCombo1 to lineaCombo
  34.          
  35.          move 1 to idx-2
  36.          
  37.          perform until idx-2 + buscLength > length of buscar or sw-enontr-si
  38.              if  lineaCombo(idx-2:buscLength) = buscar(1:buscLength)
  39.                  set sw-enontr-si to true
  40.              end-if
  41.              
  42.              add 1 to idx-2
  43.          end-perform
  44.          
  45.          if  sw-enontr-no
  46.              add 1 to idx-1
  47.          end-if
  48.      end-perform
  49.      
  50.      if  sw-enontr-si
  51.          move idx-1 to "ListIndex" OF CmCombo1
  52.          
  53.          string "Encontrado en la línea " idx-1 " del combo."
  54.              delimited by size into msg
  55.          
  56.          INVOKE pow-self "DisplayMessage" USING msg 64
  57.      
  58.      else
  59.          INVOKE pow-self "DisplayMessage" USING "No encontrado." 64
  60.      end-if
  61.      



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