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


#if @HELP_CLEARHISTORY

    CLEARHISTORY

    Purpose:
             Deletes the user history file.

    Format:
             CLEARHISTORY("histfile")

              "histfile" - Optional. A string, the name of the history file
                           to delete. Defaults to current history file.

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

    Example:
             setconfig("history_logging", 1);

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

             viewhistory

             clearhistory

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

    Remarks:
             The history file contains user input text only, no informational
             or error messages are saved.

             CLEARHISTORY deletes the history file, if any. If history logging
             is enabled, a new, empty history is opened.

             See CLEARLOG to delete the log file.

    See Also:
             Clearlog
             Monitor
             Viewhistory
             Viewlog
#endif


/* delete history file */
clearhistory(histfile, verbose)
{
        local status;

        if (argc < 2)
        {
                if (argc < 1)
                {
                        histfile = getconf("history_logname");
                }

                verbose = 1;
        }

        /* special mode to delete */
        status = historylog(histfile, -100, verbose);

        return(status);
}