What’s new in 4D v18 R3

Programming-related features

Classes

4D v18 R3 introduces a new concept to the 4D language: classes. A class allows you to define the behavior of an object through properties and functions. Once a class is defined, you can instantiate objects of this class anywhere in your code. Each object is an instance of its class. Classes can extend other classes, and then inherit from their functions.

Two types of classes are available in 4D: built-in 4D classes (returned by the 4D command) and user classes (returned by the cs command).

To create an object as an instance of a class, use the cs command with the new member function. Another important term to know is: constructor. The constructor is used to create and instantiate an object with default attributes. It’s called automatically when an object is initialized. Creating a class is done from the “New” menu in the toolbar, or from the “Explorer” dialog. A class editor will be displayed where you can create the class constructor and functions.

 

Class Inheritance

Inheritance allows a class to inherit the behavior of another class (the parent class). To inherit from one user class to another, use the Class extends keyword and the constructor of the parent class is automatically called (if you haven’t defined a specific constructor for the child class). You can also use the Super command to call the constructor of the parent class.

 

Multiple web servers in a single 4D instance

4D v18 R3 lets you start and monitor a web server for the main (host) database, as well as each hosted component. The new WEB server command enables managing web servers within separate objects for each server. It also accepts an optional parameter to define which server to use:

  • Web database server – to manipulate the current database web server (the host database or the component database, depending on where the command is called)
  • Web host database server – to manipulate the host database web server from a component
  • Web request receiving server – to manipulate the web server receiving a request, in a web server management common method, for example.

Two member methods are available for starting and stopping the web server: start() and stop(). To get  a list of available web servers, the new WEB Server list command returns a collection of objects corresponding to all available web servers for the host database.

 

Enhanced XPath support

Beginning in 4D v18 R3, XPath implementation is more compliant and simplifies your searcheas by allowing the support of expressions such as //, @, *, and last(). For compatibility reasons, the previous, non-standard implementation is maintained by default in converted databases. To take advantage of the extended features in your converted databases, select the Use standard XPath compatibility option on the Compatibility page.

 

Object and Collection enhancements

The OB Copy() command and the collection.copy() member method have been enhanced in 4D v18 R3. They now give you the ability to add a standard object in a shared object or collection in order to avoid complex code to copy the standard object’s content to the shared object or collection. In addition, new commands to handle objects as a hash maps are available:

  • OB Keys: returns an object’s property names as a collection.
  • OB Values:  returns an object’s property values as a collection
  • OB Entries:  returns a collection of objects with key properties (property name) and values (property value).

 

 

Create an offscreen web area

4D v18 R3 lets you to use a web area in offscreen mode with the WA Run offscreen area command. It creates a web area in memory and takes, in parameter, all of the pertinent information for the web area such as :

  • The URL to load
  • The area’s name
  • The formula called when an event is thrown by the web area

And to simplify debugging an offscreen web area, a new command has been added: WA OPEN WEB INSPECTOR. It opens the web inspector and allows you to verify if the page is correctly loaded or if your JavaScript code throws errors.

4D Server Administration

Monitor 4D Server activity

To discover which operations are causing a server to be slow, 4D v18 R3 provides a new command:  START MONITORING ACTIVITY. It records operations exceeding a specified duration using two parameters: the duration and the operation to monitor. Based on the specifications set by this command, you can also get all of the recorded activities with the Get Monitored Activity() command. Once you decide to stop recording your 4D application’s activity or empty the activity list, call the STOP MONITORING ACTIVITY command.

 

ORDA

Entity selection new methods

New member methods are at your disposal in 4D v18 R3:

  • extract(): to extract data from an entity selection. This allows you to build a fully customized collection with your entity selection data. You can specify the dataclass attributes you want to extract and their names in the resulting collection.
  • refresh(): invalidates the entity selection data in the ORDA cache. It triggers an updated from the server the next time you use the data. By default the ORDA cache expires after 30 seconds, so use this member method in case you need up-to-date data immediately.
 
 

List box row selecting

4D v18 R3 provides a new command that facilitates the selection of rows in an entity selection: LISTBOX SELECT ROWS. It accepts an entity selection as a parameter and rows matching the entity selection can be selected intuitively (including rows added or removed from the selection). And for collection list boxes, you can pass a collection containing the object references you want to select.

Project database

Method documentation

As of 4D v18 R3, you can write your own documentation for project, database, trigger, project and table form methods. Documentation is saved in a Markdown file with the same name as the method or form in a documentation folder. Markdown is a standard format for documentation and allows enhanced formatting styles. The format can be displayed in 4D Explorer, in GitHub, or other tools. The documentation can contain a description of an element, as well as any information necessary to understand how the element functions in the database. To create or edit the documentation file in a project database, from the Explorer click the “Create” button or select the “Edit Documentation” menu item. 4D creates the corresponding file and opens it in your default editor with a preset template.

Define the size for automatic fontS

4D provides three automatic font themes that respect the guidelines of each platform. 4D v18 R3 allows you to override the size of these automatic themes and have more control over how your text is displayed.

 
 

4D for iOS

Ready-to-use templates

40+ ready-to-use templates are at your disposal, accessible from the project editor. The gallery is based on a dynamic list of up-to-date templates available on GitHub. To use a template, aMore” icon is available for both list and detail forms that will display the entire list of templates from the Forms section. Select the template and 4D for iOS will handle the installation. As a final step, you can enhance it to suit your needs.

 

 

Emails

Download emails in MIME format

4D v18 R3 provides a command to let you to store emails in their original, unconverted, received format. Using the POP3_transporter.getMIMEAsBlob( ) method, you can obtain a BLOB containing the MIME content for a specific message, which can be saved in your database or somewhere else.

 

4D Write Pro

New Standard actions for tables and their elements

4D v18 R3 adds new standard actions to 4D Write Pro, targeting tables, rows, and cells. They allow you to define the border type of a table, the background color of a cell, the vertical alignment of the text in a row, the alignment of the table itself within the document, the margins, the padding, and 40+ other options. Consequently, the interface of 4D Write Pro has been ehanced in terms of table processing capabilities. Four new buttons have been added to change the appearance of tables, rows, columns, and cells.

Support of protected attribute

In 4D v18 R3, designated parts of 4D Write Pro documents (or all parts) can be “non-editable”. Two levels of protection are available. First, define which part of the documents will be protected (by default, all parts are protected). Then, activate the document protection flag so that the settings you have made are taken into account. For this, two new attributes are available to be used with theWP SET ATTRIBUTES command: wk protected (can be set to almost any kind of target belonging to a document), and wk protection enabled (enables or disables the global document protection).

 

4D View Pro

More options to customize worksheets

A new command, VP SET SHEET OPTIONS, is available to define various sheet options of a 4D View Pro area. For example, this command lets you:

  • protect a worksheet by preventing the cells within it from being edited,
  • customize the colors of your worksheet’s tabs, frozen lines, gridlines, or a selection’s background and border,
  • manage the visibility of a worksheet’s gridlines, and row / column headers.
 

Want to know more? Read all blog posts about 4D v18 R3