Solved

About null value in delphi 6

Posted on 2001-07-04
15
744 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month4 days, 22 hours left to enroll

635 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