home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxtools.zip / dbf2txt.cmd < prev    next >
OS/2 REXX Batch file  |  1999-04-15  |  999b  |  44 lines

  1. /* DBF to text converter by cygnus, 2:463/62.32 */
  2.  
  3. parse arg fname
  4. if fname \= '' then
  5. do
  6.  i=0
  7.  rc=reverse(charin(fname,5,4))
  8.  records=c2d(rc)
  9.  
  10.  perc=records%30+1
  11.  rc=charin(fname,1,32)
  12.  test=charin(fname)
  13.  
  14.  do while test \= '0d'x
  15.     i=i+1
  16.     fieldname.i=test||charin(fname,,10)
  17.     type.i=charin(fname)
  18.     rc=charin(fname,,4)
  19.     len.i=c2d(charin(fname))
  20.     rc=charin(fname,,15)
  21.     rc=charout('DBFout.txt',fieldname.i type.i len.i||'0d0a'x)
  22.     test=charin(fname)
  23.  end
  24.  
  25.  fields=i
  26.  rc=charout('DBFout.txt','0d0a'x)
  27.  do i=1 to fields
  28.         rc=charout('DBFout.txt',left(fieldname.i,len.i)' ')
  29.  end
  30.  rc=charout('DBFout.txt','0d0a0d0a'x)
  31.  rc=charout(,'Creating DBFout.txt ')
  32.  
  33.  do a=1 to records
  34.     call charin(fname)
  35.     if a//perc=0 then rc=charout(,'▒')
  36.     do i=1 to fields
  37.         rc=charin(fname,,len.i)
  38.         rc=charout('DBFout.txt',rc' ')
  39.     end
  40.     rc=charout('DBFout.txt','0d0a'x)
  41.  end
  42.  call charout 'DBFout.txt','0d0a'x||records 'records total.'
  43. end
  44. else say 'Usage: dbf2txt [DBFname.dbf]'