Mr. Rao, more about xBrowse

Mr. Rao, more about xBrowse

Postby Armando » Mon Aug 21, 2023 4: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: Select all  Expand view

            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
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, more about xBrowse

Postby cmsoft » Mon Aug 21, 2023 7:20 pm

Podria ser algo asi:
Code: Select all  Expand view

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
User avatar
cmsoft
 
Posts: 1285
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Mr. Rao, more about xBrowse

Postby Armando » Mon Aug 21, 2023 8: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
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, more about xBrowse

Postby cmsoft » Mon Aug 21, 2023 10:17 pm

Fijate si algo asi es la idea
Tenias razon, lo otro daba error
Code: Select all  Expand view
#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.
User avatar
cmsoft
 
Posts: 1285
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Mr. Rao, more about xBrowse

Postby Armando » 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
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, more about xBrowse

Postby nageswaragunupudi » Tue Aug 22, 2023 12:40 am

cmsoft wrote:Podria ser algo asi:
Code: Select all  Expand view

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: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao, more about xBrowse

Postby Armando » Tue Aug 22, 2023 1: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
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, more about xBrowse

Postby cmsoft » 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!!
User avatar
cmsoft
 
Posts: 1285
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Mr. Rao, more about xBrowse

Postby nageswaragunupudi » Tue Aug 22, 2023 8: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: Select all  Expand view
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: Select all  Expand view
oBrw:datas := { a, b, c, .... }


Examples:
Code: Select all  Expand view
oBrw:nEditTypes := EDIT_GET
oBrw:cSortOrders := { "ID","FIRST","LAST", ... }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Mr. Rao, more about xBrowse

Postby Armando » Tue Aug 22, 2023 9: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
User avatar
Armando
 
Posts: 3201
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Mr. Rao, more about xBrowse

Postby Marc Venken » Wed Aug 23, 2023 7:14 am

nageswaragunupudi wrote:
cmsoft 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.04 with Harbour
User avatar
Marc Venken
 
Posts: 1425
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Mr. Rao, more about xBrowse

Postby nageswaragunupudi » Wed Aug 23, 2023 7: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 35 guests