6 practical examples on how to use macros
4D 18 R5 introduced form macros. They can be incredibly useful, for example, by providing an ideal way to save time on repetitive tasks. In this blog post, we’ll show you some basic examples to learn more about how macros work and the possibilities they offer. All of the following examples are available on GitHub.
A new command to open a Form in the Form Editor
4D v18 R5 provides a new 4D command to open a form in the form editor. This can be especially useful for analysis or introspection tools.
Automate repetitive tasks and more with form macros!
If you’re a fan of macros in the code editor, then 4D v18 R5 has some good news for you … because now macros are also available in the form editor!
Let me start by telling you how useful macros can be for you. Have you ever needed to use formatting or naming rules in your application, then apply them to each new form? Or maybe you’ve had to work on existing forms created by someone else, and always need to do the exact same checks and analyses before getting started. If you’ve ever encountered one of these scenarios, then 4D v18 R5 is for you because it gives you the ability to create macros and save time on predictable, repetitive tasks.
4D Write Pro: soft-hyphens made easy
With 4D v18 R5, we’ve simplified the insertion of soft-hyphens by providing new standard actions, as well as new buttons in the 4D Write Pro Interface widgets.
Coder-friendly syntax for class functions and methods
Using $1, $2, and $n variables in your code not only makes the code less readable, it can also increase confusion since the human brain can find it difficult to remember what these variables correspond to. The solution is to create a variable with an understandable name and assign it the value of $1, $2, or $n.
4D v18 R5 has good news, you can now name your parameters when declaring:
- a project method,
- a trigger
- a database method
- a form method
- a constructor of a class
- a function of a class.
Let’s see how!
Preview your CSS directly in the form editor!
In 4D v18 R5, you can preview the final CSS rendering in the form editor WITHOUT running your dialog. Yes, you heard that right. Standardizing and reviving your forms has never been easier!
If you haven’t yet heard about CSS in 4D, now’s the perfect time to learn more! Introduced in 4D v18 for project applications, this concept includes enhanced and quick style sheets based on CSS. I recommend taking a look at this blog post.
Select 4D Write Pro Interface pages to display
The two 4D Write Pro Interface widgets continue to be enhanced with more abilities and functionalities in each release. For some of your applications, not all the widget pages are useful. For example, you use 4D Write Pro to format your emails, so you only want to display a few pages to simplify the interface and make the user’s work easier.
4D v18 R5 lets you display only the desired pages. Keep reading to learn how!
4D Write Pro interface widget: Import & Export
You asked for a way to import and export different document formats via the 4D Write Pro widget and once again, 4D listened!
In addition to the 4D commands that already allow you to import and export documents in different formats, such as export .docx format with 4D v17 R4 and PDF format with 4D v18 R4. Now, 4D Write Pro can import and export different document formats via the widget from the toolbar and sidebar.
New declaration syntax for an intuitive autocompletion
Have you ever wondered about 4D’s autocompletion feature or asked yourself why 4D suggests all functions used in the code? Since an object is a very generic type, 4D only knows what it’s really storing at runtime. However, that doesn’t help much when you’re writing your code.
4D now offers a new, alternative syntax which will greatly enhance autocompletion when declaring your variables.
Project Databases: Build your own documentation for components
In a previous blog post, we showed you that documentation for methods has returned in the Explorer. Want to take things even further and use them as documentation for your components? In this blog post, we’ll show you how!
Contact us
Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!
* Your privacy is very important to us. Please click here to view our Policy