V4MD - <null> results with lingo

Giacomo Vernoni giacomo at way-out.it
Thu Jul 19 04:32:48 CDT 2007


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.

I've got a necessity. I think it's not a strange one. Many times I  
need to get a string from vfields: empty, null or with content.  
Because in Director I can't assign <Void> to a member 
("mymember").text. I may need to convert numeric vfields to strings too.

I can do in many ways; let's pretend that the vfield.value bug is  
solved and I get a <Void> result from vfield.value if the field is  
null/empty (not the <Null> we get now that's incorrect in lingo).

1)
myText = string(vcursor.field("fld_varchar").value) -- I'm using  
lingo string() function
myNumberAsAString = string(vcursor.field("fld_byte").value) -- I get  
a string from a byte field if I need it

note that

put string(void)
-- ""

2)
if voidP(vcursor.field("fld_varchar").value) then -- this works (will  
work) with empty and null vfields
   myText = ""
else
   myText = vcursor.field("fld_varchar").value
end if

if voidP(vcursor.field("fld_byte").value) then
   myNumberAsAString = ""
else
   myNumberAsAString = string(vcursor.field("fld_byte").value)
end if


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


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.

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.

Sorry for my long post.

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
>



More information about the Valentina mailing list