FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Mr. Rao, more about xBrowse
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Mr. Rao, more about xBrowse
Posted: Mon Aug 21, 2023 04:45 PM
Mr. Rao:

I have the following code, I need the same code for all the columns of the browse, something like :nEditTypes := 1, I know that I can repeat it as many columns as the browse has, the problem is that I don't know how many columns the browse has.
Code (fw): Select all Collapse
            WITH OBJECT :aCols[03]
               :bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
               :bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) } 
               :bEditValid := { | oGet | Valida(oGet:VarGet())}         
            END
I am building the browse with the code AUTOCOLS


Thank you for your kind help

Best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Mr. Rao, more about xBrowse
Posted: Mon Aug 21, 2023 07:20 PM
Podria ser algo asi:
Code (fw): Select all Collapse
for each oCol in :aCols
      oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
next oCol
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Mr. Rao, more about xBrowse
Posted: Mon Aug 21, 2023 08:12 PM

Cesar:

Gracias por la idea, pero me tira error, no reconoce oCol

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Mr. Rao, more about xBrowse
Posted: Mon Aug 21, 2023 10:17 PM
Fijate si algo asi es la idea
Tenias razon, lo otro daba error
Code (fw): Select all Collapse
#include "Fivewin.ch"
#include "xbrowse.ch"
static nSaldo, oSay 
FUNCTION cmsoft()
LOCAL oDlg1, oBrwTmp, aCols, oCol, nFilas := 3, nColumnas := 3, i, j 
nSaldo := 10000
MsgGet("Filas","Ingrese filas",@nFilas)
MsgGet("Columnas","Ingrese columnas",@nColumnas)
aCols := ARRAY(nFilas,nColumnas)
FOR i := 1 to nFilas 
    for j := 1 to nColumnas 
        aCols [i,j] := 0
    next j
next i
DEFINE DIALOG oDlg1 TITLE "Edicion" SIZE 700,700 PIXEL TRUEPIXEL RESIZABLE
   @ 20, 20 XBROWSE oBrwTmp SIZE -20,-20 pixel OF oDlg1 ;
      CELL LINES NOBORDER
   WITH OBJECT oBrwTmp
      :SetArray(aCols)
      AEval( :aCols, ;
         { |o| (o:bOnPreEdit := { | o, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !","Atencion"),)}), ;
               (o:bOnChange  := { | o, uOldVal| VerSaldo(uOldVal) }),;
               (o:bEditValid := { | oGet | Valida(oGet:VarGet())}),;
               (o:nEditType := EDIT_GET) })


      /*for each oCol in :aCols
            oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !","Atencion"),)}
            oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
            oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
            oCol:nEditType := EDIT_GET 
      next oCol      */
      :CreateFromCode()
   END
@ 0,0 Say "Saldo" GET oSay VAR nSaldo  PIXEL   OF oDlg1 READONLY
ACTIVATE DIALOG oDlg1 CENTERED 
RETURN nil

static function VerSaldo(n)
nSaldo := nSaldo + n
oSay:Refresh()
return nil 

static function valida(n)
IF (nSaldo - n) <= 0 
   MsgStop("El importe super el saldo")
   RETURN .f.
ENDIF 
nsaldo := nSaldo - n
oSay:Refresh()
return .t.
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Mr. Rao, more about xBrowse
Posted: Mon Aug 21, 2023 11:01 PM

César:

Gracias, pruebo y aviso.

Saludos

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao, more about xBrowse
Posted: Tue Aug 22, 2023 12:40 AM
cmsoft wrote:Podria ser algo asi:
Code (fw): Select all Collapse
for each oCol in :aCols
      oCol:bOnPreEdit := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      oCol:bOnChange  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      oCol:bEditValid := { | oGet | Valida(oGet:VarGet())}
next oCol
XBrowse provides a much easier way.
No need for using "for each oCol in :aCols" or "AEval( :aCols.", etc.
Code (fw): Select all Collapse
WITH OBJECT oBrw
      :bOnPreEdits := { | oCol, xVal, nKey | IIF(nSaldo <= 0,MsgStop("No hay más autobuses disponibles !",oApp:cAplicacion),)}
      :bOnChanges  := { | oCol, uOldVal| VerSaldo(uOldVal) }
      :bEditValids := { | oGet | Valida(oGet:VarGet())}
END
Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
Regards



G. N. Rao.

Hyderabad, India
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Mr. Rao, more about xBrowse
Posted: Tue Aug 22, 2023 01:27 AM

Mr. Rao (Master)

It works soo fine.

Thanks so much.

Best regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Mr. Rao, more about xBrowse
Posted: Tue Aug 22, 2023 12:17 PM

Muchas gracias por la aclaración, mucho mas facil así. Cada dia me sorprendo mas del poder de xbrowse!!

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao, more about xBrowse
Posted: Tue Aug 22, 2023 08:58 PM
Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
If we want to set the same value for any DATA of every column, we use
Code (fw): Select all Collapse
oBrw:datas := uValue
If we want to set different values like [ a, b, c, d, ... } to each column in the creation order we use
Code (fw): Select all Collapse
oBrw:datas := { a, b, c, .... }
Examples:
Code (fw): Select all Collapse
oBrw:nEditTypes := EDIT_GET
oBrw:cSortOrders := { "ID","FIRST","LAST", ... }
Regards



G. N. Rao.

Hyderabad, India
Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: Mr. Rao, more about xBrowse
Posted: Tue Aug 22, 2023 09:29 PM

Mr. Rao:

Thanks so much.

With best regards

SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Mr. Rao, more about xBrowse
Posted: Wed Aug 23, 2023 07:14 AM
nageswaragunupudi wrote:
Explanation:
If you want to set any data of each column (for example "nEditType" ), instead of setting oCol:nEditType of each every column, you can set oBrw:nEditTypes := n ( nEditType _+ "s" ) i.e., use "plural"
Out of interest : In the source class, i don't see these data as plural ? how does Xbrowse know them ?

like :

oBrw:nEditTypes := EDIT_GET
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Mr. Rao, more about xBrowse
Posted: Wed Aug 23, 2023 07:26 AM

XBrowse is not that simple class.

Well all this is handled in the Error Handler.

There is no DATA nEditTypes in XBrowse, so this message goes to error handler.

There it checks if there is any data of a Column class with that name without trailing "s"

If exists then the rest of the logic is simple.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion