FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Xbrowse aCols -> user function
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Xbrowse aCols -> user function
Posted: Tue Feb 08, 2022 10:36 AM
Dear NAges,
when I open a Xbrowse I sent the configuration of columns sample :
Code (fw): Select all Collapse
   aCols    := { ;
        { "DESCRAGE",  "Denominazione"        ,,   200, },;
        { "IND",       "Indirizzo"            ,,   200, },;
        { "CODCATP",   "Categoria Provvigioni",,   100, }}


but we often have to change the content of the field through user functions such as the field CODCATP of the sample

WITH OBJECT oBrwAge
WITH OBJECT oBrwAge:aCols[3]
:bEditValue :={ || GiveMeProvv(oAgenti:CODCATP) }
END

since I wanted to create a Table () function to display a window of the archives for selection
so as not to change it every time can it be created in order to pass the function through aCols?

example

aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{GiveMeProvv( "CODCATP"), "Categoria Provvigioni",, 200, }}
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1487
Joined: Tue Jun 14, 2016 07:51 AM
Re: Xbrowse aCols -> user function
Posted: Tue Feb 08, 2022 01:34 PM
Maybe this can be of help. (from project Mr. Rao gave the solution)

tn := oRs:FieldPos( "T" + alltrim( Str( month(date()))) + "_1" )

Code (fw): Select all Collapse
   aVelden6 :=  { ;
    { "selection"  , "Sel"           ,nil,  25 }, ; // 1
    { "naam"       , "Naam"          ,nil, 90 , NIL}, ; // 3
    { "voornaam"   , "Voornaam"      ,nil, 90 , NIL}, ; // 4
    { "ploeg2018"  , "P2018"          ,"@!", 75, NIL}, ; // 5
    { "ploeg2017"  , "P2017"          ,"@!", 75, NIL}, ; // 5
    { "truitjesnum", "Num"          ,"999", 30 }, ;   // 16
    { "Actief"     , "Actief"        ,nil,  75 , NIL}, ; // 6
    { "Nonactief"  , "Beschikbaar"    ,"@D",  72 ,NIL},;   // 12
    { { |x| If( x == nil, oRs:FieldGet( tn ), oRs:FieldPut( tn , x ) ) },"T1","@!",  25 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+1 ), oRs:FieldPut( tn+1 , x ) ) },"T2","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+2 ), oRs:FieldPut( tn+2 , x ) ) },"T3","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+3 ), oRs:FieldPut( tn+3 , x ) ) },"T4","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+4 ), oRs:FieldPut( tn+4 , x ) ) },"T5","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+5 ), oRs:FieldPut( tn+5 , x ) ) },"T6","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+6 ), oRs:FieldPut( tn+6 , x ) ) },"T7","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+7 ), oRs:FieldPut( tn+7 , x ) ) },"T8","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+8 ), oRs:FieldPut( tn+8 , x ) ) },"T9","@!",  22 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+9 ), oRs:FieldPut( tn+9 , x ) ) },"T10","@!",  25 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+10 ), oRs:FieldPut( tn+10 , x ) ) },"MA1","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+11 ), oRs:FieldPut( tn+11 , x ) ) },"MA2","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+12 ), oRs:FieldPut( tn+12 , x ) ) },"MA3","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+13 ), oRs:FieldPut( tn+13 , x ) ) },"MA4","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+14 ), oRs:FieldPut( tn+14 , x ) ) },"MA5","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+15 ), oRs:FieldPut( tn+15 , x ) ) },"MB1","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+16 ), oRs:FieldPut( tn+16 , x ) ) },"MB2","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+17 ), oRs:FieldPut( tn+17 , x ) ) },"MB3","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+18 ), oRs:FieldPut( tn+18 , x ) ) },"MB4","@!",  30 ,2}, ; // 9  // 2 is center
    { { |x| If( x == nil, oRs:FieldGet( tn+19 ), oRs:FieldPut( tn+19 , x ) ) },"MB5","@!",  30 ,2}, ; // 9  // 2 is center
    { "opvolging"  , "Opv"           ,NIL, 30 ,NIL},;
    { "memo"       , "Memo"          ,"@!",  240 ,NIL}}

@ 0,0 XBROWSE oBrw[6] size -1,-1 PIXEL OF  oFld:aDialogs[ 6 ] font oFont ;
      DATASOURCE oRs ;
      COLUMNS aVelden6;
      AUTOSORT CELL LINES NOBORDER FOOTERS FASTEDIT
Marc Venken

Using: FWH 23.08 with Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse aCols -> user function
Posted: Tue Feb 08, 2022 03:27 PM
Code (fw): Select all Collapse
aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ "GiveMeProvv( CODCATP)", "Categoria Provvigioni",, 200, }}

This works if GiveMeProvv() is a "function" not a "static function"

If this is a static function, use

Code (fw): Select all Collapse
aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ {||GiveMeProvv( FIELD->CODCATP ) }, "Categoria Provvigioni",, 200, }}
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse aCols -> user function
Posted: Tue Feb 08, 2022 03:34 PM
Instead of
Code (fw): Select all Collapse
    { { |x| If( x == nil, oRs:FieldGet( tn+1 ), oRs:FieldPut( tn+1 , x ) ) },"T2","@!",  22 ,2}, ;

Try
Code (fw): Select all Collapse
    { oRs:FieldName( tn+1 ),"T2","@!",  22 ,2}, ;
Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Xbrowse aCols -> user function
Posted: Tue Feb 08, 2022 05:49 PM

THANKS RAO

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Xbrowse aCols -> user function
Posted: Wed Feb 16, 2022 06:04 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ "GiveMeProvv( CODCATP)", "Categoria Provvigioni",, 200, }}

This works if GiveMeProvv() is a "function" not a "static function"

If this is a static function, use

Code (fw): Select all Collapse
aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ {||GiveMeProvv( FIELD->CODCATP ) }, "Categoria Provvigioni",, 200, }}




Nages,
on another archive I have problems, I cannot Show the data
the field RataIva is of 1 CR


the Dbf





I tried with static function

local aCols := { ;
{ "CODPAG" , "Codice" ,, 40, },;
{ "DESC" , "Descrizione" ,, 120, },;
{ "TipoPagamento(SCADVIST)" , "Tipo Scadenza" ,, 120, },;
{ { ||RataIvaP(FIELD->RataIva) } , "Rata I.V.A." ,, 120, } }



Code (fw): Select all Collapse
Static Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
  local nNum:= val(ltrim(cTipo))
  local cString:= aTipo[nNum]
  return  cString


I have this result







I tried also the no Static function

local aCols := { ;
{ "CODPAG" , "Codice" ,, 40, },;
{ "DESC" , "Descrizione" ,, 120, },;
{ "TipoPagamento(SCADVIST)" , "Tipo Scadenza" ,, 120, },;
{ "RataIvaP(RATAIVA)" , "Rata I.V.A." ,, 120, }}


Code (fw): Select all Collapse
Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
  local nNum:= val(ltrim(cTipo))
  local cString:= aTipo[nNum]
  return  cString


and I have this




How I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: Xbrowse aCols -> user function
Posted: Wed Feb 16, 2022 09:48 PM
hi Silvio,
Silvio.Falconi wrote:
Code (fw): Select all Collapse
aCols    := { ;
        { "DESCRAGE",  "Denominazione"        ,,   200, },;
        { "IND",       "Indirizzo"            ,,   200, },;
        {GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}

just a Shoot into Darkness
Code (fw): Select all Collapse
        { &GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}
greeting,

Jimmy
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Xbrowse aCols -> user function
Posted: Wed Feb 16, 2022 09:56 PM

do you see the nages's message?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Xbrowse aCols -> user function
Posted: Thu Feb 17, 2022 11:09 AM
Code (fw): Select all Collapse
function xbrtest05()

   local oDlg, oBrw, aCols

   aCols := ;
      {  { "FIRST",  "Name" } ;
      ,  { "RataIvaP(CITY)" , "Rata I.V.A.",,120  } ;
      }

   USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS aCols ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
//  local nNum:= val(ltrim(cTipo))
  local nNum := ( ASC( cTipo ) % 4 ) + 1
  local cString:= aTipo[nNum]
  return  cString


Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Xbrowse aCols -> user function
Posted: Thu Feb 17, 2022 12:06 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
function xbrtest05()

   local oDlg, oBrw, aCols

   aCols := ;
      {  { "FIRST",  "Name" } ;
      ,  { "RataIvaP(CITY)" , "Rata I.V.A.",,120  } ;
      }

   USE CUSTOMER NEW ALIAS "CUST" SHARED VIA "DBFCDX"

   DEFINE DIALOG oDlg SIZE 500,400 PIXEL TRUEPIXEL
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE "CUST" ;
      COLUMNS aCols ;
      CELL LINES NOBORDER

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED

return nil

Function RataIvap(cTipo)
  local aTipo:={"Divisa su rate","Tutto su prima rata","Tutto su ultima rata","La prima è solo I.v.a." }
//  local nNum:= val(ltrim(cTipo))
  local nNum := ( ASC( cTipo ) % 4 ) + 1
  local cString:= aTipo[nNum]
  return  cString





Nages,
Strange but I not understood why of a comma , { "RataIvaP(CITY)" , "Rata I.V.A.",,120 } ;

aCols := ;
{ { "FIRST", "Name" } ;
, { "RataIvaP(CITY)" , "Rata I.V.A.",,120 } ;
}
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Xbrowse aCols -> user function
Posted: Thu Feb 17, 2022 01:04 PM

I found the error
When the field is empty give me zero

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com

Continue the discussion