'KEYS_UPD - rebuild all keys in standard views

external   dpath messbox() vloadif() vunloadif() progress() progtag() fgi bgi
external   sch scw remove() fgp bgp strcount()

public     ptstr ptval

global     x $module $file y $out strc

MAIN

single-step off
  file unload all
  screen clear box 1 1 sch scw 0 0 no-border
  repaint off
  $out = "C:\overnite.txt"
  remove("C:\viewlist.txt")
'   tools os "dir S:\data\*.vws /O:N /B > C:\viewlist.txt"
'   progress(fgp,bgp," Reading fields in custom screens ",1)

'   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("S:\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("S:\data\*.vws",0),y)
message "$file) is:"&str($file)
'   CompileFiles()
    if left($file,2)="A_"
      continue for
    elseif len($file)=0
      exit for
    end if
    repaint off
    x=vloadif(dpath|$file)   'message "x is:"&str(x)
    repaint off
    progtag(fgi,bgi,$file)
    order key rebuild
    if cerror
      message $file&"- keys not rebuilt"
    else
      fopen $out as 2
      fseek 2 EOF
      fwrite 2 from ""
      fwrite 2 from $file&"- keys updated at"&time24
      fclose 2
    end if
    vunloadif($file)


'   end while
end for



  progress(15,9," Rebuilding keys for data files ",1)
  fopen "C:\viewlist.txt" as 4
  while eof(4) = 0
    fread 4 into $file      '
message "$file is:"&str($file)
    if left($file,2)="A_"
      continue while
    elseif len($file)=0
      exit while
    end if
    repaint off
    x=vloadif(dpath|$file)   'message "x is:"&str(x)
    repaint off
    progtag(fgi,bgi,$file)
    order key rebuild
    if cerror
      message $file&"- keys not rebuilt"
    else
      fopen $out as 2
      fseek 2 EOF
      fwrite 2 from ""
      fwrite 2 from $file&"- keys updated at"&time24
      fclose 2
    end if
    vunloadif($file)
  end while
END MAIN
