Page 1 of 1

ISBLANK() function

Posted: Thu Mar 05, 2020 3:07 am
by Victorio
Hi,
Exist some replacement for function ISBLANK() (Visual Foxpro) ?

I need determine numeric field in DBF database (no SQL, only VFP DBF) when value is blank or 0
Function empty() return .T. in both variants but VFP function return .T. only when numeric field is blank.

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 4:01 am
by Auge_Ohr
Hi,
Victorio wrote: Exist some replacement for function ISBLANK() (Visual Foxpro) ?

I need determine numeric field in DBF database (no SQL, only VFP DBF) when value is blank or 0
Function empty() return .T. in both variants but VFP function return .T. only when numeric field is blank.
have a look at "SET NULLVALUE"

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 4:38 am
by Victorio
Hi Jimmy,
I found SET NULLVALUE, I am testing also ON OFF, but no effect.
Only when I add NULL parameter to structure in Visual Foxpro and then when I add NIL value to field , then can test ISNULL()

But I do not know how add NUL parameter to DBF structure from Xbase++

this do not work not accept parameter nullable, however this is in Xbase++ manual in example for function

Code: Select all

aStruct:=DbStruct()
aadd(aStruct,{'TYP_ZM','N',2,0,"nullable"})
lupdstru:=DC_STRUUPDATE(aStruct,,,,.F.)
but this do not work not accept parameter nullable, however this is in Xbase++ manual in example for function :

// The sample illustrates how DbSetNullValue()
// affects the Null value representation of a
// field which is nullable.
PROCEDURE Main()
LOCAL aStructure := {}

AAdd( aStructure , { "LASTNAME" , "C" , 20 , 0 } )
AAdd( aStructure , { "REVENUE" , "N" , 8 , 2 , "nullable" } )
AAdd( aStructure , { "CONTACT" , "D" , 8 , 0 , "nullable" } )

DbCreate("Customer",aStructure,"FOXCDX")
USE Customer EXCLUSIVE VIA FOXCDX

DbAppend()
FIELD->LASTNAME := "Joe Doe"

// result: "Joe Doe 0 . . "
//
DbSetNullValue(.F.)
? FIELD->LASTNAME, FIELD->REVENUE, FIELD->CONTACT

// result: "Joe Doe NIL NIL"
//
DbSetNullValue(.T.)
? FIELD->LASTNAME, FIELD->REVENUE, FIELD->CONTACT

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 4:43 am
by rdonnay
There are no NULL values in a DBF file.

You should use Empty() instead of IsBlank().

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 5:23 am
by Victorio
Hi Roger,
In Visual Foxpro ver 5 I can add NULL parameter for any fields in DBF file.
After this I can put NIL value to dbf also from Xbase++ and after this test with ISNULL() and this works.

Only problem I have, that I cannot change structure DBF file from Xbase , only from Visual Foxpro. It is oddly, because after add NULL Xbase also accept this and enable write .NULL. to dbf.
Here are printscreens from VFP where dialog for modify structure and after this in one row .NULL. value

and empty() function not distinguish between no value and zero when numeric fields.

And here :
Structure of e0050898
Field/name type length offset fieldflag AutoIncr AutoIncr
in rec NextValue StepValue
----------------------------------------------------------------------
1 CPA N 9.0 1
2 CPU N 2.0 10 Null values ok
3 VYM N 8.0 12 Null values ok
4 KVV N 1.0 20
5 DRP N 2.0 21

is visible than parameter Null values ok for DBF file.

But I mean, know where is problem, it looks to problem with struupdate where Xbase have only 4 elements for structure and this NULL is 5th.
Or something around this.

Now I have only way to create own sample databases with VFP and use it to copy content tables in XBase, when I need use NULL values.

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 8:03 am
by rdonnay
You may be able to do this by using ADS and local server via a SQL statement.

This can be done entirely in Xbase++ code.

Let me know if this interests you and I will dig into this for you.

I will need a copy of your database (with nulls) to write a test program.

Do do not need to purchase ADS for this because it uses only the client-side DLLs.

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 8:33 am
by Victorio
Thank you for answer. Now I test create dbf with DbCreate, this looks will work .
When create dbf with structure in aStruct array and have also "nullable" element, database created.
Only with DC_Struupdate later, when DBF is already created cannot change this element. But this is not problem, when I can use DbStruct.

Only I need test it because some time ago I had problem with open database created in Xbase in Visual Foxpro when created with DbCreate When create with Copy stru to this works.

I will write, if my solution will not work.
I am interesting about ADS but this work only with proffesional edition Xbase++ , right ?
I have Foundation.

Re: ISBLANK() function

Posted: Thu Mar 05, 2020 9:45 am
by rdonnay
I am interesting about ADS but this work only with proffesional edition Xbase++ , right ?
Yes, that is correct. It requires ADSDBE.

Re: ISBLANK() function

Posted: Fri Mar 06, 2020 2:40 am
by Victorio
Hi,
At this moment I have some solution.
First before open any database I set DbSetNullvalue(.F.)
without it if in DBF file is nullable enabled for some field, indexing CDX crashing
Next I can store .NULL. values to fields in database

when I want test if field is .NULL. I must DbSetNullvalue(.T.) , this works fine

but after processing using NULL values I must remove all NULL values from DBF , this mean replace it with zero, "" or blank date,
without it program crashing when use set order to... with error index key not enabled null values or something like this.

Now I testing if no other problem will be with this system.