How to check if the KeyValue of a DBLookupComboBox is Nil? lazarus / 16-Databases ---------------------------------------------------------------------- panoss · 2018-08-05 07:25 How can I check if my combobox 's KeyValue is nil? (null) The combobox is a DBLookupComboBox. It 's KeyValue is Variant. ---------------------------------------------------------------------- taazz · 2018-08-05 08:41 Quote from: panoss on August 05, 2018, 09:25:21 amHow can I check if my combobox 's KeyValue is nil? (null) The combobox is a DBLookupComboBox. It 's KeyValue is Variant. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if DBLookupComboBox1.keyvalue = null then     showmessage('Nothing was selected')   else     showMessage('You selected the item with Code :'+string(DBLookupComboBox1.keyvalue)); ---------------------------------------------------------------------- panoss · 2018-08-05 08:52 Thanks it works, my mistake was that I was using 'nil': Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if DBLookupComboBox1.keyvalue = nil then  I thought that nil in Pascal is the null used in other languages. ---------------------------------------------------------------------- taazz · 2018-08-05 09:42 Quote from: panoss on August 05, 2018, 10:52:30 amThanks it works, my mistake was that I was using 'nil': Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i if DBLookupComboBox1.keyvalue = nil then  I thought that nil in Pascal is the null used in other languages. Null is a variant constant. Since variant is a nullable record in memory the nil check is against an internal field. But in general you are correct null and nil are synonyms. ---------------------------------------------------------------------- marcov · 2018-08-05 13:42 Quote from: panoss on August 05, 2018, 10:52:30 amI thought that nil in Pascal is the null used in other languages. It is. But you don't want the language pointer NIL, but SQL NULL here. C NULL and SQL NULL are also two different things. ---------------------------------------------------------------------- ASerge · 2018-08-06 19:00 Quote from: taazz on August 05, 2018, 10:41:29 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   if DBLookupComboBox1.keyvalue = null thenVarIsNull is more optimal and clearer. This code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$MODE OBJFPC}{$APPTYPE CONSOLE} uses Variants; var  V: Variant; // Unassigned;begin  if V = null then    ;  if VarIsNull(V) then    ;end.in assembler look like: Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i # [9] if V = null then        leaq    -32(%rbp),%rax        movq    %rax,%rcx      call    VARIANTS_$$_NULL$$VARIANT        leaq    -32(%rbp),%rdx      leaq    U_$P$PROGRAM_$$_V(%rip),%rcx        call    SYSTEM_$$_equal$VARIANT$VARIANT$$BOOLEAN        testb   %al,%al.Ll7:# [11] if VarIsNull(V) then        cmpw    $1,U_$P$PROGRAM_$$_V(%rip)      seteb   %al        testb   %al,%al