Using Classes Across Components
Component developers frequently require the utilization of a class from another existing component.
With 4D 20 R6, when a component has a declared namespace, its classes are now accessible to all components loaded in the host project via cs.namespace.
New 4D remote session object with Client/Server connection and Stored procedure
In 4D applications, four types of sessions exist 4D Remote session, Stored Procedure session, Mobile session, and Web session.
The Session command already returns Web or Mobile sessions. This gives you access to a wealth of information about the session and an object shared by all processes in the session.
In 4D 20 R5, the Session command has been extended to the Client/Server connection and stored procedure.
Shared Classes
Do you want a simplified way to use shared objects, following the classic object syntax and automatically calling use/end use when needed?
Fasten your seatbelts; here come the shared classes!
Singletons in 4D
4D 20 R5 delivers a powerful feature for developers: Singletons!
The singleton design pattern creates a single instance of a class accessible throughout your application.
This pattern offers many benefits, including:
- host for interprocess values,
- utility classes,
- a base for the factory design pattern,
- and many more.
Keep reading for more information about this new concept!
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.
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