'FILE-FIX - file-fix all DATA files in directory
external   strtoary() fgi bgi fgp bgp progress() progtag() sch scw vloadif()
external   messbox() remove() vunloadif()
external   strcount()

public     ptary[1] ptval $file #rec_st #rec_fin ptstr

global     names i nextproj firstline x  $files nextdrive y
global     $module $c CompileFiles() strc

MAIN
single-step off
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
'   quiet off
  error off
message "Hard coded for drive C:\SW2000"
'   remove("C:\data.txt")
' single-step on
'   tools os "dir C:\SW45\DATA\*.db /O:N /B > C:\data.txt"
  progress(fgp,bgp," Reading data files ",0)
'   fopen "C:\data.txt" as 4

  x=getfnames("C:\SW2000\data\*.vws",0)
' message x
  if strcount(x)=0
    message "There are"&str(ptval)&"items in the list"
  end if
strc=ptval
for y=1 to strc
'   while eof(4) = 0
'     fread 4 into $file
  $file=group(getfnames("C:\SW2000\data\*.vws",0),y)
' message "$file) is:"&str($file)
  CompileFiles()
'   end while
end for
'   fclose 4
END MAIN


FUNCTION CompileFiles()
local $module  y y1 y2 $filename
'   if $c = "Y"
' message "$file is:"&str($file)
    progress(fgp,bgp," File-fixing data files ",1)
    progtag(fgi,bgi,"VIEW "|$file)
    data utilities file-fix view "C:\SW2000\DATA\"|$file
    progtag(fgi,bgi,"DBASE "|$file)
    data utilities file-fix Smart4 "C:\SW2000\DATA\"|$file
    if cerror
      message $file|" not fixed"
    end if

'   vloadif(dpath|group($files,x)|".vws")
  vloadif("C:\sw2000\data\"|$file|".vws")
  progtag(fgi,bgi,"Updating keys for"&$file)
  order key rebuild
  if cerror
    message $file|".vws - keys not rebuilt"
  end if
  vunloadif($file|".vws")
END FUNCTION ' CompileFiles()

' data utilities file-fix data-file "F:\data\cust_ord"

