RSS

 
WinEdt Macro Library  | macro previous macro 

makeMUI

Description

This macro generates WinEdt macro code to call the MUI plug-in. Thus, it facilitates the creation of advanced dialogs a lot for macro writers. Note, however, that this macro creates code for the old, external MUI plug-in, not the new one that is built into WinEdt since version 5.5. If you intend to create an interface for WinEdt 5.5 or later, you should consider employing the new plug-in instead, even if cannot use this macro then.

The MUI plug-in is a great application to generate user friendly dialogs. However, to the macro writer, it is less friendly. If you've once tried it, you'll know that writing the underlying macro code is tiresome and error-prone. This macro tool facilitates macro programming for the MUI plug-in. It will generate all the code you would otherwise write yourself -- including register releases before, and the framework for evaluating the user's choices after running the MUI plug-in.

So, instead of programming in WinEdt's macro language, where you have to take care that you don't mix up delimiter levels, that you don't forget to release any registers before running the MUI plug-in, and where you have to double-check, when testing for a variable, that you take exactly the same option name as you chose in the MUI macro; -- instead of all this hassle, all you have to know now are some abbreviations (e.g. "C" for a Combo box), and a straight-forward syntax. You can concentrate on the contents of the MUI dialog, and don't have to bother about technicalities.

You'd write something like the following:

// this is the output file, i.e. the MUI input _F_ile:
F %b\Macros\macro\makeMUItest.mui
// This is the caption (_T_itle) of the MUI window:
T Global Options:
// This is its _W_idth:
W 300
// First, we write a _L_abel:
L These are the class options:
// This is a _C_ombo box called "Paper Size" (a4paper will be pre-selected):
C Paper Size
  letterpaper (11 x 8.5 inches)
  legalpaper (14 x 8.5 inches)
 !a4paper (297 x 210 mm)
  a5paper (210 x 148 mm)
// a _R_adio button called "Orientation" (Portrait will be pre-selected):
R Orientation
 !Portrait
  Landscape
// a _X_eck box:
X Draft
// Finally, "--" marks the end of the MUI block.
--

Selecting this text and running makeMUI on it would transform it into the following macro code:

IfFileExists("%b\Plugins\MUI\mui.exe","Assign('MUIexe','%b\Plugins\MUI\mui.exe');",>
   "IfFileExists('%B\Plugins\MUI\mui.exe','Assign(''MUIexe'',''%B\Plugins\MUI\mui.exe'');',>
       'Prompt(''You do not have the MUI plug-in installed!%\Please get it from www.winedt.org.'',3,1);Exit;');");
Assign("MUIOK","0");
Release(`MUICheckBox1`);
Release(`MUIRadioButton1`);
Release(`MUIComboBox1`);
// This is the output file, i.e. the MUI input _F_ile:
OpenOutput(`%b\Macros\macro\makeMUItest.mui`);
// This is the caption (_T_itle) of the MUI window:
WrL(`MUITitle("Global Options:");`);
// This is its _W_idth:
WrL(`MUIWidth("300");`);
// First, we write a _L_abel:
WrL(`MUILabel("These are the class options:");`);
// This is a _C_ombo box called "Paper Size" (a4paper will be pre-selected):
WrL(`MUILabel("Papersize");`);
WrL(`MUIComboBox("letterpaper (11 x 8.5 inches)|legalpaper (14 x 8.5 inches)|>
a4paper (297 x 210 mm)|a5paper (210 x 148 mm)",3);`);
// a _R_adio button called "Orientation" (Portrait will be pre-selected):
WrL(`MUIRadioButton("portrait|landscape",1,"Orientation");`);
// a _X_eck box:
WrL(`MUICheckBox("Draft");`);
// Finally, "--" marks the end of the MUI block.
CloseOutput;
WinExe(``,`%$("MUIexe"); "%b\Macros\macro\makeMUItest.mui"`,`%p`,``,000100);
IfNum("%$('MUIOK');",0,"=","Exit;");
// => Orientation
IfStr(`%$("MUIRadioButton1");`,`Portrait`,`=`,>
   `*`);
IfStr(`%$("MUIRadioButton1");`,`Landscape`,`=`,>
   `*`);
// => Papersize
IfStr(`%$("MUIComboBox1");`,`letterpaper (11 x 8.5 inches)`,`=`,>
   `*`);
IfStr(`%$("MUIComboBox1");`,`legalpaper (14 x 8.5 inches)`,`=`,>
   `*`);
IfStr(`%$("MUIComboBox1");`,`a4paper (297 x 210 mm)`,`=`,>
   `*`);
IfStr(`%$("MUIComboBox1");`,`a5paper (210 x 148 mm)`,`=`,>
   `*`);
IfStr(`%$("MUICheckBox1");`,1,`=`, // => Draft <>
   `*`,`*`);

The complete list of abbreviations can be found at the end of the macro file.

Options

  • You can change the two delimiters that should be used when generating the code
  • It is possible to append all lines with the concatenation character ">" (e.g., when you want to use the generated code inside a loop)

Installation

Put the macro in %b\Macros\macro\, and assign a shortcut to it if you want.

Download

macro/makeMUI.edt

Macro contributed by Robert <w.m.lgmx.net>

WinEdt Macro Library  | macro previous macro