About null value in delphi 6

What happen with NULL value in Delphi6?
in Delphi5 i have code:
SaveDialog1.filename:=null;
Query1['customer']:=null;
and it's work but in Delphi6 i see:
Undeclared identifier: 'null'
Harry_De_SadAsked:
Who is Participating?
 
MadshiConnect With a Mentor Commented:
Haven't you read what's new in Delphi6? They say they moved a lot of variant stuff out of system.pas and into a new unit named variants.pas. So I guess you only have to add variants to your uses clause and everything will be just fine...

Regards, Madshi.
0
 
edeyCommented:
how about nil?

GL
Mike
0
 
MotazCommented:
NULL is a C++ equivilant of Object Pascal's nil

Motaz
0
2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

 
Harry_De_SadAuthor Commented:
if write Query1['customer']:=nil; then Delphi send message:
[Error]  Incompatible types
0
 
MotazCommented:
Try this:
Query1.FieldByName('customer').Value:= nil;
0
 
MotazCommented:
Try this:

Query1.FieldByName('customer').Clear;
0
 
MotazCommented:
This is from Help, about TField.Clear

Sets the value of the field to NULL.

procedure Clear;

Description

Call the Clear method to give the field a blank value (a NULL value in SQL terms).
0
 
Harry_De_SadAuthor Commented:
if frm_DataModul.temp_ext['contract']<>null
0
 
Harry_De_SadAuthor Commented:
Thank's Motaz Query1.FieldByName('customer').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['contract']<>null then ...

And why null not work?
0
 
MotazCommented:
Try this:

frm_DataModul.temp_ext.FieldByName('contract').IsNull then

Motaz
www.geocities.com/motaz1
0
 
Harry_De_SadAuthor Commented:
Thank's Motaz Query1.FieldByName('customer').Clear is work,
but what about this code:
if frm_DataModul.temp_ext['contract']<>null then ...

And why null not work?
0
 
Mohammed NasmanSoftware DeveloperCommented:
try the empty quotes

SaveDialog1.filename:='';
Query1['customer']:='';

Mohammed
0
 
MotazCommented:
Hi Mohammed,
SaveDialog1.FileName:= '' is equivilant to := NULL,
because Null string is represented by empty contaitions, but in fields, it is not means Null:

Query1.FieldByName('customer').AsString:= '' means that it contains an empty string, but the field is not NULL,

Query1.FieldByName('customer').Clear means clearing data = NULL value

Motaz
0
 
robert_marquardtCommented:
To clear up some things:
nil <> NULL in Delphi.

nil is a pointer with address $0.
NULL is the NULL of a database field.

In C NULL is the same as nil in Delphi.

So your code is wrong in both Delphi 5 and 6.
Only that Delphi 5 is a bit more tolerant.

SaveDialog1.FileName := nil;
Query1['customer'] := null;

is the correct version.
0
 
Harry_De_SadAuthor Commented:
Madshi you answer the most full and short...
And i don't need any change in my project.
Thank's all.
0
All Courses

From novice to tech pro — start learning today.