by frose » Thu Oct 13, 2011 12:21 pm
James,
thank you for your tip.
After some tries it works even with detached LOCAL's, by omitting the parameter(s) in the RETURN statement:
- Code: Select all Expand view
FUNCTION Main()
LOCAL oDlg
LOCAL oGet1
LOCAL oGet2
LOCAL cInfo1 := [This is the first codeblock!]
LOCAL cInfo2 := [This is the second codeblock!]
LOCAL cCodeBlock1 := "{ | cInfo1 | MsgInfo( cInfo1 ) }"
LOCAL cCodeBlock2 := "{ | cInfo2 | MsgInfo( cInfo2 ) }"
DEFINE DIALOG oDlg size 400, 400 TITLE "Merging two code blocks"
@ 1, 2 SAY "Codeblock 1:" OF oDlg
@ 1, 6 GET oGet1 VAR cCodeblock1 OF oDlg SIZE 120, 10
@ 2, 2 SAY "Codeblock 2:" OF oDlg
@ 2, 6 GET oGet2 VAR cCodeblock2 OF oDlg SIZE 120, 10
@ 3, 2 BUTTON "&End" SIZE 30, 12 OF oDlg ACTION oDlg:End() CANCEL
@ 3, 08 BUTTON "&Eval 1" OF oDlg SIZE 30, 12 ACTION Eval( Detached_Local( &( cCodeblock1 ), cInfo1 ) )
@ 3, 14 BUTTON "&Eval 2" OF oDlg SIZE 30, 12 ACTION Eval( Detached_Local( &( cCodeblock2 ), cInfo2 ) )
@ 3, 20 BUTTON "&Eval 1+2" OF oDlg SIZE 30, 12 ACTION Eval( Codeblock_Merge( &( cCodeblock1 ), &( cCodeblock2 ), cInfo1, cInfo2 ) )
ACTIVATE DIALOG oDlg
RETURN NIL
FUNCTION Detached_Local( bCodeblock, cInfo )
RETURN { || Eval( bCodeblock, cInfo ) }
FUNCTION Codeblock_Merge( bCodeblock1, bCodeblock2, cInfo1, cInfo2 )
RETURN { || Eval( bCodeblock1, cInfo1 ), Eval( bCodeblock2, cInfo2 ) }
Now there is still some work to be done to make it more generic, but the basic problem is solved
Windows 11 Pro 22H2 22621.1848
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Harbour 3.2.0dev (r2008190002)
FWH 23.10 x86