Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 857
  • Last Modified:

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'
0
Harry_De_Sad
Asked:
Harry_De_Sad
1 Solution
 
edeyCommented:
how about nil?

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

Motaz
0
 
Harry_De_SadAuthor Commented:
if write Query1['customer']:=nil; then Delphi send message:
[Error]  Incompatible types
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
MadshiCommented:
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now