In Listbox, I can call user defined function like Get_name( field->Customer_code ).
How to do similar thing in XBrowse? like COLUMNS "DOC_DATE", "Get_name( Customer_code )", but it does not work
Thanks in advance.
How to use user defined function in XBrowse?
-
- Posts: 1033
- Joined: Fri Oct 07, 2005 3:33 pm
- Location: Cochabamba - Bolivia
Re: How to use user defined function in XBrowse?
Hola,
try to use code block COLUMNS "DOC_DATE", {|| Get_name( Customer_code ) }
regards
Marcelo
try to use code block COLUMNS "DOC_DATE", {|| Get_name( Customer_code ) }
regards
Marcelo
Re: How to use user defined function in XBrowse?
Thanks for your reply. But it does not work.
XBrowse can call build-in function like "DOW(DOC_DATE)", but I do not know how to call my user defined function.
XBrowse can call build-in function like "DOW(DOC_DATE)", but I do not know how to call my user defined function.
Marcelo Via Giglio wrote:Hola,
try to use code block COLUMNS "DOC_DATE", {|| Get_name( Customer_code ) }
regards
Marcelo
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to use user defined function in XBrowse?
Code: Select all
COLUMNS "DOC_DATE", "Get_name( Customer_code )"
Code: Select all
COLUMNS "DOC_DATE", {|| Get_name( Customer_code ) }
Please make sure that the function itself is working correctly and that XBrowse knows the values of parameters used.
This is a test program:
Code: Select all
#include "fivewin.ch"
static aStates
function Main()
USE STATES SHARED
aStates := FW_DbfToArray()
CLOSE STATES
USE CUSTOMER NEW SHARED
XBROWSER "CUSTOMER" COLUMNS "State", "StateName(STATE)", { || StateName(FIELD->STATE) } ;
SETUP oBrw:cHeaders := { "State", "Name1", "Name2" }
return nil
function StateName( cCode )
local nAt := AScan( aStates, { |a| a[ 1 ] == cCode } )
return If( nAt == 0, Space( 20 ), aStates[ nAt, 2 ] )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: How to use user defined function in XBrowse?
Mr Rao,
Thanks for your suggestion. But it still not work in Code Block.
Please notice that I use XBrowse, not XBrowser.
From wiki.fivetechsoft.com, I find the following explanation:
========================================
Difference between COLUMNS and FIELDS
COLUMNS CLAUSE is a list of column names of the Alias assigned to the browse. FIELDS clause is for any expressions. FIELDS clause is to be used for data from other related Aliases or any complext expressions.
When both COLUMNS and FIELDS clauses are speicified, XBrowse places the columns first and then the fields. We can later rearrange the sequence of xbrowse columns.
========================================
I have used FIELDS but still failed to call my functions.
Thanks & Regards.
Thanks for your suggestion. But it still not work in Code Block.
Please notice that I use XBrowse, not XBrowser.
From wiki.fivetechsoft.com, I find the following explanation:
========================================
Difference between COLUMNS and FIELDS
COLUMNS CLAUSE is a list of column names of the Alias assigned to the browse. FIELDS clause is for any expressions. FIELDS clause is to be used for data from other related Aliases or any complext expressions.
When both COLUMNS and FIELDS clauses are speicified, XBrowse places the columns first and then the fields. We can later rearrange the sequence of xbrowse columns.
========================================
I have used FIELDS but still failed to call my functions.
Thanks & Regards.
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: How to use user defined function in XBrowse?
[quote]
Please notice that I use XBrowse, not XBrowser.
[/code]
I posted the sample using XBrowser, because I know for sure that the behavour is the same whether it is xbrowse or xbrowser.
Please let us know:
1) What is the version of FWH you are using. If your version is not too old, whatever I said above SHOULD work.
2) Did you build and test the sample I posted above? Does the sample as it is work for you or not? Please test and let us know first. Then we can advise you better.
Please copy the sample to \fwh\samples folder and build it with buildh.bat or buildx.bat
Please notice that I use XBrowse, not XBrowser.
[/code]
I posted the sample using XBrowser, because I know for sure that the behavour is the same whether it is xbrowse or xbrowser.
Please let us know:
1) What is the version of FWH you are using. If your version is not too old, whatever I said above SHOULD work.
2) Did you build and test the sample I posted above? Does the sample as it is work for you or not? Please test and let us know first. Then we can advise you better.
Please copy the sample to \fwh\samples folder and build it with buildh.bat or buildx.bat
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: How to use user defined function in XBrowse?
I found the solution. The Code Block syntax is correct.
But since I use TDatabase to open DBF, the syntax is {|| Get_name( odbf:Customer_code ) }, instead of using "FIELD->".
But since I use TDatabase to open DBF, the syntax is {|| Get_name( odbf:Customer_code ) }, instead of using "FIELD->".