V4MD - <null> results with lingo

Bart Pietercil bart.pietercil at gmail.com
Thu Jul 19 10:22:26 CDT 2007


Hi Giacomo,

although I won't be using director anymore I did use it for 15 years.

On 19-jul-07, at 11:32, Giacomo Vernoni wrote:

> Hi Ruslan, hi all Director developers... please tell me what you  
> think about this post. I think it will be my last one on this topic.
>
>
> 3) Ruslan suggestion
> if vcursor.field("fld_varchar").IsNull then -- this will not return  
> true with empty vfields
>   myText = ""
> else
>   myText = vcursor.field("fld_varchar").value
> end if
>
> if vcursor.field("fld_varchar").IsNull then
>   myText = ""
> else
>   myText = vcursor.field("fld_varchar").value
> end if
>

My vote goes to this one. You only need to do one more check on myText

> if vcursor.field("fld_varchar").IsNull then
>   myText = ""
> else
>   myText = vcursor.field("fld_varchar").value
	if len(mytext) =  0 then
	//empty text
	// do whatever is necessary
	else
	//mytext has text

	end if
> end if

There is in database a specific reason why null values are  
differentiated from empty values.
It is up to the designer of the database to decide whether he will  
accept NULL as a valid entry.
If NULL is not acceptable then it is up to the designer to flag the  
field with a not null option

This is why I suggested to flag "not null" and use default values  
(but Ruslan indicated it was not a good idea). However if you can  
live with the additional space the use of default values would mean  
in your database,  this still looks to me as an easy way out of your  
problem.

If you set default values ('') then you would only need this code in  
Director:

> myText = vcursor.field("fld_varchar").getstring()

to read the fld_varchar field



>
> Solution 1) is the fastest.
> Solution 2) has too many lines of code.
> Solution 3) will not return true on empty (not null) vfields, so I  
> must always be sure that a vfield is null and not empty: on user  
> input I will have to check that if a member text is empty I must  
> set the vfield to null. Even more lines of code.
>

Solution 3 with the additional lines will be able to differentiate  
between null,empty and filled strings

> If I have to check if a field is null with a function, to get it as  
> a string, what's the use of field.getstring() function when every  
> programming language has a function to convert a value into a string?
>
> As you all know, I feel the need, the need for speed, and I'd like  
> to code:
>
> myText = vcursor.field("fld_varchar").getstring() -- always a  
> string as a result, empty on null/empty vfields
> myNumberAsAString = vcursor.field("fld_byte").getstring()
>
> Opinions anyone?
>
> I won't insist anymore on this if you say I'm wrong.

While I do think you're wrong, you are still very welcome to discuss  
the issue further :-)


>
> Sorry for my long post.

No Problem. Hey next week I'll be in Tuscany (holidays,yeah), maybe  
we can meet for a beer or wine and discuss the issue face to face.

hth,
Ciao

Bart
>
> Giacomo Vernoni
>
>
>
>
>
> On 18 lug 2007, at 19:08, Ruslan Zasukhin wrote:
>
>> On 18/7/07 6:46 PM, "Giacomo Vernoni" <giacomo at way-out.it> wrote:
>>
>>>>> 2) vfield.getstring() returns <Void> instead of an empty string if
>>>>> the field is empty or Null.
>>>> Not sure here. How then you do differ empty string value from NULL?
>>>> Ruslan?
>>>
>>> My opinion: a function that is called getstring() should always
>>> return a string... even if it is null, I'm asking to GET a STRING.
>>> Waiting for Ruslan...
>>
>> Note that we have
>>
>>     Vfield.IsNull()
>>
>> Method which allow check if value of ANY field type is NULL,
>> And if it is not then READ value
>>
>> -- 
>> Best regards,
>>
>> Ruslan Zasukhin
>> VP Engineering and New Technology
>> Paradigma Software, Inc
>>
>> Valentina - Joining Worlds of Information
>> http://www.paradigmasoft.com
>>
>> [I feel the need: the need for speed]
>>
>>
>> _______________________________________________
>> Valentina mailing list
>> Valentina at lists.macserve.net
>> http://lists.macserve.net/mailman/listinfo/valentina
>>
>
> _______________________________________________
> Valentina mailing list
> Valentina at lists.macserve.net
> http://lists.macserve.net/mailman/listinfo/valentina


More information about the Valentina mailing list