Columnas Xbrowse (Solucionado)

Columnas Xbrowse (Solucionado)

Postby JoseLuis » Wed Aug 24, 2022 9:42 pm

Muy buenas

Tengo un xbrowse, con 44 columnas:
Code: Select all  Expand view
       @ 30, 0 xbrowse oLbx Alias aAlias[1]  ;
                COLUMNS "Codigo","Nombre" ,"Precio1","Precio2","Precio3","Precio4","Precio5","Precio6","Precio7","Precio8","Precio9","Precio10",;
                        "Precio11","Precio12","Precio13","Precio14","Precio15","Precio16","Precio17","Precio18","Precio19","Precio20","Precio21",;
                        "Precio22","Precio23","Precio24","Precio25","Precio26","Precio27","Precio28","Precio29","Precio30","Precio31","Precio32",;
                        "Precio33","Precio34","Precio35","Precio36","Precio37","Precio38","Precio39","Precio40","Precio41","Resto";
                HEADERS "Cód","Descripcion"," Tramo1 "," Tramo2 "," Tramo3 "," Tramo4 "," Tramo5 "," Tramo6 "," Tramo7 "," Tramo8 "," Tramo9 "," Tramo10 ",;
                        " Tramo11 "," Tramo12 "," Tramo13 "," Tramo14 "," Tramo15 "," Tramo16 "," Tramo17 "," Tramo18 "," Tramo19 "," Tramo20 ",;
                " Tramo21 "," Tramo22 "," Tramo23 "," Tramo24 "," Tramo25 "," Tramo26 "," Tramo27 "," Tramo28 "," Tramo29 "," Tramo30 ",;
                " Tramo31 "," Tramo32 "," Tramo33 "," Tramo34 "," Tramo35 "," Tramo36 "," Tramo37 "," Tramo38 "," Tramo39 "," Tramo40 ",;
                " Tramo41 "," Resto ";
                LINES CELL NOBORDER  SIZE -20,-30 OF oDlg PIXEL
 


El problema es que si hago un bucle for next para lo que sea, en este caso para el tema del color:

Code: Select all  Expand view
       for a = 3 to len (oLbx:aCols)
                oLbx:aCols[a]:bClrStd := { || if(oLbx:aCols[a]:value == 0 , {CLR_HRED,If( oLbx:KeyNo % 2 == 0, nRGB(242,247,252),nRGB(226,226,208) )},{CLR_BLACK,If( oLbx:KeyNo % 2 == 0, nRGB(242,247,252),nRGB(226,226,208) )}) }
        next a

 


me salta el error:
******************
Application
===========
Path and name: C:\COMPILAN\FIVEDIT\PROGRAMA\gesnuevo.exe (32 bits)
Size: 6,438,912 bytes
Compiler version: xHarbour 1.2.3 Intl. (SimpLex) (Build 20150603)
FiveWin Version: FWHX 15.10
Windows version: 6.2, Build 9200

Time from start: 0 hours 0 mins 9 secs
Error occurred at: 24/08/22, 23:37:58
Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = A { ... } length: 44
[ 2] = N 45

Stack Calls
===========
Called from: c:\compilan\fivedit\prg\Articulo.prg => (b)ARTICULO( 104 )

**********************************

La linea es la del bucle for next y me viene a decir que el array es de 44 elementos, pero que le llegan 45 o algo así.

Que puede ser?
Last edited by JoseLuis on Sat Aug 27, 2022 5:32 pm, edited 1 time in total.
--------------------------
Saludos

Jose Luis
JoseLuis
 
Posts: 426
Joined: Thu Oct 19, 2006 12:28 pm
Location: Toledo

Re: Columnas Xbrowse

Postby Cgallegoa » Wed Aug 24, 2022 11:33 pm

Jose Luis,

Tienes que procesar una función Detached. Te pongo un ejemplo funcional:

Code: Select all  Expand view
#include "FiveWin.ch"
#include "xBrowse.ch"


function Main22()

   LOCAL oDlg, oLbx, aDatos, a

   aDatos := { {1,0,3,0,5} , {1,0,3,4,5} , {1,2,3,4,5} , {1,2,3,4,5} , {1,2,3,4,0} , {1,2,0,4,5}}

   DEFINE DIALOG oDlg SIZE 420, 250 PIXEL

      @ 5, 5 xbrowse oLbx DATASOURCE aDatos OF oDlg ;
              COLUMNS {1,2,3,4,5} ;
              HEADERS {"Col.1","Col.2","Col.3","Col.4","Col.5"} PIXEL SIZE 194,100

      oLbx:CreateFromCode()
     
       for a := 3 to len (oLbx:aCols)
           Detached(oLbx,a)
       next a
           
   ACTIVATE DIALOG oDlg CENTERED // ON INIT Detached(oLbx)
 
return nil


Function Detached(oLbx,a)
   oLbx:aCols[a]:bClrStd := { || if(oLbx:aCols[a]:value == 0 , {CLR_HRED,If( oLbx:KeyNo % 2 == 0, nRGB(242,247,252),nRGB(226,226,208) )},{CLR_BLACK,If( oLbx:KeyNo % 2 == 0, nRGB(242,247,252),nRGB(226,226,208) )}) }
Return(NIL)
 
Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 492
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador

Re: Columnas Xbrowse

Postby JoseLuis » Thu Aug 25, 2022 9:58 am

Muchas gracias Carlos

Funciona correctamente, aunque no entiendo mucho porqué funciona a través de una función y directamente en el bucle no.
--------------------------
Saludos

Jose Luis
JoseLuis
 
Posts: 426
Joined: Thu Oct 19, 2006 12:28 pm
Location: Toledo

Re: Columnas Xbrowse

Postby Cgallegoa » Thu Aug 25, 2022 2:26 pm

Saludos,

Carlos Gallego

*** FWH-24.07, xHarbour 1.3.1 Build 20240624, Borland C++7.70, PellesC ***
Cgallegoa
 
Posts: 492
Joined: Sun Oct 16, 2005 3:32 am
Location: Quito - Ecuador


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 34 guests