FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Column Function in XBROWSE
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Column Function in XBROWSE
Posted: Thu Oct 12, 2017 03:45 PM
hi to all,
I would Like a column in XBROWSE with result of function:
Code (fw): Select all Collapse
...
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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Column Function in XBROWSE
Posted: Thu Oct 12, 2017 05:28 PM

Try removing the single quotes around the function.

EMG

Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 07: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 (fw): Select all Collapse
...
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 (fw): Select all Collapse
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 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 07:48 AM

Sorry, let's wait for Rao advice.

EMG

Posts: 300
Joined: Wed Jul 11, 2007 11:06 AM
Re: Column Function in XBROWSE
Posted: 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 .

Posts: 1088
Joined: Fri Oct 07, 2005 03:33 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 01:13 PM
Hola,

try to use a codeblock

Code (fw): Select all Collapse
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
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 01: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

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 02:04 PM

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

Regards



G. N. Rao.

Hyderabad, India
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 02:37 PM

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

why in a XBROWSE 'dAAAAMMGGadata(DATA)' works and 'MYFUNCTION(DATA1)' no ?

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 02: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
Posts: 434
Joined: Wed Jun 06, 2007 02:58 PM
Re: Column Function in XBROWSE
Posted: Fri Oct 13, 2017 03:04 PM

thank you Mr Rao

FiveWin for xHarbour 24.02 - Feb. 2024 - Embarcadero C++ 7.60 for Win32 Copyright (c) 1993-2023

FWH 64 for Harbour 19.06 (MSVC++) Jun. 2019 - Harbour 3.2.0dev (r1904111533)

Visual Studio 2019 - Pelles C V.8.00.60 (Win64)

Continue the discussion