Column Function in XBROWSE

Post Reply
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Column Function in XBROWSE

Post by damianodec »

hi to all,
I would Like a column in XBROWSE with result of function:

Code: Select all

...
oRs := FW_OpenRecordSet( oCn, tuple, 1 )
@ 40,10 XBROWSE oBrw SIZE -10,-50 PIXEL ;
RECORDSET oRs ;
      COLUMNS "ONE", "TWO", "A", "B",  'MYFUNCTION(fieldC)' ;
      OF oDlg2  
....

FUNCTION MYFUNCTION(fieldC)
local x = 0
x = fieldc * x
return x
 
but in xbrowse I get costant MYFUNCTION(fieldC) in fifth column instead of x value.

any help?
thank you
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Column Function in XBROWSE

Post by damianodec »

hi Enrico, thank you for your help but if I remove single quote xbrowse goes in myfunction only one time.
I changed my prg:

Code: Select all

...
oYORD := FW_OpenRecordSet( oCn, tuple, 1 )
oYORD:MoveFirst()

DEFINE DIALOG oDlg2 SIZE 800,500 PIXEL  FONT oFont;
STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
              WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME ) ;
              TITLE "ANALISI IMPLOSIONE: "+m_get[02]

@ 40,10 XBROWSE oBrw SIZE -10,-50 PIXEL ;
     RECORDSET oYord ;
  COLUMNS "LEVEL", "FIELD1", "FIELD2", "TIPO", "TIME", "PROGR", MRP00421(oYORD:Fields("FIELD1"):value,oCn) ;
  HEADERS "LIV", "BASE", "APERTO", "TIPO", "LEAD", "PROGR", "IN ORDINE" ;
  PICTURE "@ZE 999",,,,"@ZE 999", "@ZE 999" ;
  OF oDlg2 
...
Return NIL

*-----------------------------------------------------------------------------------
FUNCTION MRP00421(field, oCn)
local tuple, oRs
local totale := 0

msginfo(Field)

    tuple := +;
    "SELECT a.Totale as Totale..." +;
       etc...etc...etc...
    "WHERE ARTICOLO = '"+FIELD+"' AND WORKIT = 8 "
       etc... etc...

oRs := FW_OpenRecordSet( oCn, tuple, 1 )

if oRs:EOF()
    totale = 0.00
else
    oRs:MoveFirst()
    totale = oRs:Fields("Totale"):value
    msginfo(str(totale))
endif

oRs:Close()

Return Str(Totale)
 
I put MSGINFO into FUNCTION MRP00421 for check FIELD and it shows me msginfo only one time with NULL field.
the original RECORDSET oYord in XBROWSE had 25 rows and MRP00421 function should return calculate TOTALE (in another SELECT) for each row.
but COLUMN "IN ORDINE" in XBROWSE retrun 0,00 in each row

I have another my XBROWSE:

Code: Select all

DEFINE DIALOG oDlg2 SIZE 800,500 PIXEL  FONT oFont;
    STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
              WS_MAXIMIZEBOX, WS_MINIMIZEBOX, WS_THICKFRAME ) ;
              TITLE "SCHEDA MOVIMENTI DI ACQUISTO FORNITORE: "+CDFOR

    @ 40,10 XBROWSE oBrw SIZE -10,-50 PIXEL ;
      RECORDSET oRsMovimenti ;
      COLUMNS 'dAAAAMMGGadata(DATA)',"CODICE","DESCR","RIFER","QTA","IMPORT","COSTO" ;
      HEADERS "DATA","CODICE","DESCRIZIONE","RIFERIM.","QUANTITA","IMPORTO","COSTO" ;
      PICTURE ,,,,"@ZE 99,999,999.999", "@ZE 99,999,999.999", "@ZE 99,999,999.999" ;
in this XBROWSE there is dAAAAMMGGadata FUNCTION whit single quotes that convert field DATA from YYYYMMDD to DD/MM/YYYY and it works for each row in oRsMovimenti

thank you
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Jack
Posts: 249
Joined: Wed Jul 11, 2007 11:06 am

Re: Column Function in XBROWSE

Post by Jack »

Hi ,
When i have to do that, i insert a column and use a code block with my function :

oCol:=oLbxp:inscol(4)
oCol:bStrData:={||QSTOCK(oRsp:Fields("NB"):Value)}
oCol:cHeader:="Total"
*

*
function QSTOCK(p)
return p/2


Philippe .
Marcelo Via Giglio
Posts: 1033
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Column Function in XBROWSE

Post by Marcelo Via Giglio »

Hola,

try to use a codeblock

Code: Select all

oRs := FW_OpenRecordSet( oCn, tuple, 1 )
@ 40,10 XBROWSE oBrw SIZE -10,-50 PIXEL ;
RECORDSET oRs ;
      COLUMNS "ONE", "TWO", "A", "B",  {|| MYFUNCTION(fieldC)} ;
      OF oDlg2  
....

FUNCTION MYFUNCTION(fieldC)
local x = 0
x = fieldc * x
return x
But here we have a performance problem, because xBrowse repaint many time all the data

Regards

Marcelo
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Column Function in XBROWSE

Post by damianodec »

hi thank you for your help
If I use codeblock, performance is very very slow.

I do not understand because If I use function 'dAAAAMMGGadata(DATA)' that works and with 'MRP00421(oYORD:Fields("FIELD1"):value,oCn)' not works
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Column Function in XBROWSE

Post by nageswaragunupudi »

COLUMNS "ONE", "TWO", "A", "B", { || MYFUNCTION(fieldC) } ;
Regards

G. N. Rao.
Hyderabad, India
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Column Function in XBROWSE

Post by damianodec »

thank you Mr.Rao
but is very slowly with codeblock.

why in a XBROWSE 'dAAAAMMGGadata(DATA)' works and 'MYFUNCTION(DATA1)' no ?
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
User avatar
nageswaragunupudi
Posts: 8017
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Contact:

Re: Column Function in XBROWSE

Post by nageswaragunupudi »

Speed depends purely on the implementation of the function.
why in a XBROWSE 'dAAAAMMGGadata(DATA)' works and 'MYFUNCTION(DATA1)' no ?
If the function is a public function ( i.e., not a static function ) and all parameters are either public/private or field variables, "MYFUNCTION(PARAMETERS)" works. In other words, XBrowse should be able to call the function with the parameters from inside xbrowse.

Otherwise, you need to use it as codeblock.
Regards

G. N. Rao.
Hyderabad, India
User avatar
damianodec
Posts: 372
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia
Contact:

Re: Column Function in XBROWSE

Post by damianodec »

thank you Mr Rao
FiveWin for xHarbour 17.09 - Sep. 2017 - Embarcadero C++ 7.00 for Win32
FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)
Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Post Reply