4D Blog

Home Product Comparison with an Undefined Value

Comparison with an Undefined Value

April 27, 2023

Product

Since the appearance of ORDA, classes, and other objects, you must work increasingly with undefined values.

Since some of you are asking for an easier way to use them, starting with v20, you can compare any type of value to an undefined value without throwing an error.

Usually, in 4D, the comparison operators =, #, >, <, >=, and <= check each operand’s type and value. If the types of the two operands are different, the comparison throws an error:

As mentioned before, we understand that when working with classes and objects, you must work with undefined values, so we have made this rule more flexible. Starting with v20, you can compare undefined values with all variable types:

  • The = comparison returns true when you compare an undefined variable with a null or undefined value and false in all the other ways:
$o:=new object
If ($o.undefined =10)
  ...
else
  // returns false because $o.undefined is undefined
  ...
End if
  • The # comparison returns false when you compare an undefined variable with a null or undefined value and true in all the other ways:
$o:=new object
If ($o.undefined #10)
  // returns true because $o.undefined is undefined
  ...
else
  ...
End if
  • The >, <, >= and <= comparisons return false for all the comparisons between an undefined variable and a scalar value (numeric, text, date, time, boolean). Because the comparison has no meaning, 4D throws an error for the other types.
$o:=new object
If ($o.undefined >10)
  ...
else
  // returns false because $o.undefined is undefined
  ...
End if

Check out the documentation for more details!

Discuss

Tags Language, v20

Latest related posts

  • October 23, 2025

    Starting Qodly studio is just two clicks away

  • October 22, 2025

    Localize your Qodly Pages: A Practical Guide

  • October 21, 2025

    New Way to Control Your HTTP Responses

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 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 AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience v20 vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 Administration AI Artificial Intelligence Build application Class Client/Server Code editor Collections Compatibility settings Formula Google Listbox Logs Mail Network Objects OpenAI ORDA PDF Pictures Preemptive Programming 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