?
В стандартном окне замены есть кнопка "Найти далее" и "Заменить" - для пошаговой замены (т.е. для неё необходимо ещё действие/функция), а также кнопка "Заменить всё".
var hEditWnd= AkelPad.GetEditWnd();
var v=AkelPad.TextReplace(hEditWnd, "sio", "123", 0x00000001, false);
if (v > -1)
AkelPad.TextReplace(hEditWnd, "sio", "123", 0x00400001, false);
А ещё есть такой скрипт "AkelPadMethodsView.js" от KDJ, очень полезная штука.
The effect of TextReplace() with bAll==false, depends on whether matching text is selected in edit window.
1. If matching text is selected, TextReplace() replaces it and searches for the next occurrence,
- if the next was found, it will be selected and TextReplace() returns position of this next match,
- else -1 is returned.
2. If matching text isn't selected, TextReplace() don't replace, only searches for the next occurrence (so it works as TextFind()),
- if the next was found, it will be selected and TextReplace() returns position of this next match,
- else -1 is returned.
YuS
Дык, как же без AkelPadMethodsView.js. Пользуюсь со дня публикации. Я в описании «bAll false одна замена.» немного неразобрался. Читаю «замена», значит должон заменять, а он не заменяет.
т.е. для неё необходимо ещё действие/функция
Вот эта мысль у меня смутно брезжила, но не был уверен. Теперь всё ясно, спасибо.
KDJ wrote:The effect of TextReplace() with bAll==false, depends on whether matching text is selected in edit window.
...
KDJ! May be it should be added to AkelPadMethodsView.js, for there is no informationa of such behaviour of TextReplace with bAll == false and I got same misuse as previous authors did.
beotiger, этот скрипт в удобной форме показывает разделы содержимого файлов Script-Eng.txt/Script-Rus.txt.
В общем, это надо к Instructor-у обращаться, чтобы дополнить описание (наверное, лучше с готовыми вариантами), либо локально файл корректировать...
Instructor
When I try to close any modified document (from the script), then displays message box "Document was modified. Do you want to save it?" and AkelPad hangs. On Win-XP sometimes, and on Win-7 always.
Try this test:
Instructor
Could you add optional parameter bAll for AkelPad.TextFind:
AkelPad.TextFind(hHandle, pFindIt, nFlags, bAll);
Return Value
- if bAll is true, the return value is count of occurences.
var hMainMenu = CreateMainMenu();
...
//dwStyle=DS_SETFONT|WS_VISIBLE|WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX
...
AkelPad.CreateDialog(...)
В качестве эксперимента попробовал код отсюда (второй пример). Тот же результат.
Хотя так: "oSys.Call("user32::CreateWindowEx"...", все работает прекрасно.
Выложу полный код скрипта и попрошу помощи (наверное), только если у Вас ошибка не воспроизведется