Improved productivity with Object check syntax

Automatically translated from English

Auto-completion for classes is available since 4D v18 R4. This feature simplifies code writing and limits errors in function names, for example. But it doesn’t avoid them entirely; it’s easy to reverse two letters or to forget a capital letter, and then have to 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.

What’s checked

When declaring or instantiating a class, the class name is checked. Also, the name of the functions is validated for 4D classes, user classes, or user ORDA classes.

And where?

Code editor

As you write your code, if you make a spelling mistake or use the wrong function, a warning will appear to the left of the line.

Compiler window

Like all other 4D warnings, you will find the warnings in the Compiler window.

Compile Project command

Since v19, you can run a “check syntax” by programming thanks to the Compile project command. The status object returned by the command contains all the warnings:

var $options; $status : Object
$options:=New object()
$options.targets:=New collection()
$status:=Compile project($options)

Here are the contents of the $status object:

{
  "success": true,
  "errors": [
    {..}, {
    "message": "The function or property orderby is incompatible with the type driversSelection. (550.2)",
    "isError": false,
    "code": {
      "type": "projectMethod",
      "methodName": "Method2",
      "path": "Method2",
      "file": "[object File]"
    },
    "line": 6,
    "lineInFile": 7
  }]
}

And…

Feel free to comment on the 4D forum.

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.