KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically freeze all expressions in a 4D Write Pro document
PRODUCT: 4D | VERSION: 18 R | PLATFORM: Mac & Win
Published On: April 12, 2021

When trying to freeze all expressions in a 4D Write Pro document, it is a common mistake to immediately try freezing all expressions without setting a selection. For example, if one were to run the command below during a form's On Load event:

ST FREEZE EXPRESSIONS(WParea;ST Start text;ST End text)


The command by itself would not freeze anything since it's missing a selection. To address this, simply call WP SELECT beforehand to select all characters within a document. Afterwards, use WP SELECT to set the selection back to the 1st character

WP SELECT(WParea;wk start text;wk end text) // Select all text
ST FREEZE EXPRESSIONS(WParea;ST Start text;ST End text) // Freeze all within select range
WP SELECT(WParea;wk start text;wk start text) // Set selection back to 1st character


Alternatively for those running on 18 R5 or newer, you can reduce the code to a single line using the new command WP FREEZE EXPRESSIONS as shown below:

WP FREEZE FORMULAS(WParea)


Now when the form is initially loaded, the document will display all expressions as static text without having to manually freeze the expressions with the 4D Write Pro toolbar.

Commented by Erick Lui on April 14, 2021 at 2:30 PM
WP FREEZE FORMULAS is definitely the cleaner alternative, although that command only exists in 18 R5 or newer. I will keep that in mind for future suggestions when other developers are running on the R versions.
Commented by Armin Deeg on April 14, 2021 at 3:30 AM
Why not use WP FREEZE FORMULAS ?