// http://akelpad.sourceforge.net/forum/viewtopic.php?p=13321#13321
// Version: 2015-09-19
// Author: KDJ
//
// *** Inserts folder name using SHBrowseForFolder function ***
//
// Alternative version with AkelPad.Include("BrowseForFolder_function.js").
// Script BrowseForFolder_function.js must be placed in directory ...\AkelPad\AkelFiles\Plugs\Scripts\Include\
//
// Usage:
//   Call("Scripts::Main", 1, "InsertFolderName_alternative.js")

var hEditWnd = AkelPad.GetEditWnd();
var sFile    = AkelPad.GetEditFile(0);
var sText    = "请选择文件夹:";
var sDir     = "";
var sTitle   = "插入文件夹名称";

if ((hEditWnd) && AkelPad.Include("BrowseForFolder_function.js"))
{
  if (sFile)
    sDir = sFile.substr(0, sFile.lastIndexOf("\\") + 1);

  sDir = BrowseForFolder(hEditWnd, sText, sDir, sTitle);

  if (sDir)
    AkelPad.ReplaceSel(sDir, -1);
}
