Ayuda Array - Combobox

Ayuda Array - Combobox

Postby remtec » Thu May 18, 2023 5:52 pm

Hola Amigos

Ncesito lo siguiente, tengo 2 Combobox con Array, pero necesito generar el segundo al seleccionar un Items del 1er. Combox.

Emite un error.

Muchos Saludos
Antonio

Codigo:
Code: Select all  Expand view

         // 1er Combobox, que debe llenar el Combobox Tipo Pago
     @ 018,150 SAY "Tipo Examen"   SIZE 80,10 PIXEL OF oDlg4  RIGHT  FONT oFont2
     @ 018,237 ComboBox oExam Var nExam Items ArrTranspose(aExamenes)[2] SIZE 90,200 PIXEL OF oDlg4  COLORS RGB(55, 255, 153)     FONT oFont5 ;
                         ON CHANGE ((Tip_Exam1:=ArrTranspose(aExamenes)[1][oExam:nAt]),IF(!Filtra_Aran_Ate(Estado1,Tip_Exam1,Tip_Pag1,.t.),(MsgStop("TODO BIEN"),oBrw2:Setfocus(),.F.), (oBrw2:Refresh(),oTpag:Refresh(),oBrw2:Setfocus(), .T.) ))

     @ 030,150 SAY "Tipo Pago"   SIZE 80,10 PIXEL OF oDlg4  RIGHT  FONT oFont2
     @ 030,237 ComboBox oTpag Var nTPag Items ArrTranspose(aTpagos)[2] SIZE 90,200 PIXEL OF oDlg4  COLORS RGB(55, 255, 153)     FONT oFont5 ;
                         ON CHANGE ((Tip_Pag1:=ArrTranspose(aTpagos)[1][oTpag:nAt]),IF(!Filtra_Aran_Ate(Estado1,Tip_Exam1,Tip_Pag1,.f.),(MsgStop("TODO BIEN"),oBrw2:Setfocus(),.F.), (oBrw2:Refresh(),oBrw2:Setfocus(), .T.) ))


.....

Static Function Filtra_Aran_Ate(cEsta,cAte,cPag,desde)
        If desde        // Si es .T. viene de Tipo atencion y debe Actulizar el Array aTpagos
                Sele Aran
                Rec:=OrdNumber()
                Regi:=Recno()
                DbSetOrder(7)
                aTpagos2:=aTpagos

                aTpagos:={}
                AADD( aTpagos,{ "   ","         "," "})

                Seek cAte

                Do While (Tip_Ate=cAte).and.!Eof()
                        If !Eof()
                             Sele TPag
                             Seek Aran->Tip_Pag
                             If !Eof()
                                    Aadd(aTpagos, { Aran->Tip_Pag,Tpag->Nom_Pag,Tpag->Est_Pag})
                             Endif
                             Sele Aran
                             cPag2:=Tip_Pag
                             Do While (Tip_Ate=cAte.and.Tip_Pag=cPag2).and.!Eof()
                                    Skip
                             Enddo
                        Else
                             Skip
                        Endif
                Enddo
                xbrowse(aTpagos)
                If Len(aTpagos)=0
                     aTpagos:=aTpagos2
                Endif
                ASort(aTpagos,,,{|x,y| x[2]<y[2]})   //Ordena ascendente por descripcion
                DbSetOrder(Rec)      // Recupero Orden que ingreso
                Go Regi
        Endif


 


Error:
Code: Select all  Expand view


pplication
===========
   Path and name: C:\Desa\Sistem 2023\Maestros\MaeWin.exe (32 bits)
   Size: 5,556,736 bytes
   Compiler version: Harbour 3.2.0dev (r2008190002)
   FiveWin  version: FWH 22.10
   C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
   Windows XP 32 Bits, version: 5.1, Build 2600 Service Pack 3

   Time from start: 0 hours 0 mins 37 secs
   Error occurred at: 18/05/2023, 13:50:52
   Error description: Error BASE/1132  Error de rango: acceso al array
   Args:
     [   1] = A   {"   ","BANM","BONI","CIGN","CENR","27  ","GACH","PACH","CHIL","CISO","COLM","CONS","FAB ","GS ... } length: 40
     [   2] = N   45

Stack Calls
===========
   Called from: .\Actu_Aran.PRG => (b)ACTU_MAE_ARAN( 152 )
   Called from: .\source\classes\COMBOBOX.PRG => TCOMBOBOX:CHANGE( 581 )
   Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT( 1826 )
   Called from: .\source\classes\COMBOBOX.PRG => TCOMBOBOX:HANDLEEVENT( 923 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3689 )
   Called from:  => SENDMESSAGE( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:COMMAND( 520 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:HANDLEEVENT( 1213 )
   Called from:  => DIALOGBOXINDIRECT( 0 )
   Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE( 307 )
   Called from: .\Actu_Aran.PRG => ACTU_MAE_ARAN( 235 )
   Called from: .\MaeWin.PRG => (b)MENU( 173 )
   Called from: .\source\classes\MENU.PRG => TMENU:COMMAND( 1557 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:COMMAND( 1158 )
   Called from:  => TWINDOW:HANDLEEVENT( 0 )
   Called from: .\source\classes\WINDOW.PRG => _FWH( 3689 )
   Called from:  => WINRUN( 0 )
   Called from: .\source\classes\WINDOW.PRG => TWINDOW:ACTIVATE( 1114 )
   Called from: .\MaeWin.PRG => MAIN( 130 )

System
======
   CPU type: Intel(R) Core(TM)2 Duo CPU     E7400  @ 2.80GHz 2793 Mhz
   Hardware memory: 3020 megs

   Free System resources: 90 %
        GDI    resources: 90 %
        User   resources: 90 %

   Windows total applications running: 10
      1 ,                                                                                                    
      2 , C:\Desa\Sistem 2023\Maestros\MaeWin.exe                                                            
      3 , C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.6028_x-ww_61e65202
      4 , C:\WINDOWS\system32\COMCTL32.DLL                                                                    
      5 , C:\WINDOWS\system32\SHLWAPI.dll                                                                    
      6 DDE Server Window, C:\WINDOWS\system32\OLE32.DLL                                                                      
      7 GDI+ Window, C:\WINDOWS\WinSxS\x86_Microsoft.Windows.GdiPlus_6595b64144ccf1df_1.0.6002.23084_x-ww_f3f35550\GDIPLU
      8 M, C:\WINDOWS\system32\msctfime.ime                                                                    
      9 MCI command handling window, C:\WINDOWS\system32\WINMM.DLL                                                                      
     10 SysFader, C:\WINDOWS\system32\SHELL32.dll                                                                    

Variables in use
================
   Procedure     Type   Value
   ==========================
   (b)ACTU_MAE_ARAN
     Param   1:    O    Class: ERROR
   TCOMBOBOX:CHANGE
     Param   1:    O    Class: TCOMBOBOX
     Param   2:    C    "
PARTICULAR          "
     Local   1:    N    45
     Local   2:    U    
     Local   3:    U    
     Local   4:    S    
   TCONTROL:HANDLEEVENT
     Local   1:    C    "
PARTICULAR          "
     Local   2:    N    45
     Local   3:    U    
   TCOMBOBOX:HANDLEEVENT
     Param   1:    N    2053
     Param   2:    N    0
     Param   3:    N    0
     Local   1:    U    
   _FWH
     Param   1:    N    2053
     Param   2:    N    0
     Param   3:    N    0
   SENDMESSAGE
     Param   1:    N    0
     Param   2:    N    2053
     Param   3:    N    0
     Param   4:    N    0
     Param   5:    N    11
     Local   1:    O    Class: TCOMBOBOX
   TDIALOG:COMMAND
     Param   1:    N    6554490
     Param   2:    N    2053
     Param   3:    N    0
     Param   4:    N    0
   TWINDOW:HANDLEEVENT
     Param   1:    N    65652
     Param   2:    N    6554490
     Local   1:    U    
     Local   2:    N    1
     Local   3:    N    116
     Local   4:    N    6554490
     Local   5:    U    
   TDIALOG:HANDLEEVENT
     Param   1:    N    273
     Param   2:    N    65652
     Param   3:    N    6554490
   DIALOGBOXINDIRECT
     Param   1:    N    273
     Param   2:    N    65652
     Param   3:    N    6554490
   TDIALOG:ACTIVATE
     Param   1:    N    4194304
     Param   2:    C    "
 @       u         P    Z   ô  p S T A T I C     M A E S T R O   D E   A R A N C E L         P    –  P
 q S T A T I C   T i p o   E x a m e n       ¡P    í  Z È r C O M B O B O X         P    –  P
 s S T A T I C   T i p o   P a g o       ¡P    í  Z È t C O M B O B O X         P    (  <
 u S T A T I C   E s t a d o     ¡P    n  F È v C O M B O B O X         1P    < - ¯w T X B R O W S E   a r a n p a g o       P     <   x T B T N B M P   N U E V O       P     d    y T B T N B M P   M O D I F I         P     Œ    z T B T N B M P   B O R R A       P     ´    { T B T N B M P   M U E S T R A       P     Ü    | T B T N B M P   I M P R I M E       P    d n
 } T B T N B M P   D o b l e   C l i c k ,   M o d i f i c a r   E s t a d o       P    ú ý   ~ T B T N B M P   V O L V E R       "
     Param   3:    N    4260622
     Param   4:    O    Class: TDIALOG
   ACTU_MAE_ARAN
     Param   1:    U    
     Param   2:    U    
     Param   3:    U    
     Param   4:    L    .T.
     Param   5:    U    
     Param   6:    L    .T.
     Param   7:    B    {|| ... }
     Param   8:    U    
     Param   9:    U    
     Param  10:    U    
     Param  11:    U    
     Param  12:    L    .F.
     Param  13:    O    Class: TDIALOG
     Param  14:    U    
     Local   1:    N    4260622
     Local   2:    S    
     Local   3:    O    Class: TDIALOG
   (b)MENU
     Local   1:    O    Class: TDIALOG
     Local   2:    O    Class: TXBROWSE
     Local   3:    O    Class: TFONT
     Local   4:    O    Class: TFONT
     Local   5:    O    Class: TSAY
     Local   6:    O    Class: TFONT
     Local   7:    O    Class: TFONT
     Local   8:    O    Class: TBTNBMP
   TMENU:COMMAND
     Param   1:    O    Class: TMENUITEM
   TWINDOW:COMMAND
     Param   1:    N    20013
     Local   1:    O    Class: TMENUITEM
   TWINDOW:HANDLEEVENT
     Param   1:    N    20013
     Param   2:    N    0
     Local   1:    N    0
     Local   2:    N    20013
     Local   3:    N    0
     Local   4:    U    
   _FWH
     Param   1:    N    273
     Param   2:    N    20013
     Param   3:    N    0
   WINRUN
     Param   1:    N    0
     Param   2:    N    273
     Param   3:    N    20013
     Param   4:    N    0
     Param   5:    N    1
     Local   1:    O    Class: TWINDOW
   TWINDOW:ACTIVATE
     Param   1:    N    4260622
   MAIN
     Param   1:    C    "
MAXIMIZED"
     Param   2:    U    
     Param   3:    U    
     Param   4:    U    
     Param   5:    U    
     Param   6:    U    
     Param   7:    U    
     Param   8:    U    
     Param   9:    U    
     Param  10:    U    
     Param  11:    U    
     Param  12:    U    
     Param  13:    U    
     Param  14:    U    
     Param  15:    U    
     Param  16:    U    
     Param  17:    B    {|| ... }
     Param  18:    U    
     Param  19:    U    
     Param  20:    L    .F.
     Local   1:    O    Class: TWINDOW
     Local   2:    U    
     Local   3:    U    

Linked RDDs
===========
   DBF
   DBFFPT
   DBFBLOB
   DBFCDX
   DBFNTX

DataBases in use
================

  1:    TATEN                              RddName: DBFCDX
     ==============================
     RecNo    RecCount    BOF   EOF
         44           43      .F.   .T.

     Indexes in use                        TagName
        => Cod_Aten                           TAT1
           Nom_Aten                           TAT2

     Relations in use

  2:    TPAG                               RddName: DBFCDX
     ==============================
     RecNo    RecCount    BOF   EOF
         43          109      .F.   .F.

     Indexes in use                        TagName
        => Tip_Pag                            TPA1
           Nom_Pag                            TPA2

     Relations in use

  3: => ARAN                               RddName: DBFCDX
     ==============================
     RecNo    RecCount    BOF   EOF
      15145        15144      .T.   .T.

     Indexes in use                        TagName
           cod_ara                            ARA1
           tip_pag+cod_ara                    ARA2
           tip_pag+tip_ate+cod_ara            ARA3
           tip_ate+cod_ara                    ARA4
        => tip_ate+tip_pag+nom_ara            ARA5
           tip_ate+tip_pag+nom_ara            ARA6
           tip_ate+tip_pag+nom_ara            ARA7
           tip_pag+tip_ate+nom_ara            ARA8

     Relations in use

Classes in use:
===============
     1 ERROR
     2 HBCLASS
     3 HBOBJECT
     4 TCURSOR
     5 TFONT
     6 TWINDOW
     7 TDIALOG
     8 TBRUSH
     9 TMDIFRAME
    10 TMENU
    11 TREG32
    12 TMDICLIENT
    13 TRECT
    14 TCONTROL
    15 TGET
    16 TSAY
    17 GET
    18 TCLIPGET
    19 TBTNBMP
    20 TMENUITEM
    21 TBAR
    22 TMSGBAR
    23 TMSGITEM
    24 TTIMER
    25 TCOMBOBOX
    26 TXBROWSE
    27 TXBRWCOLUMN
    28 TSCROLLBAR
    29 TCLIPBOARD
    30 TSTRUCT

Memory Analysis
===============
      747 Static variables

   Dynamic memory consume:
      Actual  Value:    2359296 bytes
      Highest Value:    2359296 bytes
FWH 22.10 - HARBOUR - PELLES C
remtec
 
Posts: 717
Joined: Fri May 12, 2017 2:50 pm

Re: Ayuda Array - Combobox

Postby Antonio Linares » Fri May 19, 2023 6:44 am

Estimado Antonio,

Estás intentando acceder a un elemento del array que no existe:

[ 1] = A {" ","BANM","BONI","CIGN","CENR","27 ","GACH","PACH","CHIL","CISO","COLM","CONS","FAB ","GS ... } length: 40
[ 2] = N 45

El array debe tener al menos 45 elementos
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Ayuda Array - Combobox

Postby remtec » Fri May 19, 2023 4:18 pm

Antonio Linares wrote:Estimado Antonio,

Estás intentando acceder a un elemento del array que no existe:

[ 1] = A {" ","BANM","BONI","CIGN","CENR","27 ","GACH","PACH","CHIL","CISO","COLM","CONS","FAB ","GS ... } length: 40
[ 2] = N 45

El array debe tener al menos 45 elementos


Buen dia Maestro Antonio.

Muchas gracias por responder.

Que extraño, porque el array aTpagos que se en la funcion, se agregan 3 elementos.

Me parece que no puedo actualizar los elementos del aTpagos en tiempo de ejecucion, desde el 1º Combobox, al volver, ya el array aTpagos de me rescata datos que no selecciono.

Efectivamente, una vez que vuelvo desde el 1er Combobox, al seleccionar algun elemento de Combobox aTpagos 2do array creado, los elementos no coinciden con el seleccionado. :?:

Comprobe que es el array aTpagos, no se actuliza en el Combobox, aunque lo limpie en la funcion, vuelve igual muestra los datos anteriores en la lista :?:

Muchas gracias

Saludos
Antonio

Codigo
Code: Select all  Expand view

// Combobox
     @ 018,150 SAY "Tipo Examen"   SIZE 80,10 PIXEL OF oDlg4  RIGHT  FONT oFont2
     @ 018,237 ComboBox oExam Var nExam Items ArrTranspose(aExamenes)[2] SIZE 90,200 PIXEL OF oDlg4  COLORS RGB(55, 255, 153)     FONT oFont5 ;
                         ON CHANGE ((Tip_Exam1:=ArrTranspose(aExamenes)[1][oExam:nAt]),IF(!Filtra_Aran_Ate(Estado1,Tip_Exam1,Tip_Pag2,(xBrowse(aTpagos,"VUELVE aTpagos"),.t.)),(MsgStop("TODO BIEN"),oBrw2:Setfocus(),.F.), (oBrw2:Refresh(),oTpag2:Refresh(),oBrw2:Setfocus(), .T.) ))

     @ 030,150 SAY "Tipo Pago"   SIZE 80,10 PIXEL OF oDlg4  RIGHT  FONT oFont2
     @ 030,237 ComboBox oTpag2 Var nTPag2 Items ArrTranspose(aTpagos)[2] SIZE 90,200 PIXEL OF oDlg4  COLORS RGB(55, 255, 153)     FONT oFont5 ;
                         ON CHANGE ((Tip_Pag2:=ArrTranspose(aTpagos)[1][oTpag2:nAt]),IF(!Filtra_Aran_Ate(Estado1,Tip_Exam1,Tip_Pag2,.f.),(MsgStop("TODO BIEN"),oBrw2:Setfocus(),.F.), (oBrw2:Refresh(),oBrw2:Setfocus(), .T.) ))




// Carga de Array aTpagos
Static Function Filtra_Aran_Ate(cEsta,cAte,cPag,desde)
        ?" LLEGA "+"cAte "+cAte+"  cPag "+cPag+ " Estado "+cEsta

        If desde        // Si es .T. viene de Tipo atencion y debe llenar o actualizar Combobox aTpagos
                Sele Tpag
                DbSetOrder(1)

                Sele Aran
                Rec:=OrdNumber()
                Regi:=Recno()
                DbSetOrder(7)
                aTpagos2:=aTpagos

                aTpagos:={}
                AADD( aTpagos,{ "   ","         "," "})

                Seek cAte

                Do While (Tip_Ate=cAte).and.!Eof()
                     If !Empty(Aran->Tip_Ate)
                             Sele TPag
                             Seek Aran->Tip_Pag
                             If !Eof()
                                    Aadd(aTpagos, { Aran->Tip_Pag,Tpag->Nom_Pag,Tpag->Est_Pag})
                             Endif

                             Sele Aran
                             cPag2:=Tip_Pag
                             Do While (Tip_Ate=cAte.and.Tip_Pag=cPag2).and.!Eof()
                                    Skip
                             Enddo
                     Else
                            Skip
                     Endif
                Enddo
                ?Len(aTpagos),Len(aTpagos2)
                If Len(aTpagos)<=1
                     aTpagos:=aTpagos2
                Endif
                ASort(aTpagos,,,{|x,y| x[2]<y[2]})   //Ordena ascendente por descripcion
                DbSetOrder(Rec)      // Recupero Orden que ingreso
                Go Regi
        Endif

 
Last edited by remtec on Fri May 19, 2023 6:02 pm, edited 1 time in total.
FWH 22.10 - HARBOUR - PELLES C
remtec
 
Posts: 717
Joined: Fri May 12, 2017 2:50 pm

Re: Ayuda Array - Combobox

Postby remtec » Fri May 19, 2023 5:23 pm

Amigos

Alguna idea?

Saludos
Antonio
FWH 22.10 - HARBOUR - PELLES C
remtec
 
Posts: 717
Joined: Fri May 12, 2017 2:50 pm

Re: Ayuda Array - Combobox

Postby karinha » Sat May 20, 2023 3:53 pm

Publique un ejemplo completo para probar en Mega Upload, por favor. Es más fácil de probar. Piezas de programas son inútiles y es difícil ayudar.

Gracias.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Ayuda Array - Combobox

Postby leandro » Sat May 20, 2023 4:37 pm

Según lo que puede ver en el trozo de código que publicaste, parece que lo que te hace falta es hacer el cambio del nuevo array en el combobox.

Después de cambiar el array asígnalo a combobox y refréscalo
Code: Select all  Expand view

oTpag2:SetItems( aTpagos2, .t. )
oTpag2:refresh()
 

Espero te sea de ayuda.
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Embarcadero C++ 7.60 for Win32 ] [ FiveWin 23.07 ] [ xHarbour 1.3.0 Intl. (SimpLex) (Build 20230914) ]
User avatar
leandro
 
Posts: 1481
Joined: Wed Oct 26, 2005 2:49 pm
Location: Colombia


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 98 guests