Solved

About null value in delphi 6

Posted on 2001-07-04
15
697 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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:mnasman
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now