What’s new in 4D v16 R4

Object notation

Objects, introduced as language object with 4D v14, supported by the database engine with 4D v15, enhanced with 4D v16 – will see a huge increase for functionality in the coming releases, starting with 4D v16 R4. It will start with making coding easier and faster – and lead in the not so far future to a revolution in how you write code and use the database engine.

With object notation, provided as a preview in 4D v16 R4, you can simply write $myobject.attribute.subattribute:=5 or access an attribute with $person.children[2].firstname. Just as a reminder, the preview status means that you can play with the new functionality and learn it, but is not yet production-ready.

In fact, you can use object notation as expression. For example create a form object like a text variable and assign directly the object attribute, e.g. [person]relatives.grandfather.grandfather.firstname. It is no longer needed to use OB Get recursively to read the value and assign it to a temporary variable, just to display it.

In order to use the object notation features, you should activate object notation in the Compatibility page of the Database settings dialog box. This action is irreversible.

When activating this feature, you should be aware that it is no longer allowed to use special characters such as dots (.) and/or square brackets ([ ]) in names of variables, tables, fields and project methods. In order to verify that your application is compliant with the object notation prerequisites, you can run Verify the application action in the MSC. The elements containing forbidden characters will be listed in the MSC log, so that you can easily find what needs to be renamed in your application.

Object notation is supported in:

  • Method editor: Using the object notation is more elegant, easier and more intuitive in object manipulation than using OB Get and OB Set.
    You can create, read or modify object attributes directly, even create new elements in an object array attribute simply by using it. If for example an array inside an object has 3 elements and you write in element 10, it is automatically enlarged and missing elements are created.
  • Form editor: You can use object notation as form object data source in the form editor. Complex objects can be displayed as single entry fields. Using the language you could even fully dynamically create a form and simply link the form widgets to object attributes.
  • Debugger and Runtime Explorer: You can use the object notation in the Debugger in order to test and check your code.

New Collection type

4D v16 R4 introduces a new Collection type in the 4D language. On the first view a collection looks like an array, but while an array is a highly optimized list of the same type (Array longint, Array Text, …), a collection is a kind of container storing a list of individual types (a longint, then a text, then a number, then a picture, an object, even another collection, etc). A collection is very flexible. While an array needs less memory and could be faster, a collection is more flexible and speeds up development time.

You could imagine an object as a list of named attributes, while a collection is a list of unnamed attributes, accessed with an index. The New collection command creates a new empty or prefilled collection. And collections can be access with the object notation

Null command

The new Null command can be used to check if an object attribute or a collection member has an unknown or missing value (mind the difference from the value 0 or an empty string “” with an unset value). It also allows to set an attribute value to unknown. And yes, it can be used with the object notation.

Support of pictures in objects

Pictures can be stored in an object field or in an object variable. Many developers used the object field type to allow their customers to enhance the database structure with customized fields, storing all kind of information. Pictures was not possible so far. 

The OB Get and OB SET commands have been updated to support the new Is picture type and to be able to store a picture in an object field. And of course, you can use the object notation as well…

Validate JSON objects

Working with objects you will sooner or later exchange objects with other application or services – and to do so you need to parse JSON strings. As long this strings are well defined everything is nice, but sometimes they are not and a new option can drastically reduce your debugging time. The option * parameter of JSON Parse creates additional debug information (__symbols property) which provides path, line position, and line offset of each property and sub-property of the object. This information can be useful for debugging purposes.

Even if an object is well formed, it might not fulfill requested specifications or content norms. The new JSON Validate command allows you to check if the structure of the object fits to a given specification (JSON schema).

4D Write Pro

4D Write Pro Tables

Tables arrive in 4D Write Pro. Real tables, individual cells, if you enter a large text in a cell, the text will be automatically wrapped, and the cell width will just remain the same. You can create a table from scratch and of course modify the style of the table, or its columns, rows and even individual cells, all this by programming.

The new WP Insert table command allows you to create a table with a number of cells, rows or empty. The following commands have been created to allow you to manage tables in your 4D Write Pro document: WP Table append row, WP Table get rows, WP Table get columns, WP Table get cells. All these new commands are thread-safe.

4D Write Pro hyperlinks

Add a link to your company logo or company name is now as easy as styling some text to bold. Thanks to the wk link url new attribute, hyperlinks can be added on pictures, text or a combination of both, just by using WP SET ATTRIBUTES and WP GET ATTRIBUTES commands.

Design your own toolbar with standard actions

Easily create your custom 4D Write Pro toolbar, without any programming. The Standard actions mechanism, simple but very powerful, has been extended again with 4D v16 R4. In fact, standard actions can now also be assigned to checkboxes and pop-up menus.

Using standard actions make you benefit from automatic mechanisms which will save your time: the object activation/deactivation is automatically handled by 4D depending on the context and the current status (for checkboxes) or value (for pop-up menus) is automatically updated by 4D according to the current text selection.

Altura-free 4D Windows 64-bit product line

The whole 4D Windows 64-bit product line is no longer relying on the Mac2Win library from Altura. 4D Server Windows 64-bit was the last step to complete and this is done with 4D v16 R4. This is allowing 4D to internally use modern technologies on the Windows platform, and make you benefit from new features such as SDI.

SDI Support on Windows

On Windows, 4D was used to have a grey main window (named MDI window) with all application windows displayed inside (as child windows). SDI applications, like Microsoft Outlook for instance, have a main window but can open many additional windows which are independent of the main window. They can be moved on other screens, they stay visible even if the main window is hidden and so on…

On the other hand, MDI also has benefits for some business applications, as all windows belongs together to build the application. A good example is Adobe Photoshop. This is why 4D allows both modes for merged applications.

4D View Pro Spreadsheets

4D v16 R4 introduces the very first step of the 4D View Pro spreadsheet as a preview. Discover the new 4D View Pro form object, and the new 4D View Pro commands. Create a new document with VP NEW DOCUMENT, save it on disk with VP EXPORT DOCUMENT or in the database using VP Export to object and reopen it with VP IMPORT DOCUMENT or VP IMPORT FROM OBJECT.

Custom Server Administration Window

A series of features in development will allow you to create your own server administration window, controlling which information you want to display or allow the admin to change.

Information about processes and users

As a first step the new Get process activity command gives a snapshot of connected user sessions, related running processes and of all current processes including internal processes that were not reachable by the PROCESS PROPERTIES command. You can also compute from the session/process information returned the CPU time consumed by this process since connecting (in seconds) and the activity percentage (e.g.: 2%).

Detailed information about licenses

The new Get license info command returns detailed information about the installed licenses and used/available licenses.

Enhanced control of help tip display

Quite simple, you can by programming disable or enable all help tips inside a 4D application with SET DATABASE PARAMETER command. More enhanced, you can define the display delay and the maximum duration of the display by language. But that’s not all, it is also possible to dynamically modify the text of a help tip using the OBJECT SET HELP TIP command.

Define form tab order by programming

This feature allows you to define in a form the object input order by programming, so that you can control on which next form object the focus will be when the user presses the TAB key. Two new commands – FORM SET ENTRY ORDER and FORM GET ENTRY ORDER – permit you respectively to dynamically set and get the entry order of the current form objects for the current process. This feature is especially useful when you create forms dynamically.

IPv6-related user interface improvement

4D v16 R4 provides some UI improvements for a better user experience for people using IPv6 network configurations.

Want to know more? Read all blog posts about 4D v16 R4!