/*
$VER: Log2Info 1.0 (13.2.97)
(c)  Neil Bothwick <neil@wirenet.co.uk> 1997
*/

/* Adds the contents of a temporary logfile      */
/* to the Information conference                 */

/* Set ConnectTHOR of Get/SendTCP to log to the file       */
/* specified in InfoLog. If you also want the information  */
/* logged to a permanent file, specify the name in MainLog */

MainLog     = 'UUSpool:Connect.log' /* Name of main logfile to copy to, leave blank if you don't want a copy */
InfoLog     = 'UUSpool:Info.log'    /* Temporary logfile to be added to Information conference */
System      = 'Wirenet'             /* The system containing your information conference */
Conf        = 'Information'         /* The name of your information conference */
ShowStartup = 0                     /* Set to 1 to show Startup/Exit messages */

/* Don't change anything below here */

options results
address command

if ~exists(InfoLog) then exit

/* Load bbsread.library if necessary */
if ~show('p', 'BBSREAD') then do
    address command
    "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
    "WaitForPort BBSREAD"
    end

/* Copy temporary log contents to main logfile */
/* moved to ShowLog
if symbol('MainLog') = 'VAR' & MainLog > '' then 'type' InfoLog '>>'MainLog
*/

if ~open(log,InfoLog,'R') then exit
drop MsgData.
MsgData.TEXT.COUNT = 0
body = ''

/* Read log file */
do while ~eof(log)
    line = readln(log)
    if ShowStartup = 0 & (word(line,3) = 'STARTUP' | word(line,3) = 'EXIT') then iterate
    MsgData.TEXT.COUNT = MsgData.TEXT.COUNT + 1
    interpret 'MsgData.TEXT.'MsgData.TEXT.COUNT '= line'
    end
call close(log)

/* Write message to conference */
address BBSREAD
MsgData.FROMNAME = 'Log2Info'
MsgData.SUBJECT = 'Log information'
'WRITEBRMESSAGE "'System'" "'Conf'" stem MSGDATA'
if RC > 0 then say BBSREAD.LASTERROR

address command
'delete >NIL:' InfoLog

