This is a nice one! Good news: There is a solution. (But it is tricky. Easy alternative solution in the end.)
The thing is, that the macro replacement of the PRACTICE scripts work everywhere inside the actual PRACTICE code. However the dialog description is no PRACTICE code: The dialog description is just embedded inside the script. This is like embedding an image (e.g. via a data-URI) in a HTML file. The image is also not HTML.
The command to show a custom dialog is DIALOG.view <dlg-file>
. However the DIALOG.view can also be used with an embedded block (in round braces, which are in separate lines). That is what you do.
And here comes the trick: If you replace the opening brace with (&+
all words starting with &
inside the whole embedded block are replaced with a PRACTICE macro - as long as a macro with that name exist.
So here you go:
PRINT "Workspace is &WORKSPACE"
DIALOG
(&+
HEADER "&WORKSPACE"
; Large menu here...
)
Be aware that the macro replacement appears then really everywhere in the DIALOG block. This can cause unwanted side effects - especially if you have embedded PRACTICE code in your DIALOG. E.g.:
DIALOG
(
BUTTON "Push me"
(
PRIVATE &myfile
DIALOG.File.open *.txt
ENTRY %LINE &myfile
PRINT "You picked file '&myfile'"
)
)
If you enable now macro replacement for the Dialog-block it would also replace the &myfile of the PRIVATE and ENTRY command, which is usually not what you want.
However it should work if you explicitly disable macro replacement down to the PRACTICE script embedded in the DIALOG with "(&-". So you get:
DIALOG
(&+
HEADER "&WORKSPACE"
BUTTON "Push me"
(&-
PRIVATE &myfile
DIALOG.File.open *.txt
ENTRY %LINE &myfile
PRINT "You picked file '&myfile'"
)
)
Other workaround would be to define a macro &myfile which actually contains the text "&myfile":
LOCAL &WORKSPACE &myfile
&WORKSPACE="Select A Task To Run"
&myfile="&"+"myfile" // <- This is the trick!
DIALOG
(&+
HEADER "&WORKSPACE"
BUTTON "Push me"
(
PRIVATE &myfile
DIALOG.File.open *.txt
ENTRY %LINE &myfile
PRINT "You picked file '&myfile'"
)
)
If you've mastered this thing you are close to be a PRACTICE master!
Here is another more easy solution for customizing both the TEXT and HEADER of a custom dialog:
- Replace the HEADER statement inside the DIALOG description with a WinPOS command before the DIALOG command.
- Replace the TEXT statement inside the DIALOG description with DYNTEXT and set the text outside the DIALOG description with DIALOG.Set
E.g.:
PRIVATE &myheader &mytext
&myheader="Select A Task To Run"
&mytext="zaphod beeblebrox is an awesome frood"
WinPOS ,,,,,,,"&myheader"
DIALOG
(
POS 0 0 30. 1
DlgText1: DYNTEXT ""
)
DIALOG.Set DlgText1 "&mytext"
This 2nd approach simply avoids macro replacement inside the DIALOG description. So it is not an exact answer to the question, but maybe a better solution to the actual problem.