// http://akelpad.sourceforge.net/forum/viewtopic.php?p=10810#10810
// Version: 1.0
// Author: Shengalts Aleksander aka Instructor
//
//
// Description(1033): Clear recent files list.
// Description(2052): 清除最近文件列表。
//
// Arguments:
// -Msg=false  -Clear recent files list without prompt (default is true).
//
// Usage:
// Call("Scripts::Main", 1, "ClearRecentFiles.js", `-Msg=false`)

//Arguments
var bMsg=AkelPad.GetArgValue("Msg", true);

//Variables
var hWndMain=AkelPad.GetMainWnd();

if (bMsg)
{
  if (AkelPad.MessageBox(hWndMain, GetLangString(0), WScript.ScriptName, 0x24 /*MB_ICONQUESTION|MB_YESNO*/) == 7 /*IDNO*/)
    WScript.Quit();
}
AkelPad.SendMessage(hWndMain, 1238 /*AKD_RECENTFILES*/, 5 /*RF_CLEAR*/, 0);
AkelPad.SendMessage(hWndMain, 1238 /*AKD_RECENTFILES*/, 4 /*RF_SAVE*/, 0);

function GetLangString(nStringID)
{
  var nLangID=AkelPad.GetLangId(1 /*LANGID_PRIMARY*/);

  if (nLangID == 0x4) //LANG_CHINESE
  {
    if (nStringID == 0)
      return "要清除文件历史记录吗?";
  }
  else
  {
    if (nStringID == 0)
      return "Clear recent files list?";
  }
  return "";
}
