Using macros to customize application settings

As the application you create may affect standard settings on the desktop, it is a good idea to save and reset the user’s environment settings. You can include extra code in the macro to restore the original settings once the user exits the application. You can also update links to other notebooks and objects using linking parameters.

You can customize macros using self-modifying (or dynamic) macro codes. Self-modifying macros either alter all or part of the macro when playing.


To save and reset application defaults

Wordperfect Quattro Pro btnbacktotopproc Using macros to customize application settings

When you develop a Quattro Pro application, it is usually best to store the user’s environment settings.

If you create a custom application in Quattro Pro that changes a user’s environment settings, it is a good idea to include macro code that saves the user’s current settings and restores them when the user exits the application. You can save the current settings with the following macro commands:

  {LET:A1,PROPERTY("Application.Display")}   {LET:A2,PROPERTY("Application.International")}   {LET:A3,PROPERTY("Application.Macro")}   {LET:A4,PROPERTY("Application.File_Options")}   {LET:A5,PROPERTY("Application.General")}   

To change the settings, you can use macro commands like the following:

  {Application.Display "none,Yes,Yes,Yes,A..B:A1..B2,Yes,Yes,yes"}   {Application.International "$;Quattro Pro/  Windows;Prefix;Signed;Windows Default;MM/DD/YY (MM/DD);HH:MM:SS   (HH:MM);Quattro Pro;""English, North American (EN)"";No;Canada   (English)'}   {Application.File_Options "H:\;;QPW;Yes;20;No;Yes;Yes;H:\Program   Files\Corel\WordPerfect Office X5\Languages\EN\Template\Custom QP   Templates;20;No"}   {Application.Macro "Both;No;Quattro Pro - DOS;;No"}   {Application.General "Yes;No;Yes;Yes;500;No;Yes;Yes;Yes;Yes;Down"}   

Finally, to restore the settings, use these macro commands:

  {Application.Display +:A1}   {Application.International +:A2}   {Application.Macro +:A3}   {Application.File_Options +:A4}   {Application.General +:A5}   

To use the active selection within a macro

Wordperfect Quattro Pro btnbacktotopproc Using macros to customize application settings

PROPERTY(“Active_Block.Selection”) returns the address of the currently selected cells as an address and can be used within macro commands. The following macros set the print selection and create a named cell from the active cells:

  Print_Block {Print.Block PROPERTY("Active_Block.Selection")}   Name_Blk {BlockName.Create TestBlk",   PROPERTY("Active_Block.Selection")}   

To update links with macros

Wordperfect Quattro Pro btnbacktotopproc Using macros to customize application settings

To pass linking parameters such as “Open Supporting”, “Update References”, or “None”, you must spell out the entire parameter in the {FileOpen} macro command, as follows:

  {FileOpen "TEST.QPW, "Open Supporting"}   {FileOpen "TEST.QPW, "Update References"}   {FileOpen "TEST.QPW, "None"}   

To create self-modifying macros

Wordperfect Quattro Pro btnbacktotopproc Using macros to customize application settings

You can use macro commands and text formulas to create self-modifying macros (also called dynamic macros) that alter themselves while playing. For example, to save the active notebook as acctx.qpw, where x is a value stored in cell A5, type the following text formula into a cell:

  +"{FileSaveAs ""ACCT"&@STRING(A5,0)&".QPW""}"   

The result of this formula plays as a macro command. For example, if cell A5 contains the value 5 from the previous example, Quattro Pro plays {FileSaveAs “ACCT5.QPW”}. If cell A5 changes to 10 and the notebook recalculates, Quattro Pro plays {FileSaveAs “ACCT10.QPW”}.

You can also use macro commands to change a portion of the macro while it is playing. The next example shows a macro that uses {GET} to convert user keystrokes into macro actions:

  cell_type b   type_indic {INDICATE UPPER(CELLPOINTER("type"))}   {LET cell_type,cellpointer("type")}   {IF cell_type="l"}{INDICATE LABEL}   {IF cell_type="b"}{INDICATE BLANK}   {IF cell_type="v"}{INDICATE VALUE}{GET next_key}   {IF UPPER(next_key)="{ESC}"}{BRANCH clear_indic}   next_key {Esc}{BRANCH type_indic}   clear_indic {INDICATE}{QUIT}   

You can use these concepts to create powerful macros that completely change themselves based on their environment.

Using macros to customize application settings