View Raw SPL
/*****************************************************************************
*                                                                            *
*   CLEARLOG.SPL  Copyright (C) 2023 DSP Development Corporation             *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Delete user LOG file                                        *
*                                                                            *
*   Revisions:   27 Jun 2023  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/


#if @HELP_CLEARLOG

    CLEARLOG

    Purpose:
             Deletes the user log file.

    Format:
             CLEARLOG("logfile")

              "logfile" - Optional. A string, the name of the log file
                          to delete. Defaults to current log file.

    Returns:
             An integer, 1 if the log file was successfully deleted,
             else 0.

    Example:
             setconfig("message_logging", 1);

             W1: rand(10);
             W2: integ(w1)

             viewlog

             clearlog

             Message logging is enabled for the session. The current
             contents of the log file is displayed. The log file
             is then deleted. Because message logging was enabled, a new
             log file is automatically opened.

    Remarks:
             CLEARLOG deletes the log file, if any. If message logging
             is enabled, a new, empty log is opened.

             See CLEARHISTORY to delete the history file.

    See Also:
             Clearhistory
             Monitor
             Viewhistory
             Viewlog
#endif


/* delete log file */
clearlog(logfile, verbose)
{
        local status;

        if (argc < 2)
        {
                if (argc < 1)
                {
                        logfile = getconf("message_logname");
                }

                verbose = 1;
        }

        /* special mode to delete */
        status = messagelog(logfile, -100, verbose);

        return(status);
}