home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 13
/
AACD13.ISO
/
AACD
/
Utilities
/
QuickFile
/
ARexx
/
SetField.quickfile
< prev
next >
Wrap
Text File
|
2000-05-26
|
3KB
|
132 lines
/*
$VER: SetField.quickfile 1.13 (26 May 2000 14:58:08) by M Andre Z Eckenrode
Sets the designated field to a constant value in all records in the current
index; OR appends or prepends the existing field value in each record with the
string entered, at user's discretion.
It is assumed that the designated field is to be set to an empty string if SET
FIELD is selected while the requester string gadget is empty, or CANCEL is
selected, but the operation may still be cancelled via the subsequent
confirmation requester.
Requires QuickFile v3.24 or higher, (rexx)reqtools.library and the following
external function macros:
FixQuotes.quickfile
ReSort.quickfile
ProgressWin.quickfile
GetViewWin.quickfile
*/
options results
lib = 'rexxreqtools.library'
if ~show(l,lib) then call addlib(lib,0,-30)
body = 'Select field to set value of...'
gads = ' _Ok |_Cancel'
title = 'SetField.quickfile'
tag = 'reqf_centertext'
eztag = 'rtez_flags = ez'tag
tags = eztag
call notify
if choice = 0 then exit
reqfield nocalc
if rc = 5 then exit
fld = upper(result)
lf = d2c(10)
body = 'Would you like to Append or Prepend to Field'lf'«'fld'»?'
gads = ' _Append | _Prepend |_Set Field'
eztags = eztag'|ezreqf_noreturnkey'
tags = eztags
call notify
op = choice
which.0 = 'Set'
which.1 = 'Append'
which.2 = 'Prepend'
to.0 = 'to'
to.1 = 'with'
to.2 = to.1
val = rtgetstring(,which.op 'field'lf'«'fld'»'lf||to.op 'value:',title,'_'which.op,'rtgs_flags = gs'tag)
if sign(op) & ~rtresult then do
body = 'No value entered'
gads = '_Exit'
tags = eztag
call notify
end
body = which.op||copies('t',abs(sign(op)-1))'ing field'lf'«'fld'»'lf||to.op 'value'lf'"'val'".'lf'Are you sure?'
gads = '_Yes| _No'
tags = eztags
call notify
go = choice
if go = 0 then exit
ndx = 'arexx/resort'(fld)
parse var ndx code ' ' ndx
if code > 1 then exit
else if code = 1 then do
body ='All available fields to be modified.'lf'No unused field to re-sort database with.'lf'Records may be operated on inconsistently.'
gads = '_Proceed| _Exit '
call notify
if choice = 0 then exit
end
numrecs
recs = result
soi = -1*(recs-1)
next '"'soi'"'
ups = 0
noups = 0
esc = d2c(27)
line = ' Working...Record '
winspec = 'arexx/progresswin'(length(line)+(2*length(recs))+4,title)
call open(1win,winspec,'w')
call writech(1win,esc'[0 p'lf||line)
do i = 1 to recs
call writech(1win,esc'[2;20f'i 'of' recs)
getfield '"'fld'"'
fldval = result
select
when op = 1 then newval = fldval||val
when op = 2 then newval = val||fldval
otherwise newval = val
end
if pos('"',newval) > 0 then newval = 'arexx/fixquotes'(newval)
putfield '"'fld'" "'newval'"'
if rc = 5 then do
body = 'Unable to' which.op 'field'lf'«'fld'»'lf||to.op 'value'lf'"'val'".'lf'Is the field type compatible?'
gads = '_Exit'
tags = eztag
call notify
exit
end
updrec
if rc = 0 then ups = ups+1
else noups = noups+1
next
end
call close(1win)
setindex '"'ndx'"'
refresh
body = 'Completed!'lf||ups 'record(s) updated successfully.'lf'Update failed for' noups 'record(s).'
gads = '_Done'
tags = eztag
call notify
exit
notify:
choice = rtezrequest(body,gads,title,tags)
return