/* Passages: Spot Interface (Import)                     *
 * Both this script and Passages are © 1994 PSR Software */

/* $VER: Passages.import.spot 2.4 */

Address SPOT
Options Results

PATH="Passages:"

'IsMessages'
if ~(rc=0) then do
   'requestnotify PROMPT "Use only from message window"'
   exit
end

file=path || 'Passages.input'
'requestresponse PROMPT "Save as 'file'" GADGETS "_Yes|_No|_Abort"'
if rc=0 then exit
if rc=2 then do
   'requestfile TITLE "Select..." PATH "'PATH'"'
   if rc>0 then exit
   file=result
end

address command Copy '"'file'"' '"'file'.bak"'
'saveascii TO "'file'" NOHEADER NOTEARLINE NOORIGIN NOKLUDGES NOREFLOW'

if ~open('in',file,'r') then do
   'requestnotift PROMPT "Disk error!"'
   exit
end

c=0
do while ~eof('in')
   c=c+1
   line.temp=readln('in')
   line.c=translate(line.temp,'0123456789- ','PSR software')
end
call close('in')

if ~open('out',file,'w') then do
   'requestnotify PROMPT "Disk error!"'
   exit
end
if c=0 then do
   'requestnotify PROMPT "Empty file"'
   exit
end
do n=1 to c
   call writeln('out',line.n)
end
call close('out')

'requestnotify PROMPT "All done"'
