Hi everybody,
maybe my question will cause a LoL, but i'll try it nevertheless:
#include "dcdialog.ch"
proc main()
local cvar1,cvar2
cvar1="text function"
cvar2="text udf"
@ 1,1 DCSAY "text 1" get cvar1
x={||test2()}
DCREAD GUI
return
function test2
@ 2,1 DCSAY cvar2
return .t.
Is there any way to show these two textes in the same window?
merging a DCSAY from a codeblock in a gui-Window
- obelix
- Posts: 48
- Joined: Tue Dec 03, 2013 7:44 am
- Location: Villingen-Schwenningen, Black Forest, Germany
merging a DCSAY from a codeblock in a gui-Window
quiet old but still young and unskilled in express++
Re: merging a DCSAY from a codeblock in a gui-Window
The answer is YES, but I don't understand what you are trying to do.
The eXpress train is coming - and it has more cars.
- obelix
- Posts: 48
- Joined: Tue Dec 03, 2013 7:44 am
- Location: Villingen-Schwenningen, Black Forest, Germany
Re: merging a DCSAY from a codeblock in a gui-Window
hi Roger,
I want to use the same headline in different windows. For being able to change the look or the behavior of the dcsay-Statements easily it would be helpful to
put it into a function, but when I display the window, the elements of the function are not shown.
//insted of:
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE wcol,wrow OBJECT oStatic1
* used in many windows
@ 2,5 dcsay w_rahmtext1 SAYFONT textfont1
@ 3,5 dcsay w_rahmtext2 SAYFONT textfont1
@ frow,fcol dcsay wnr SAYFONT textfont1
@ 4,2 DCSAY repl("_",wcol-2) SAYCOLOR color1,color2 SAYFONT textfont1
* end
@ 6.2 DCSAY ....
//I would prefer:
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE wcol,wrow OBJECT oStatic1
headlines(w_rahmtext1,w_rahmtext2,wnr)
@ 6.2 DCSAY ....
function headlines
parameters w_rahmtext1,w_rahmtext2,wnr
* used in many windows
@ 2,5 dcsay w_rahmtext1 SAYFONT textfont1
@ 3,5 dcsay w_rahmtext2 SAYFONT textfont1
@ frow,fcol dcsay wnr SAYFONT textfont1
@ 4,2 DCSAY repl("_",wcol-2) SAYCOLOR color1,color2 SAYFONT textfont1
* end
I want to use the same headline in different windows. For being able to change the look or the behavior of the dcsay-Statements easily it would be helpful to
put it into a function, but when I display the window, the elements of the function are not shown.
//insted of:
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE wcol,wrow OBJECT oStatic1
* used in many windows
@ 2,5 dcsay w_rahmtext1 SAYFONT textfont1
@ 3,5 dcsay w_rahmtext2 SAYFONT textfont1
@ frow,fcol dcsay wnr SAYFONT textfont1
@ 4,2 DCSAY repl("_",wcol-2) SAYCOLOR color1,color2 SAYFONT textfont1
* end
@ 6.2 DCSAY ....
//I would prefer:
@ 0,0 DCSTATIC TYPE XBPSTATIC_TYPE_TEXT SIZE wcol,wrow OBJECT oStatic1
headlines(w_rahmtext1,w_rahmtext2,wnr)
@ 6.2 DCSAY ....
function headlines
parameters w_rahmtext1,w_rahmtext2,wnr
* used in many windows
@ 2,5 dcsay w_rahmtext1 SAYFONT textfont1
@ 3,5 dcsay w_rahmtext2 SAYFONT textfont1
@ frow,fcol dcsay wnr SAYFONT textfont1
@ 4,2 DCSAY repl("_",wcol-2) SAYCOLOR color1,color2 SAYFONT textfont1
* end
quiet old but still young and unskilled in express++
Re: merging a DCSAY from a codeblock in a gui-Window
Put your SAY text into a Code block.
Code: Select all
@ 2,2 DCSAY {||HeadLine()} SAYSIZE 20
DCREAD GUI
FUNCTION HeadLine()
RETURN 'This is my head line'
The eXpress train is coming - and it has more cars.
Re: merging a DCSAY from a codeblock in a gui-Window
This will not return what Obelix wants.Put your SAY text into a Code block.
The best way to do this would be to use the preprocessor:
Code: Select all
#include 'dcdialog.ch'
#command HEADLINES <nStartLine>,<cHeadLine1>,<cHeadLine2>,<cFont> ;
=> @ <nStartLine>,5 DCSAY <cHeadLine1> SAYFONT <cFont> ;;
@ <nStartLine>+1,5 DCSAY <cHeadLine2> SAYFONT <cFont>
#pragma library("dclipx.lib")
FUNCTION Main()
HEADLINES 2.5,'Hallo','Welt','12.Tahoma'
@ 6,1 DCPUSHBUTTON CAPTION 'Test' SIZE 10,1 ACTION {||MsgBox('Test')}
DCREAD GUI FIT ADDBUTTONS
RETURN nil
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
- obelix
- Posts: 48
- Joined: Tue Dec 03, 2013 7:44 am
- Location: Villingen-Schwenningen, Black Forest, Germany
Re: merging a DCSAY from a codeblock in a gui-Window
Thank you Tom, that's what I looked for, a little bit compicated but really helpful.
Rogers suggestion (codeblock) didn't work.
Rogers suggestion (codeblock) didn't work.
quiet old but still young and unskilled in express++
Re: merging a DCSAY from a codeblock in a gui-Window
Great!
It's not very complicated. The #command-directive forces the preprocessor to replace the command ("HEADLINES") with the code behind the "=>", using the parameters declared. This is no magic. The PP looks for matching code and replaces it with what you tell to replace. A #define-directive does nothing else then to replace every matching text inside the code with the value declared:
This translates the code into 'IF cPassWord == "MyMasterPassword"' before it's going to be compiled. It's like you're running a "Search&Replace" in your source code editor. Same with #command.
If you use the code I posted, remember that you now are able to change your "HEADLINES" code only once to create an effect for your whole app, but it does not force PBUILD to recompile every PRG effected. You may use PBUILD /all if you change it. Place the code in a .CH-file included in all PRGs which use it.
The preprocessor is a very powerful instrument. At least, eXpress++ is a proof for this, since the usage of PP-functionalities are the core of it.

It's not very complicated. The #command-directive forces the preprocessor to replace the command ("HEADLINES") with the code behind the "=>", using the parameters declared. This is no magic. The PP looks for matching code and replaces it with what you tell to replace. A #define-directive does nothing else then to replace every matching text inside the code with the value declared:
Code: Select all
#define MASTERPASSWORD "MyMasterPassword"
...
IF cPassWord == MASTERPASSWORD
...
If you use the code I posted, remember that you now are able to change your "HEADLINES" code only once to create an effect for your whole app, but it does not force PBUILD to recompile every PRG effected. You may use PBUILD /all if you change it. Place the code in a .CH-file included in all PRGs which use it.
The preprocessor is a very powerful instrument. At least, eXpress++ is a proof for this, since the usage of PP-functionalities are the core of it.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
- obelix
- Posts: 48
- Joined: Tue Dec 03, 2013 7:44 am
- Location: Villingen-Schwenningen, Black Forest, Germany
Re: merging a DCSAY from a codeblock in a gui-Window
Thank you, Tom for the explanation. It really works good (after having found out
that the #pp-commands are case sensitive !)
that the #pp-commands are case sensitive !)
quiet old but still young and unskilled in express++
Re: merging a DCSAY from a codeblock in a gui-Window
Ok, try this:
Not sure what you want, but you can refresh cVar2, and call Dc_Getrefresh(Getlist,.....)
Jack Duijf
Code: Select all
Procedure Main()
LOCAL cVar1,cVar2, x
LOCAL GetList := {}
cVar1 := "text function"
cVar2 := "text udf"
@ 1,1 DCSAY "text 1" get cVar1
If .T. // Same result
x={||Test2(GetList,cVar2)}
Eval(x)
Else
Test2(GetList,cVar2)
Endif
DCREAD GUI
return
Function test2(GetList,cVar2)
@ 2,1 DCSAY {||cVar2}
return .t.
Jack Duijf
Regards,
Jack Duijf
Jack Duijf