/// FR_ALLFILES search flag implementation

var FR_DOWN       =0x00000001
var FR_MATCHCASE  =0x00000004
var FR_UP         =0x00100000
var FR_BEGINNING  =0x00200000
var FR_SELECTION  =0x00400000
var FR_ESCAPESEQ  =0x00800000
var FR_ALLFILES   =0x01000000

//Options
var pSearchString="MyString";
var nSearchFlags=0x01200001 /*FR_DOWN|FR_BEGINNING|FR_ALLFILES*/;

var hMainWnd=AkelPad.GetMainWnd();
var hWndFrameInit=AkelPad.SendMessage(hMainWnd, 1288 /*AKD_FRAMEFIND*/, 1 /*FWF_CURRENT*/, 0);
var hWndFrameCurrent=hWndFrameInit;

while (hMainWnd)
{
  nSearchFlags|=FR_BEGINNING;
  if (hWndFrameCurrent == hWndFrameInit)
    if (AkelPad.GetSelText() == pSearchString)
      nSearchFlags&=~FR_BEGINNING;

  if (AkelPad.TextFind(AkelPad.GetEditWnd(), pSearchString, nSearchFlags) != -1)
    break;

  if (nSearchFlags & FR_ALLFILES)
  {
    //Next MDI frame
    AkelPad.SendMessage(hMainWnd, 273 /*WM_COMMAND*/, 4316 /*IDM_WINDOW_FRAMENEXT*/, 0);
    hWndFrameCurrent=AkelPad.SendMessage(hMainWnd, 1288 /*AKD_FRAMEFIND*/, 1 /*FWF_CURRENT*/, 0);
    if (hWndFrameCurrent == hWndFrameInit)
    {
      AkelPad.MessageBox(hMainWnd, "\"" + pSearchString + "\" not found.", WScript.ScriptName, 48 /*MB_ICONEXCLAMATION*/);
      break;
    }
  }
  else break;
}