/* SaveFile.xdme */
/* Copyright © 1994 Fergus Duniho */

if ~show("L","rexxsupport.library") then
    if ~addlib("rexxsupport.library",0,-30,0) then exit

options results
address 'XDME.1'
'rxresult $method'
method = result
compressor = "LIBS:compressors/xpk" || method || ".library"
'rxresult $filename'
fullname = result

if method = "NONE" || ~exists(compressor) then do
    saveold
end
else do
    'writeto t:temp'
    'rxresult $password'
    password = result
    if password = "RESULT" then
        xcom = 'execute (xpack t:temp method' method || ')'
    else
        xcom = 'execute (xpack t:temp method' method 'password "' || password || '")'
    xcom
    xcom = "execute (copy t:temp """ || fullname || """)"
    xcom
    call delete("t:temp")
end
