A class for easy handling of your sub-forms
On the forum, several requests, tips, or questions have been asked about displaying a message, an hourglass, or some interface elements in the foreground of a form while blurring out the rest. You can create this type of interface with sub-forms and call forms. The code can get complicated if you’re working with a multi-page form.
To simplify your work, Vincent De Lachaux has prepared a class to simplify the management of sub-forms displayed in a multi-page form. It handles loading the sub-form on the fly, controlling it from a worker, and repositioning it if the main form is resized. You can focus on your dialogues without worrying about the mechanics.
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.
Tips & Tricks for your 4D Apps – September Edition
by Add Komoncharoensiri, Director of Technical Services at 4D Inc
Here we go with another set of tips and tricks.
As you know, 4D Knowledge Base is a library of information about 4D technology where weekly tech tips and monthly tech notes are actively published. If you missed the last tips on the KB, that’s fine; here is a compilation from the past few weeks.
This blog post covers 16 tips:
New Tips & Tricks for your 4D Applications
by Add Komoncharoensiri, Director of Technical Services at 4D Inc
As you know, 4D Knowledge Base is a library of information about the 4D technology where weekly tech tips and monthly technotes are actively published. If you missed the last tips on the KB, that’s fine; here is a compilation from the past few weeks.
This blog post covers 12 tips:
A Seamless Way to Manage Parameters
In the declaration of a function or method, you explicitly define its parameters. Then, when calling that function or method, you can pass fewer parameters to it if some are optional. Or, if you used the declaration with ${n}, the number of passed parameters is variable. In this case, you use the Count Parameters command with a loop over the arguments. This code works flawlessly. Still, it’s a little bit heavy.
You asked us for a lighter way to handle parameters, and we listened. Starting with 4D v19 R5, we provide you with a new command, Copy parameters, allowing you to write a seamless, more elegant, and easier-to-read code.
Access your component classes from your host project
Components can now publish classes! And even better, if your application is still in binary mode, you can now benefit from classes and object-oriented development by using a component (in project mode) to create your own classes and use them from your (binary mode based) application.
Quickly jump to different functions of a class
Classes were introduced with 4D v18 R3. They allow you to organize your business logic and separate it from the UI part more quickly.
Classes are composed of several functions of varying lengths, so it’s not always easy to find the function you want to modify, or to move from one function to another. You can use the explorer, which displays classes and functions, but when you’re coding in the editor window, you don’t want to waste time changing windows.
With 4D v19 R4, the list of functions in your class is displayed in the code editor toolbar, allowing you to easily jump to a specific function.
Need a magic wand? Here are computed class properties!
Create a BLOB attribute in an object
With the introduction of classes in the 4D environment, the need to store your data in objects, and especially blobs, has increased. That’s why 4D v19 R2 lets you encapsulate blobs in objects.
Beyond the storage aspect, since the blob object is a reference type, your performance in terms of memory occupation and speed will be greatly improved.
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!
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