Re: Invalid variant type conversion

From: Nicolai Hansen (nic_at_aub.dk)
Date: 01/22/04


Date: 22 Jan 2004 00:31:34 -0800


> In Delphi, there is no distinction between "" and a NULL string. Actually, a
> "" *is* a NULL string.
> While I can see why you need an "empty number" (for display purposes, e.g.),
> I can't see why you need e NULL string type. Well, in some cases it may be
> handy, but it makes all the normal cases much more cumbersome. Much like
> when you need to answer "Yes, I wanna save this d*ed document, why do you
> think I wrote it ?" in standard Win applications, to have the possibility of
> *not* saving. The 1% cases f*** up for the remaining 99%. Only true
> technicans could do this.

NULL / nil means "has no value" - which is basically different from
"an empty string" or "0".

When a database returns NULL it is because it doesn't have any data to
return to you. If it HAD data, but the data was "nothing" it would
return "" or 0 (or for a boolean; whatever bool value that is
default).

IMHO Borland made something not too smart when using NULL for an empty
string. '' is _NOT_ NULL. '' is '' - a string with nothing in it. An
empty string has a value, therefore it is not NULL.

Look upon databases, or programming languages where pointers are more
common to the language than in Pascal (C/Java for example).

In C, char *empty=""; and char *empty=NULL; is two different things.
Very different things. Unfortunately it is not so in Delphi.

Personally I never check a Delphi string for being nil - I check it
for being '' (or having length=0). In my eyes, nil has nothing to do
with an empty string; it is an undefined string.



Relevant Pages

  • Re: string as nil or empty string?
    ... With everything in Ruby being an object, should a string be initialised ... a_string = nil ... an empty string, to enable expressions like ...
    (comp.lang.ruby)
  • Re: Attachments to MAPI Message
    ... :> Do this before assigning the attachments to the message. ... :> String, _ ... :> 'is provided for sign-on. ... The default is an empty string. ...
    (microsoft.public.vb.controls.internet)
  • Re: What does this do ? !/somestring/
    ... transliteration)] it is interpreted as a search pattern at run time." ... contains a variable that is set to the empty string. ... because the m/Wor/ match was the last successful pattern match. ...
    (comp.lang.perl.misc)
  • Re: comments of less.rb appreciated
    ... There are no global variables in less.rb. ... ARGV is the command line argument Array. ... Otherwise use an empty string. ...
    (comp.lang.ruby)
  • Re: So whats null then if its not nothing?
    ... > empty string and the absence of a string? ... You have been saying, not I, that you can use the empty string to signify ... NULL covers all data types. ... > that there be a representation for unknown or absent data then that is ...
    (comp.databases.theory)