Easy Reference Comparison of Objects & Collections
Objects have become an essential part of the 4D language and of Qodly.
But when you declare a variable of this type, you define a reference. So, how do you know if two objects are, in fact, just one and share the same reference?
Starting with 4D 20 R6, comparing object references is simple: enter the = and # operators!
This blog post explores these operators and how they help determine if objects share the same reference. Let’s find out more!
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.
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.
New Handy Functions for Collections!
The functions associated with collections were introduced with 4D v16 R6 and have evolved with the possibility to use formulas for some of them, like map() or reduce(). 4D v20 brings other features that are just as practical, which we will present here.
Automatic Row Heights in Collection Based List Boxes
List boxes are the most versatile and customizable form objects. Automatic row heights were already possible for array-based list boxes. With the arrival of 4D v19 R8, this possibility is now extended to list boxes based on collections… and entity selections!
The Use of Formulas in Collections & Callback Commands
When you use collections with a member method that needs a callback method, many of you have asked us for a more straightforward way.
You asked; we delivered!
Starting with 4D v19 R6, 4D allows you to use a formula to define a callback in the collection member functions, the EXECUTE METHOD IN SUBFORM, CALL FORM, and CALL WORKER commands. If you can reduce your code to a simple expression, you can pass it directly into the formula without using a method.
Use collections and lists within forms objects
Collections are increasingly used in 4D programming. Starting with 4D v19, you can use them to define the content of some interface objects, including through the Form function. This is very useful for generic interface management.
We’ve also added improvements to how lists are used. Let’s see this in detail!
ORDA: Easy looping with a new 4D tag
You have probably already used a For each…End for each loop to work with ORDA entity selections or with collections. Its use is simple and straight forward. Would like to use it as a 4D tag in your SHTML pages? Or perhaps with the PROCESS 4D TAGS command?
As of 4D v19, you can! Keep reading to learn more.
ORDA – Better list box row selecting
Use collections to write and read in 4D View Pro
If you need to read or write hundreds of different values or formulas, you can do it faster, easier, and at the same time by using collections. New commands are available for this: VP SET VALUES, VP Get values, VP SET FORMULAS, and VP Get formulas.
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