Using Pseudo Code

Navigation:  Macros > The Macros Editor > Writing Macros >

Using Pseudo Code

Previous pageReturn to chapter overviewNext page

You should start any macro by writing the outline of what the macro is to accomplish, using pseudo-code in comments. This is a powerful way of separating the logic of your code from its implementation details.

 

As an example consider a macro that must determine if the length of the [fa] token on each date exceeds 35 characters, so that the font size and horizontal scale of the characters can be modified to fit into the token's textbox.

 

We first write comments only that make us our pseudo-code :

// what is the a-holidays string for Token date
// how many characters in the holiday
// Does the holiday have more than 35 characters
// regardless of bResult replace the token by its root

Then we insert the macro code in between the comment lines.

// what is the a-holidays string for Token date
sHolidaysCurDate = EvalToken(n_TokenDate,'[Fa]')
// how many characters in the holiday
nHolidayCharCnt = StrLength(sHolidaysCurDate)
// Does the holiday have more than 35 characters
bResult = nHolidayCharCnt > 35
// regardless of bResult replace the token by its root
sResult = '[' + s_TokenRoot + ']'

The use of pseudo-code allows you to better grasp what the issues are without immediately getting bogged down in naming variables and writing syntactically correct code. If you have written coherent and self explanatory pseudo code, it will be easier for tech support to understand what you are trying to do when you export and email them your partially completed macro.


Topic 136400 updated on 10-Feb-2019.
Topic URL: https://www.qppstudio.net/webhelp_xe3/index.html?usingpseudocode.htm