Subject Re: DBF level 4 to 7 Problem
From Peter <phb2020@hotmail.com>
Date Tue, 14 Mar 2017 12:28:44 -0400
Newsgroups dbase.getting-started

Akshat Kapoor Wrote:

> > As you have understood right from the start (and is noted in language reference when changing level), the change from Level 4 to 7 has changed any field that is empty to null.
> > Mervyn Bick's program is:
> >
> >
> >  q = new query()
> >  q.sql = "select * from 'c:\pat\data\patient.dbf'"
> >  q.active = true
> >  q.rowset.first()
> >  do while not q.rowset.endofset
> >      for n = 1 to q.rowset.fields.size
> >         if q.rowset.fields[n].type = "C"   // or "N"
> >            if q.rowset.fields[n].value = null
> >               q.rowset.fields[n].value = ""   // 0 for "N"
> >           endif
> >           ? q.rowset.fields[n].value
> >         endif
> >      next
> >      q.rowset.next()
> >  enddo
> >  q.active = false
> >
> > There are no empty number fields to mess with. Hopefully Logical fields are not affected.  But I do have some date fields that are empty, and are changed to null.  What string do I use to change these null date fields to empty strings?  Same as for Character fields, ie ""?  {} does not work, nor {  /  /    }, nor ctod(  /  /    ).
> > Peter
>
> Be very careful with logical fields also
> if the field is null then field = true and filed = false
> both will return false.
>
> in the above program replace
> if q.rowset.fields[n].type = "C"
> with a do case
> do case
> case q.rowset.fields[n].type = "C"
>         temp = " "
> case q.rowset.fields[n].type = "N"
>         temp = 0
> //repeat for all field types
> endcase
> if q.rowset.fields[n].value = null
>      q.rowset.fields[n].value = temp // the default value selected above
> endif
>
> Regards
> Akshat

But if field type is "D", what default value should be used?  "" as for Character field?  What value is in an empty date field?
As you wrote above:  
> if the field is null then field = true and filed = false
> both will return false.
did you mean to type field for filed?  Not sure I understand.
Peter