What’s new in 4D v19 R4

4D language

Return. Continue. Break. And more!

We listened and followed your feature requests in 4D Forum with several 4D language improvements!

  • Starting with statements that allow you to jump out a block of code:
    • The return keyword terminates the execution of the method or function in which it appears and returns control to the calling method. It can also return an optional value.
    • The break keyword terminates the loop containing it. The following statement executed is the one immediately after the loop’s body.
    • The continue statement terminates the statements’ execution in the current loop’s current iteration and continues execution of the loop with the next iteration.
  • Followed by short-circuit evaluation: In an expression that uses an AND or OR operator, a short-circuit evaluation means that the second argument is executed or evaluated only if the first argument does not suffice to determine the value of the expression. We add two new operators to do it:
    • && for the AND operator
    • || for the OR operator
  • And then there is a ternary operator, which is a condition followed by a question mark ( ? ), an expression to evaluate if the condition is truthy followed by a colon (:), and finally the expression to evaluate if the condition is false: condition? value If True: value If False.

 

New command to get detailed information about licenses

4D v19 R4 is shipped with a new command that gives all the information about your license usage: Get License Usage. We have also expanded our diagnostic logs. Thanks to getting this feature, you’ll be able to follow the license consumption on your server, optimize your usage and plan ahead for your future needs.

 

More optionS for OBJECT SET enterable command

The OBJECT SET ENTERABLE command has been enhanced, enabling you to better manage a field that is not editable. As a third parameter, the command supports a boolean or an integer. 

  • So, you can use the command as before without changing your code by passing a boolean. Only the enterable property is modified (False or True).
  • Or you can pass an integer. Thus, you can set the enterable and focusable property for your field.

 

User Interface

High DPI on Windows: Support for high-resolution screens

High DPI stands for High Dots Per Inch. It represents the pixel density; the higher the DPI, the higher the density of pixels. On 4K screens, the pixel density can be so high that displaying, as usual, would make all icons and controls extremely small. As such, Windows allows you to change the scale of text, icons, and controls. On 4K screens, it’s activated by default. We first supported high DPI on Mac, and with v19R4, 4D is now fully compatible on Windows, too. The result is better text and image quality.

 
 

System workers

Launch an external process asynchronously

Another highly requested feature is available for you. Sometimes, you need to run processes in the background and perform specific actions based on its output code as soon it is available, while the process is still running. For example to display a progress bar. 4D allows you to start a background process with the new 4D.SystemWorker class and automatically execute callback methods when the process returns information. So, if you use it with an interface, the interface stays responsive to your user while the external process is running, and when it is finished, you can display the result to your client.

 

ORDA

Say hello to aliases

4D v19 R4 is shipped with a new ORDA concept: Aliases. They are the logical and complementary continuation of computed attributes. As the name suggests, an alias is, in fact, a shortcut to an existing datastore object. They are defined in the “entity dataclass” like computed attributes. While a  computed attribute can process any calculation or formula, an alias is just a shortcut, making development faster and easier. An example usage is to give easy access to related attributes (which means hiding the complexity of a related database).

 

Disable default mapping of NULL value to a blank value

When you create a new field in your database, 4D allows you to choose or not to map NULL values to blank values. Starting from 4D v19 R4, in new projects, 4D will no longer by default map the NULL value to absent data.

This is beneficial because ORDA is perfectly designed to work with NULL values, and it will spare you lots of inelegant workarounds.

 

 

Pessimistic Lock management VIA Rest

With 4D v19 R4, you can use the REST API to lock or unlock an entity. This is particularly useful to:

  • Keep your code consistent if you are used to working with the REST API. There is no need to write a function in ORDA Data Model Classes to lock/unlock an entity.
  • Smoothly use the pessimistic locks with the REST API.

 

4D for Mobile

object attributes for advanced apps

As of now, you can use almost all types of attributes in your mobile projects: text, dates, time, integers. 4D v19 R4 is bringing another one: object attributes. This allows you to display object fields in your mobile application in human-readable format or in JSON format. Object fields are used to store various data in your 4D application; now, they are easily useable in mobile apps. Meaning? Building even more advanced iOS and Android applications is at your fingertips.

 

Data management improvements

With 4D v19 R4, the data section has been improved to give you more information about the data you will package with your mobile application. For example, you will get the exact number of entities and the data size for each data class, avoiding getting too much data in your mobile app. This improvement will also help you check your query validity by clicking on the Validate button. You will get more visual feedback about your query validation with error messages if the query is incorrect.

 

New in 4D for Android 

Many improvements were brought to 4D for Android, enabling you to enjoy the same premium experience 4D for iOS offers. 4D v19 R4 is bringing:

  • The support of One to N relations: Display the relative data to a record in the list and detail form.
  • Online actions: Possible to modify an entity or entity selection in online mode.
  • And Object field formatted: Display object fields in your mobile application in human-readable format or JSON format.
 
 
 

4D Write Pro

page break inside table rows

4D v19 R4 is shipped with new attributes to define tables’ layout better. Enabling you to create complex 4D Write Pro documents with ease, but most importantly, visually appealing documents: say hello to page breaks inside table rows. This is useful when the cells have longer text (or several paragraphs). It may be interesting to define that a cell (and therefore a line of the table) can also be split in two to fill the available space on the pages of the documents:

  • wk page break inside paragraph can, of course, be applied to paragraphs, but also to any target such as the document itself, a particular section, a range of text, etc. In all cases, the attribute will be assigned to the paragraphs inside the target. This is simply a programming facility.
  • wk page break inside table allows a table to be split into two (or more) parts, the separation is done between two lines of the table (as usual)
     
  • wk page break inside row also allows to split a table, but this time inside rows. Note that this option is dependent on the previous one. If a table cannot be split, neither can its rows.

 

Please note that the page break inside table rows option is available in the toolbar and sidebar widgets.

Dark mode support

With 4D v19 R4, 4D Write Pro has gone dark. You can ultimately develop and deploy in light or dark mode on macOS. The last widgets of the library are compatible in dark mode (on macOS):

  • 4D Write Pro Interface toolbar
  • 4D Write Pro Interface
  • Sidebar Rich text area

4D View Pro

Workbook options

When you create a document with 4D View Pro, you often need to fine-tune your user experience by hiding the sheet tabs, the scrollbars, deactivating the context menu, or the drag and drop… All these features and more are possible with the VP SET WORKBOOK OPTIONS command.

 

Speed up your development process with templates.

Creating reports or spreadsheets from existing templates speeds up development. Like an end-user using the Copy and Paste action, as a developer, you can, with 4D v19 R4, simply “copy” a range of cells from another location or even another area. The VP MOVE CELLS command allows you to copy/cut and paste a range of cells in another location, even between two areas. Another way to copy a range is to copy it in an object with the VP Copy to object command, for example, to save it in your database, So you can paste this object when you need it with the VP PASTE FROM OBJECT command.

 
Code Editor

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 more quickly.

Classes are composed of several functions of varying lengths. So it is not always easy to find the function to modify or move from one function to another. It is possible to use the explorer, which displays the classes and functions, but when you are 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 quickly jump to a specific function. 

 

Comment tags

4D v19 R4 takes comments to a new level with comment tags to better organize your comments. Tags are used to classify comments by simply putting the tag at the beginning of the comment line. We have put three tags at your disposal:

  • MARK
  • TODO
  • FIXME

The MARK tag allows you to split your code into sections. You can write it in three different ways. The other two tags TODO and FIXME, are written in the same way. The interest is that they have different icons in the list, which allows you to organize your code to prioritize your future actions.

 

Improved productivity with Object check syntax

Auto-completion for classes is available since 4D v18 R4. This feature simplifies code writing and limits errors in function names. But it doesn’t avoid them entirely; it’s easy to reverse two letters, to forget a capital letter. And then spend time looking for why your code doesn’t work. So what better way than to ask 4D to check if the classes or functions already exist? Starting with 4D v19 R4, a warning is displayed in the code editor if you call a function that does not exist.

 

New possibilities to customize the code editor

In addition to customizing the window and the code area, 4D v19 R4 brings two new customization options:

  • Show or hide the ten clipboards. 
  • The “show/hide lists” icon has been moved to the bottom right next to the lists.

Deployment 

Use duplicated merged client applications.

As a software publisher, some of your customers sometimes have many instances of your merged server application, for example, a merged server application for each company of a group. In this kind of deployment architecture, your customer’s officers often ask you to install a merged client application for each merged server application on their computer because they want to use the software for each company. From now on, you have a new buildApp key at your disposal to make each duplicated merged client application use its own user preferences folder (based on its application path): ClientUserPreferencesFolderByPath.

Want to know more? Read all the blog posts about 4D v19 R4