Times inside objects… (and everywhere else)

Automatically translated from English

Objects are at it again, continuing to demonstrate their utility to ease your life as a developer.

Using time (or duration) values inside of objects is now smoother and more intuitive. Beginning with 4D v17, times inside objects are set as seconds  – and not milliseconds!

This was not previously visible for users because OB SET and OB Get had to be used with the is time constant, so the conversions were made automatically.

OB SET ($myObject;"myTime";$time;is time)
$time:=OB Get ($myObject;"myTime";is time)

Now, this constant is no longer mandatory. The code above can be shortened, but even more importantly, object notation can be used as well!

$myObject.myTime:=$time
$time:=$myObject.myTime

TIME IN OTHER CONTEXTS

QUERYING OBJECT FIELDS

  • From now on, when querying an object field with QUERY BY ATTRIBUTE, comparisons between number and a time values are performed in seconds instead of milliseconds.

 

Here are two examples which produce the same result:

QUERY BY ATTRIBUTE([Table_1];[Table_1]z;"time";"=";?12:00:00?)

QUERY BY ATTRIBUTE([Table_1];[Table_1]z;"time";"=";12*60*60)

 

WEB AREA

  • When calling JavaScript in a web area, conversion to and from a time is performed in seconds instead of milliseconds when using:
    • WA Evaluate JavaScript
    • WA EXECUTE JAVASCRIPT FUNCTION
    • $4d bridge

COMPATIBILITY CAN BE MAINTAINED EASiLY

If necessary for existing databases, this default setting can be changed with the SET DATABASE PARAMETER command and the Times inside objects selector.

There are two available values for this option:

  • Times in milliseconds
  • Times in seconds

This database parameter is applied to the database itself, not just the current process. To maintain compatibility or help the migration process, this command can be called during the On Startup Database Method.

 

Roland Lannuzel

• Product Owner & 4D Expert •

After studying electronics, Roland went into industrial IT as a developer and consultant, building solutions for customers with a variety of databases and technologies. In the late 80’s he fell in love with 4D and has used it in writing business applications that include accounting, billing and email systems.

Eventually joining the company in 1997, Roland’s valuable contributions include designing specifications, testing tools, demos as well as training and speaking to the 4D community at many conferences. He continues to actively shape the future of 4D by defining new features and database development tools.