Subject Re: DBF level 4 to 7 Problem
From Akshat Kapoor <akshat.kapoor@kapoorsons.in>
Date Tue, 14 Mar 2017 21:20:05 +0530
Newsgroups dbase.getting-started

> 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