Xbrowse aCols -> user function

Xbrowse aCols -> user function

Postby Silvio.Falconi » Tue Feb 08, 2022 10:36 am

Dear NAges,
when I open a Xbrowse I sent the configuration of columns sample :
Code: Select all  Expand view

   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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse aCols -> user function

Postby Marc Venken » Tue Feb 08, 2022 1: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: Select all  Expand view

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

Re: Xbrowse aCols -> user function

Postby nageswaragunupudi » Tue Feb 08, 2022 3:27 pm

Code: Select all  Expand view
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: Select all  Expand view
aCols := { ;
{ "DESCRAGE", "Denominazione" ,, 200, },;
{ "IND", "Indirizzo" ,, 200, },;
{ {||GiveMeProvv( FIELD->CODCATP ) }, "Categoria Provvigioni",, 200, }}
 
Regards

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

Re: Xbrowse aCols -> user function

Postby nageswaragunupudi » Tue Feb 08, 2022 3:34 pm

Instead of
Code: Select all  Expand view
   { { |x| If( x == nil, oRs:FieldGet( tn+1 ), oRs:FieldPut( tn+1 , x ) ) },"T2","@!",  22 ,2}, ;

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

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

Re: Xbrowse aCols -> user function

Postby Silvio.Falconi » Tue Feb 08, 2022 5:49 pm

THANKS RAO
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse aCols -> user function

Postby Silvio.Falconi » Wed Feb 16, 2022 6:04 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
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: Select all  Expand view
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
Image




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: Select all  Expand view

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

Image





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: Select all  Expand view
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

Image


How I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse aCols -> user function

Postby Jimmy » Wed Feb 16, 2022 9:48 pm

hi Silvio,
Silvio.Falconi wrote:
Code: Select all  Expand view

aCols    := { ;
        { "DESCRAGE",  "Denominazione"        ,,   200, },;
        { "IND",       "Indirizzo"            ,,   200, },;
        {GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}

just a Shoot into Darkness
Code: Select all  Expand view
       { &GiveMeProvv( "CODCATP"),   "Categoria Provvigioni",,   200, }}
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1586
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Xbrowse aCols -> user function

Postby Silvio.Falconi » Wed Feb 16, 2022 9: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse aCols -> user function

Postby nageswaragunupudi » Thu Feb 17, 2022 11:09 am

Code: Select all  Expand view
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
 


Image
Regards

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

Re: Xbrowse aCols -> user function

Postby Silvio.Falconi » Thu Feb 17, 2022 12:06 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
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
 


Image



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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm

Re: Xbrowse aCols -> user function

Postby Silvio.Falconi » Thu Feb 17, 2022 1: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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6772
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

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