A Fresh Approach to Writing Variadic Functions
Many of you are familiar with using methods or functions that can accept an unspecified number of parameters, often referred to as variadic functions.
In our ongoing process to improve your development experience, 4D v20 R3 streamlined the declaration of these methods by introducing ellipsis, making your code more straightforward and easier to work with.
Simplify Variable Declarations & Assignments in a Single Line
Starting with 4D v20 R3, you can wave goodbye to the days of writing multiple lines of code for variable declarations and assignments. Now, you can streamline your code, eliminate redundancy, and easily boost efficiency.
Here is how!
Deprecation of PHP Commands & Removal of 4D Built-in PHP Interpreter
PHP has played a crucial role in web development, and it was introduced into 4D v12 to offer features not readily available in the native language, such as zip, hash, or LDAP functionality. Over time, 4D has incorporated many of these PHP features into its core functionality. As a result, we decided to remove the built-in PHP interpreter in 4D v20 R3 and begin the deprecation process for PHP commands in v21.
While we won’t entirely remove the PHP commands from 4D, we strongly encourage you to use the system workers to execute PHP code in the future.
This blog post will guide you through this transition process, demonstrating how to use an external interpreter through PHP Execute and explaining how to execute PHP code effectively with a system worker.
Track data changes in your database
In this blog post, we’re thrilled to introduce a powerful method to revolutionize how you manage and track changes within your data store. We’ll unveil the concept of a “stamp”, a specialized marker designed to streamline your data modification monitoring and show you how to tailor these stamps to your unique requirements.
Sync Several Collections with this new Function
4D offers powerful features to work with object collections. For example, you can create a collection of cities with their associated countries and continents. Manipulating these collections with built-in functions like sort, order, and filter becomes a breeze.
4D v20 R3 introduces the new multiSort() function to simplify this process. With this function, you can now easily sort and synchronize multiple collections.
Enhanced Error Management in 4D Code
Throwing errors in your 4D code is now possible starting from v20R2.
Those errors behave as any 4D error: they trigger an error dialog or can be handled in an ON ERR CALL method.
This feature will ease your life because you’ll be able to improve the quality of your code by proactively detecting errors as soon as they occur. You can also handle better error logging.
Before digging into details, It’s important to note that this feature is the first step towards achieving robust error management.
Now, let’s dig into the details!
Declaring Class Properties
The 4D language is constantly improving. For v20, we bring you a new feature that will ease the use of your classes: declared class properties. Declaring your class properties will significantly improve autocomplete and give you meaningful errors when compiling. Do you want to know more about it? Let me show you how it works!
Build an Application with 4D Commands
Since several versions of 4D, different features have been added to create your own build chain. For example,
- the creation of a “.zip” folder,
- the addition of information such as the copyright on an executable or a “dll”,
- the creation of an “info.plist” file,
- and the new build4D component.
With 4D v20, two new features allow finalizing the creation of a standalone or client/server application in 4D code:
- the addition of an icon to an executable
- the generation of the deployment license file for a server (OEM license only) or a standalone application.
Meet the Improved Distinct Function
Retrieving the list of unique data elements is always helpful when manipulating data. In some cases, retrieving the number of occurrences of each value is essential. The distinct function of the Collection and Entity selection classes allows retrieving a list of unique values. With 4D v20, you can also retrieve the number of occurrences of each distinct value.
And that’s not all!
An object in the database can be used to save custom data entered by the user. So on the code side, you need to know all the possible paths to the object. The distinctPaths function has been added to the Entity selection class.
Here is everything you need to know.
Object and Collection Literal Initializer
In your code, objects and collections can be instantiated using New object and New collection commands.
However, starting from 4D v20, a more convenient and readable approach is available using object literals and collection literals. These new features provide a simpler and clearer way to initialize objects and collections.
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