Solved

About null value in delphi 6

Posted on 2001-07-04
15
710 Views
Last Modified: 2010-04-06
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
Comment
Question by:Harry_De_Sad
15 Comments
 
LVL 6

Expert Comment

by:edey
ID: 6254234
how about nil?

GL
Mike
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254279
NULL is a C++ equivilant of Object Pascal's nil

Motaz
0
 

Author Comment

by:Harry_De_Sad
ID: 6254292
if write Query1['customer']:=nil; then Delphi send message:
[Error]  Incompatible types
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
LVL 7

Expert Comment

by:Motaz
ID: 6254303
Try this:
Query1.FieldByName('customer').Value:= nil;
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254307
Try this:

Query1.FieldByName('customer').Clear;
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254309
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
 

Author Comment

by:Harry_De_Sad
ID: 6254346
if frm_DataModul.temp_ext['contract']<>null
0
 

Author Comment

by:Harry_De_Sad
ID: 6254356
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
 
LVL 7

Expert Comment

by:Motaz
ID: 6254366
Try this:

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

Motaz
www.geocities.com/motaz1
0
 

Author Comment

by:Harry_De_Sad
ID: 6254391
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
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6254412
try the empty quotes

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

Mohammed
0
 
LVL 7

Expert Comment

by:Motaz
ID: 6254418
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
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 6254423
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
 
LVL 20

Accepted Solution

by:
Madshi earned 50 total points
ID: 6254424
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
 

Author Comment

by:Harry_De_Sad
ID: 6254629
Madshi you answer the most full and short...
And i don't need any change in my project.
Thank's all.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 103
HTML text in the body of an email (delphi code) 12 117
How to renew a Delphi rad-studio licence? 5 64
When i run adoquery my application freezes 26 166
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question