home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Utilities / QuickFile / ARexx / GetSet.quickfile < prev    next >
Text File  |  2000-05-26  |  2KB  |  96 lines

  1. /*
  2. $VER: GetSet.quickfile 1.8 (26 May 2000  14:59:51) by M Andre Z Eckenrode
  3.  
  4. Sets <field2> to value retrieved from <field1> in all records in the current
  5. index.
  6.  
  7. Requires QuickFile v3.24 or higher, (rexx)reqtools.library and the following
  8. external function macros:
  9.  
  10.   FixQuotes.quickfile
  11.   ReSort.quickfile
  12.   ProgressWin.quickfile
  13.   GetViewWin.quickfile
  14.  
  15. */
  16.  
  17. options results
  18.  
  19. lib = 'rexxreqtools.library'
  20. if ~show(l,lib) then call addlib(lib,0,-30)
  21.  
  22. lf = d2c(10)
  23. pre = 'Select field to'
  24. body.1 = 'retrieve value(s) from...'
  25. body.2 = 'set with value(s) from field'lf
  26. gads = '_Ok'
  27. title = 'GetSet.quickfile'
  28. eztag = 'rtez_flags = ezreqf_centertext'
  29. tags = eztag
  30.  
  31. do i = 1 to 2
  32.     body = pre body.i
  33.     if i = 2 then body = body'«'fld.1'»...'
  34.     call notify
  35.     if i = 1 then reqfield
  36.     else reqfield nocalc
  37.     if rc = 5 then exit
  38.     fld.i = upper(result)
  39. end
  40.  
  41. numrecs
  42. recs = result
  43.  
  44. body = 'Setting field'lf'«'fld.2'»'lf'to value(s) of field'lf'«'fld.1'»'lf'in' recs 'record(s).'lf'Are you sure?'
  45. gads = '_Yes| _No'
  46. tags = eztag'|ezreqf_noreturnkey'
  47. call notify
  48. if choice = 0 then exit
  49.  
  50. ndx = 'arexx/resort'(fld.2)
  51. parse var ndx code ' ' ndx
  52. if code > 1 then exit
  53. else if code = 1 then do
  54.     body = 'All available fields to be modified.'lf'No unused field to re-sort database with.'lf'Records may be operated on inconsistently.'
  55.     gads = '_Proceed|  _Exit '
  56.     call notify
  57.     if choice = 0 then exit
  58. end
  59.  
  60. soi = -1*(recs-1)
  61. next '"'soi'"'
  62.  
  63. esc = d2c(27)
  64. line = '  Working...Record '
  65. winspec = 'arexx/progresswin'(length(line)+(2*length(recs))+4,title)
  66. call open(1win,winspec,'w')
  67. call writech(1win,esc'[0 p'lf||line)
  68.  
  69. ups = 0
  70. noups = 0
  71. do i = 1 to recs
  72.     call writech(1win,esc'[2;20f'i 'of' recs)
  73.     getfield '"'fld.1'"'
  74.     fldval = result
  75.     if pos('"',fldval) > 0 then fldval = 'arexx/fixquotes'(fldval)
  76.     putfield '"'fld.2'" "'fldval'"'
  77.     updrec
  78.     if rc = 0 then ups = ups+1
  79.     else noups = noups+1
  80.     next
  81. end
  82.  
  83. call close(1win)
  84. setindex '"'ndx'"'
  85.  
  86. refresh
  87. body = 'Completed!'lf||ups 'record(s) updated successfully.'lf'Update failed for' noups 'record(s).'
  88. gads = '_Done'
  89. tags = eztag
  90. call notify
  91. exit
  92.  
  93. notify:
  94.     choice = rtezrequest(body,gads,title,tags)
  95. return
  96.