Recording Usage of Custom Tools

This facility allows you to easily record who is using your custom tools and when. This will write an entry to the log which can be viewed later using the Tool Usage Viewer.

Usage is as follows:

recordUsage("My Tool Name", "Additional Comment")

Save the code below in an include file and #include in your script.

//  

/*
	Record usage of custom tools

	Tony Goodman	

*/

/********************
	recordUsage

	Write user name and date to the specified configuration file.
**********************/
void recordUsage(string toolName, string toolVersion, string comment)
{
	Buffer b = create
	string CONF_DIR = "tool_usage"

	ConfStream conf = null

	if (!confFileExists(CONF_DIR, confSystem))
    {
        // add directory
        confMkdir(CONF_DIR, confSystem)
    }

	if (!confFileExists(CONF_DIR "\\" toolName, confSystem))
    {
		conf = confWrite(CONF_DIR "\\" toolName, confSystem)
	}
	else
	{
		conf = confAppend(CONF_DIR "\\" toolName, confSystem)
	}

	if (!null conf)
	{
		conf << toolName "\t" toolVersion "\t" stringOf(dateAndTime(today)) "\t" doorsname "\t" comment "\n"

		close(conf)
	}
}

/*********************
	recordUsage

	Write user name and date to the specified configuration file.
**********************/
void recordUsage(string toolName, string comment)
{
	recordUsage(toolName, "", comment)
}