Column Function in XBROWSE

Column Function in XBROWSE

Postby damianodec » Thu Oct 12, 2017 3:45 pm

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

...
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
ciao
Damiano
User avatar
damianodec
 
Posts: 203
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: Column Function in XBROWSE

Postby Enrico Maria Giordano » Thu Oct 12, 2017 5:28 pm

Try removing the single quotes around the function.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 6528
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Column Function in XBROWSE

Postby damianodec » Fri Oct 13, 2017 7:00 am

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  Expand view

...
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  Expand view

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
ciao
Damiano
User avatar
damianodec
 
Posts: 203
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Re: Column Function in XBROWSE

Postby Jack » Fri Oct 13, 2017 10:47 am

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 .
Jack
 
Posts: 178
Joined: Wed Jul 11, 2007 11:06 am

Re: Column Function in XBROWSE

Postby Marcelo Via Giglio » Fri Oct 13, 2017 1:13 pm

Hola,

try to use a codeblock

Code: Select all  Expand view
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
Marcelo Via Giglio
 
Posts: 976
Joined: Fri Oct 07, 2005 3:33 pm
Location: Cochabamba - Bolivia

Re: Column Function in XBROWSE

Postby damianodec » Fri Oct 13, 2017 1:43 pm

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
ciao
Damiano
User avatar
damianodec
 
Posts: 203
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: Column Function in XBROWSE

Postby nageswaragunupudi » Fri Oct 13, 2017 2:04 pm

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

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

Re: Column Function in XBROWSE

Postby damianodec » Fri Oct 13, 2017 2:37 pm

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

why in a XBROWSE 'dAAAAMMGGadata(DATA)' works and 'MYFUNCTION(DATA1)' no ?
ciao
Damiano
User avatar
damianodec
 
Posts: 203
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia

Re: Column Function in XBROWSE

Postby nageswaragunupudi » Fri Oct 13, 2017 2:56 pm

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
nageswaragunupudi
 
Posts: 5329
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Column Function in XBROWSE

Postby damianodec » Fri Oct 13, 2017 3:04 pm

thank you Mr Rao
ciao
Damiano
User avatar
damianodec
 
Posts: 203
Joined: Wed Jun 06, 2007 2:58 pm
Location: Italia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 5 guests