How Do I Format an Expression in the Expression Window? (Magic xpa 4.x)
Some expressions can be very long and complex. For instance, suppose you have a nested IF statement:
IF(I='N', 'Entering a new transaction', IF(I='P' and J='00/00/0000'DATE, 'Transaction is being processed', IF(I='P' and J<>'00/0000'DATE,'Order has been sent to Shipping', 'Order has shipped')))
While this is syntactically correct, it is difficult for a human to read. It is much easier to read if you add some line breaks and spacing:
IF(I='N',
'Entering a new transaction',
IF(I='P' and J='00/00/0000'DATE,
'Transaction is being processed',
IF(I='P' and J<>'00/0000'DATE,
'Order has been sent to Shipping',
'Order has shipped')))
Here is how you format an expression in Magic xpa.
-
Zoom (F5 or double click) to the Expressions Rules. Alternatively, you can press Ctrl+E to jump to the Expression Rules from anywhere.
-
Press F6 (Edit->Wide). This will cause the expression you are parked on to expand, so it is the only expression in the Expression window.
-
Now that you are in Wide mode, you can press Enter, and a line break will appear in the expression. You can also add spaces to indent text as desired, or use tabs.
-
When you are done, press Ctrl+Enter, the OK button, the X box on the upper right, or press Escape twice. Pressing “Enter” to leave won’t work in Wide mode, because the Enter key is interpreted as a line feed.
Note that when you add line breaks, this does in fact add a CRLF (Carriage Return and Line Feed character) to the expression. This doesn’t matter to Magic xpa, but if you are putting text out to, say, a message box, adding a line feed to the text will cause the message to have a line feed at runtime too. This allows you to format text for output purposes as well as for programmer readability.