home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Utilities / QuickFile / ARexx / Append.quickfile < prev    next >
Text File  |  1999-12-18  |  2KB  |  63 lines

  1. /*
  2. $VER: Append.quickfile 1.2 (30-Nov-1999 22:00:20) by M Andre Z Eckenrode
  3. Appends or Prepends a string to a string field in all records in the current
  4. index.
  5. NOTE: There is currently no way to tell, via ARexx, whether a given string
  6. field is a calculated field or not.
  7. Requires v3.23 of QuickFile and (rexx)reqtools.library.
  8. */
  9.  
  10. options results
  11.  
  12. numrecs
  13. records = result
  14. soi = -1*(records-1)
  15. next '"'soi'"'
  16.  
  17. if ~show(l,'rexxreqtools.library') then call addlib('rexxreqtools.library',0,-30)
  18.  
  19. title = 'Append.quickfile'
  20. tags = 'reqf_centertext'
  21. choice = rtezrequest('Append or Prepend to Field?','Append|Prepend|Cancel',title,'rtez_flags = ez'tags)
  22. if choice = 0 then exit
  23.  
  24. which.1 = 'Ap'
  25. which.2 = 'Pre'
  26.  
  27. reqfield
  28. field = result
  29.  
  30. body = 'Enter string to be' which.choice'pended to contents of field'lf'«'field'»:'
  31. string = rtgetstring(,body,title,'  Ok  |Cancel','rtgs_flags = gs'tags)
  32. if string == '' then exit
  33.  
  34. lf = d2c(10)
  35. body = which.choice'pending'lf'"'string'"'lf'to contents of field'lf'«'field'».'lf'Continue?'
  36. goahead = rtezrequest(body,''which.choice'pend|Cancel',title,'rtez_flags = ez'tags)
  37. if goahead = 0 then exit
  38.  
  39. updates = 0
  40. noupdates = 0
  41.  
  42. do records
  43.     getfield '"'field'"'
  44.     value = result
  45.     if choice = 1 then newval = value||string
  46.     else newval = string||value
  47.     putfield '"'field'" "'newval'"'
  48.     if rc > 0 then do
  49.     body = 'Unable to' which.choice'pend'lf'"'string'"'lf'to contents of field'lf'«'field'».'lf'Is the field type compatible?'
  50.     call rtezrequest(body,'Exit',title,'rtez_flags = ez'tags)
  51.     exit
  52.     end
  53.     updrec
  54.     if rc = 0 then updates = updates+1
  55.     else noupdates = noupdates+1
  56.     next
  57. end
  58.  
  59. refresh
  60. body = 'Completed!'lf||updates 'record(s) successfully updated.'lf'Update
  61. failed for' noupdates 'record(s).'
  62. call rtezrequest(body,'Done',title,'rtez_flags = ez'tags)
  63.