just started to work with XBROWSE, running into probs when adding new columns:
These lines are NOT functional:
- ADD TO oBrw DATA bBlock HEADER "City bBlock" CARGO { 1, 2 }
- oBrw:AddColumn( OemToAnsi("City CB*"), bBlock,,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
- oBrw:AddColumn( OemToAnsi("City CB*"), Get_Block( cBlock, cAlias ),,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
Why?
This is functional:
- oBrw:AddColumn( OemToAnsi("City CB*"), Format_Block( cBlock, cAlias ),,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
Here is the sample code:
- Code: Select all Expand view
- STATIC FUNCTION My_Browse()
LOCAL oWnd
LOCAL oBrw
LOCAL oCol
//LOCAL cAlias := cGetNewAlias( "CUSTOMER" )
LOCAL cAlias := "CUSTOMER"
LOCAL n
LOCAL cBlock
LOCAL bBlock
USE CUSTOMER NEW Alias ( cAlias ) SHARED VIA "DBFCDX"
Set ORDER TO TAG FIRST
GO TOP
DEFINE WINDOW ownd MDICHILD OF WndMain() TITLE "My_Browse"
@ 0, 0 XBROWSE oBrw OF ownd ALIAS cAlias
oBrw:bKeyChar := { | nKey | If( nKey == VK_ESCAPE, oWnd:End(), nKey ) }
oBrw:bClrRowFocus := oBrw:bClrSelFocus
ADD TO oBrw DATA ( cAlias )->CITY HEADER "City" CARGO { 1, 2 }
ADD TO oBrw DATA { || ( cAlias )->CITY } HEADER "City CB" CARGO { 1, 2 }
cBlock := "{ || ( cAlias )->CITY }"
bBlock := &( "{ || ( cAlias )->CITY }" )
//
// Doesn't compile, "syntax error at 'TO'"
//
//ADD TO oBrw DATA bBlock HEADER "City bBlock" CARGO { 1, 2 }
//
// Compile, but Error LEN
//
//oBrw:AddColumn( OemToAnsi("City CB*"), bBlock,,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
//
// Detached local: Error LEN
//
//oBrw:AddColumn( OemToAnsi("City CB*"), Get_Block( cBlock, cAlias ),,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
//
// This is functional
//
oBrw:AddColumn( OemToAnsi("City CB*"), Format_Block( cBlock, cAlias ),,,,,, .F., .F.,,,,,, .F.,,,,, .F.,,, { 1, 2 } )
AEval( oBrw:aCols, { | o | o:nEditType := EDIT_GET } )
//AEval( oBrw:aCols, { | o | o:bPopUp := { | o | ColMenu( o ) } } )
oBrw:CreateFromCode()
oWnd:oClient := oBrw
SET MESSAGE OF oWnd TO "RDD All Cols" 2007
ACTIVATE WINDOW oWnd ON INIT oBrw:SetFocus()
RETURN NIL
STATIC FUNCTION Get_Block( cBlock, cAlias )
RETURN &( cBlock )
STATIC FUNCTION Format_Block( cBlock, cAlias )
cBlock := StrTran( cBlock, "( cAlias )", cAlias )
cBlock := StrTran( cBlock, "cAlias", Chr( 34 ) + cAlias + Chr( 34 ) )
RETURN &( cBlock )
Ok, I can solve it with the function "Format_Block()", but that's not very smart and why it doesn't work with '&( cBlock )?