/*
** Send command for ListServ Auto Responder
** By Tom Bampton
**
** (c) Copyright 1996 Tom Bampton
**     All Rights Reserved.
*/

/*
** Configuration:
**
** See the example ListServ.config for the autorespond list config
**
** A directory in the ListPath called Text must be created
**
** Write your text files in there
**
** Set the file comment (use DOpus, WB or the CLI FileNote command) with a
** little text about the file
*/

/* Set this to the filename you set in OutFile in the ListServ.config */
Output = 'T:AutoRespond.Out' 

options results

parse arg ListPath FileName

a = right(ListPath,1)
if a ~= ":" & a ~= "/" then ListPath = ListPath"/"

if FileName = '' then do
	
	/* No filename specified, send a listing of files */
	if open(fp, Output, 'w') then do
		
		call writeln(fp, 'Syntax: send [filename]')
		call writeln(fp, ' ')
		call writeln(fp, 'Send will send you the requested help file, or a list')
		call writeln(fp, 'of available files if no filename is specified')
		call writeln(fp, ' ')
		call writeln(fp, 'Available Files:')
		call writeln(fp, ' ')
		
		call close(fp)
		
		address command 'C:List >>'Output' 'ListPath'Text/ lformat "%s - %c"'
		
	end
	
	exit
	
end

/* Send the file */

FileName = right(FileName, length(FileName) - 1)

if open(fp, ListPath'Text/'FileName, 'r') then do
	
	if open(op, Output, 'w') then do
		
		do while ~eof(fp)
			
			in = readln(fp)
			call writeln(op, in)
			
		end
		
		call close(op)
		
	end
	
	call close(fp)
	
end

exit
