4D Blog

Home Product Empower Your Development Process with your forms

Empower Your Development Process with your forms

January 20, 2025

Product

During the development phase, early detection of syntax errors is important for producing quality code. Real-time code checking is a valuable aid to developers. Not only does it improve efficiency, it also enhances quality and boosts productivity. By correcting errors immediately, you can concentrate on the functional development of your application, rather than on annoying bugs that crop up during compilation.

With 4D 20 R8, we’re delighted to introduce two new features that will transform the way you work.

  • The first is the ability to associate a class with a form, enabling syntax checking with expressions such as Form.myProperty.
  • The second is a real-time check of expressions in the property list, with a description of the error or warning displayed.

Associating a class with a form

You can now associate a user class with a form using the new “Form class” attribute. This attribute allows you to type the object returned by the Form command, permitting the use of expressions like Form.myProperty. The user class can be from the host project or a component.

Automatic Instantiation at Runtime

When opening a form, you can pass an object to the DIALOG command. This object then becomes accessible within the form via the Form command.

The object passed to the DIALOG command can be an instance of a class. Here’s how you can do it:

var $h : Integer
var $o : cs.Person
$o:=cs.Person.new()
$h:=Open form window("FormWithClass")
DIALOG("FormWithClass"; $o)

Starting from version 4D 20 R8, if you define the “Form class” property in the form without passing an object to the DIALOG command, 4D automatically handles the instantiation. Simply write:

var $h : Integer
$h:=Open form window("FormWithClass")
DIALOG("FormWithClass")

The Form command returns an object that is an instance of the “Person” class. You can check this in the form with the OB Instance of command.

$n:=OB Instance of(Form; cs.Person)

Now, you can call a class function simply by writing: “Form.message()”.

Benefits for the code editor

Auto-completion feature

The Form command benefits from auto-completion in the code editor. By typing “Form.”, 4D will suggest all the properties and functions declared in the associated class. No more inverting two letters in a property name or using a lowercase letter instead of a capital letter in a function name.

For instance, with our simple “Person” class defined as follows:

property firstname : Text
property lastname : Text
property email : Text

Class constructor
  This.firstname:=""
  This.lastname:=""
  This.email:=""

Function get fullname() : Text
  return This.firstname+" "+This.lastname

When utilizing the Form command within a form method, the code editor offers you an accurate list to complete your code:

blank

Check syntax feature

When you use expressions of the “Form.myProperty” type in the form method, or in the methods of form objects, you’ll benefit from the power of the syntax checker.

Let’s take the example of the previous class. In the code of the form method, we:

  • force an integer into a text attribute,
  • use an unknown attribute,
  • assign an integer to a computed attribute of text type.

 

In the following image, you can see that the code editor has effectively identified errors or warnings.

blank

Benefits for the form editor

Syntax checking integrated into the property list

Syntax checking is no longer limited to the code editor. This functionality is extended to expressions in the property list (such as “Datasource” or “Meta info expression“). As a result, you’ll receive immediate notifications of errors and warnings.

blank

No need to wait for compilation results to discover errors. Thanks to this feature, you’ll be informed as early as the editing phase.

Compilation

Of course, if you haven’t resolved the new errors directly, the compiler will still catch them during the compilation process.

Compiler dialog

All warnings and errors will be displayed in the compilation window. If you double-click on a form object expression, the corresponding form will open, highlighting the problematic object and its property in the property list.

blank

Compile project command

In case of compilation failure, the Compile project command returns an object with warnings and errors. The command has also been extended to return warnings or errors detected in the form object expressions.

{
    "success":false,
    "errors":[{
        "message":"Undeclared property 'firstName' used. (550.26)",
        "isError":false,
        "code":{
            "type":"formObjectExpression",
            "formName":"Person",
            "objectName":"InputFirstname",
            "propertyName":"dataSource",
            "file":"[object File]"
            }
        }]
}

What’s next

These new features will make writing code easier and more efficient.

Don’t hesitate to share your experiences with these improvements. Your comments are invaluable in helping us to understand how these tools help you on a daily basis, and to better adapt them to your needs.

Discuss

Tags 20 R8, 21, Code editor, Form editor, User Experience

Latest related posts

  • June 16, 2025

    Generate, share and use web sessions One-Time Passcodes (OTP)

  • May 20, 2025

    Automatic Refresh of OEM Build Licenses

  • May 16, 2025

    New class to handle incoming TCP connections

Vanessa Talbot
Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D-Analyzer 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R8 20 R9 Administration Authentication Build application CI/CD Class Client/Server Code editor Collections Compatibility settings Formula Listbox Logs Mail Microsoft 365 Network Objects ORDA PDF Pictures Preemptive Programming Qodly Studio REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor
Subscribe to 4D Newsletter

© 2025 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

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