/* * Script to update %ETC%\qtsys.conf during Qt4 installation from WPI * Arguments: "var=value,var=value,var=value,..." */ '@echo off' parse arg aVars eol = '0D0A'x rc = rxFuncAdd('SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs') rc = SysLoadFuncs() etc = value('ETC',, 'OS2ENVIRONMENT') if (etc == '') then etc = value('ETC',, 'OS2ENVIRONMENT') if (etc == '') then etc = SysBootDrive() qt_conf = etc'\qtsys.conf' qt_conf.0 = 0 do while lines(qt_conf) i = qt_conf.0 + 1 qt_conf.i = linein(qt_conf) qt_conf.i.!d = 0 qt_conf.0 = i end call lineout qt_conf /* process aVars */ aVars.0 = 0 rest = strip(aVars) do while(rest \== '') parse var rest v','rest if (pos('=', v) = 0) then do /* delete */ if (symbol('aVars.v') == 'VAR') then do /* already exists, mark as deleted */ aVars.v.!d = 1 iterate end w = aVars.0 + 1 aVars.w = v aVars.v = '' aVars.v.!d = 1 aVars.0 = w end else do /* add/replace value */ parse var v v'='val v = strip(v) val = strip(val) val = Replace(val, '\(', '(') val = Replace(val, '\)', ')') val = translate(val, '/', '\') if (v \== '') then do if (symbol('aVars.v') == 'VAR') then do /* already exists, take new value */ aVars.v = val aVars.v.!d = 0 iterate end w = aVars.0 + 1 aVars.w = v aVars.v = val aVars.v.!d = 0 aVars.0 = w end end end /* search for [Paths] */ do p = 1 to qt_conf.0 if (strip(qt_conf.p) == '[Paths]') then leave end if (p > qt_conf.0) then do qt_conf.p = '[Paths]' qt_conf.p.!d = 0 qt_conf.0 = p end /* replace/delete existing values */ do i = p + 1 to qt_conf.0 parse var qt_conf.i v'='val v = strip(v) if (left(v, 1) == '[') then do /* next section reached, stop */ leave end if (v \== '') then do if (symbol('aVars.v') == 'VAR') then do if (aVars.v.!d) then do qt_conf.i.!d = 1 end else do qt_conf.i = v '= "'aVars.v'"' end drop aVars.v /* mark as processed */ end end end /* create a script to generate new qt_conf */ call SysFileDelete qt_conf do i = 1 to qt_conf.0 if (qt_conf.i.!d) then iterate /* skip deleted */ call lineout qt_conf, qt_conf.i if (i == p) then do /* insert new values */ do w = 1 to aVars.0 v = aVars.w if (symbol('aVars.v') == 'VAR') then call lineout qt_conf, aVars.w' = "'aVars.v'"' end end end exit Replace: procedure expose (Globals) parse arg str, s1, s2 l1 = length(s1) l2 = length(s2) i = 1 do while (i > 0) i = pos(s1, str, i) if (i > 0) then do str = delstr(str, i, l1) str = insert(s2, str, i-1) i = i + l2 end end return str