/* UUxT4Spot v1.0 */
/* 1-5-1994 */
/* © 1994 Daniel Smith */

/* This is a front-end for use with Spot and the excellent UUcoder util, */
/* UUxT. If you haven't got this uudecoder, this script won't be any use */
/* to you. I recommend you try UUxt though. It's the best uucoder I've seen */

/* Thanks go to Asher Feldman for UUxT and Nico Francois for Spot */

/* Contact me with comments, suggestions, bugreports etc... */
/* Internet: daniel.smith@portofc.org */
/* Fidonet : 2:254/149.5              */

address 'SPOT'
options results

/* You will probably need to change the paths below */
path='DH0:Uploads' /* The default dir for the encode filerequester */
decodedpath='RAM:' /* The default dir for the decode pathrequester */
file='T:Spot.temp' /* The Spot edit file - find under Settings,    */
                   /* General in Spot */

/* Don't change anything else */
title='UUxT4Spot v1.0 © 1994 Daniel Smith'
prompt='Please select the UU option required:'

'isarealist'
if rc=0 then call warn()

'requestresponse TITLE "'title'" PROMPT "'prompt'" GADGETS "_Decode|_Encode|_Cancel"'
IF RC=0 then exit
code=RC

IF code=2 then do
/* Encode */
'requestfile TITLE "Choose file to uuencode:" PATH "'path'"'
IF RC~=0 then exit
uufile=result
lha=1
if right(uufile,4)~='.lha' then call asklha()
address command
IF lha=1 then 'UUxT a "'file'" "'uufile'"'
address 'SPOT'
IF lha=2 then do
    lha='.lha'
    'requeststring TITLE "Enter .lha filename"'
    lhafile=result
    address command
    'UUxt l "'file'" "'lhafile'" "'uufile'"'
end
address 'SPOT'
'write FILE "'file'"'

exit
end

IF code=1 then do
/* Decode */
'saveascii TO "'file'" OVERWRITE NOHEADER NOTEARLINE NOORIGIN NOKLUDGES NOREFLOW'
'requestpath TITLE "Select directory" PATH "'decodedpath'"'
decodedpath=result
oldcd=pragma('d',decodedpath)
address command
'UUxt x "'file'"'
call pragma('d',oldcd)
end

exit

asklha:
'requestresponse TITLE "'title'" PROMPT "Do you wish to use LhA?" GADGETS "_No|_Yes|_Cancel"'
IF RC=0 then exit
lha=RC
return

warn:
'requestnotify PROMPT "Use only from message window or list!"'
exit

