| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
Никита Козин 01.02.2006 14:16 / 01.02.2006 14:21
Немного громозко и неудобно, но зато читабельно :)^if(...){
^rem{ *** комментарий ***}
^if(...){
^rem{ *** комментарий ***}
}{
^rem{ *** комментарий ***}
^if(...){
^rem{ *** комментарий ***}
}{
^rem{ *** комментарий ***}
}
}
}{
^rem{ *** комментарий ***}
}Кстати, для пользователей HomeSite (каковым и я тоже являюсь) будет интересны следующие два скрипта (оригинал упоминался в форуме, но в нем были баги и неточности, я его изменил немного «под себя»:var document = Application.ActiveDocument;
function Main () {
var selection_lines = document.SelText.split(String.fromCharCode(13) + String.fromCharCode(10));
var selection_start = document.SelStart;
var selection_stop = document.SelStart + document.SelLength;
var comment_str = get_comment_type(document.Filename);
var line_start = get_line_number(document.Text, selection_start);
var line_stop = get_line_number(document.Text, selection_stop - selection_lines.length + 1);
var empty_string = new RegExp("^\\s*$");
if (line_start != line_stop && empty_string.test(document.Lines(line_stop))) {
line_stop--;
}
for (n = line_start; n <= line_stop; n++) {
document.Lines(n) = comment_str + document.Lines(n);
}
}
function get_offset (sText, iLine) {
var iPos = iOffset = 0;
while (iPos < iLine) {
if (sText.substr(iOffset, 2) == "\r\n") {
iLine++;
iOffset++;
iPos++;
}
iOffset++;
}
return iOffset;
}
function get_line_number (sText, iOffset) {
var iPos = iLine= 0;
while (iPos < iOffset) {
if (sText.substr(iPos, 2) == "\r\n") {
iLine++;
iOffset++;
iPos++;
}
iPos++;
}
return iLine;
}
function get_comment_type (filename) {
var ext = filename.substring(filename.lastIndexOf('.'));
var result = "#";
if (ext == ".pl" || ext == ".pm" || ext == ".cgi" || ext == ".p" || ext == ".cfg" || ext == ".html") {
result = "#";
} else if (document.Lines(0).charAt(0) == "#" || document.Lines(0).charAt(0) == "@") {
result = "#";
} else if (ext == ".js" || ext == ".java" || ext == ".cpp" || ext == ".h" || ext == ".sc") {
result = "//";
} else if (ext == ".asp" || ext == ".vbs") {
result = "\' ";
} else if (ext == ".inf" || ext == ".ini") {
result = ";";
}
return result;
}uncomment.js var document = Application.ActiveDocument;
function Main () {
var cursorY = document.CaretPosY - 1;
var cursorX = document.CaretPosX;
var SelArr = document.SelText.split(String.fromCharCode(13) + String.fromCharCode(10));
var lines = SelArr.length;
var commentStr = get_comment_type(document.Filename);
var regexp = new RegExp("(^\\s*)" + commentStr + "(.*)");
var regexp_match_start = new RegExp("\\$");
var regexp_match_stop = new RegExp("\\[dollar\\]");
if(!document.SelText) {
if (regexp.test(document.Lines(cursorY))) {
var line = document.Lines(cursorY).replace(regexp_match_start, "[dollar]")
if (regexp.test(line)) {
line = line.replace(regexp, RegExp.$1 + RegExp.$2)
}
document.Lines(cursorY) = line.replace(regexp_match_stop, String.fromCharCode(36))
}
} else {
for (n = cursorY; n < (cursorY + lines); n++) {
var line = document.Lines(n).replace(regexp_match_start, "[dollar]")
if (regexp.test(line)) {
line = line.replace(regexp, RegExp.$1 + RegExp.$2)
}
document.Lines(n) = line.replace(regexp_match_stop, String.fromCharCode(36))
}
}
}
function get_comment_type (filename) {
var ext = filename.substring(filename.lastIndexOf('.'));
var result = "#";
if (ext == ".pl" || ext == ".pm" || ext == ".cgi" || ext == ".p" || ext == ".cfg" || ext == ".html") {
result = "#";
} else if (document.Lines(0).charAt(0) == "#" || document.Lines(0).charAt(0) == "@") {
result = "#";
} else if (ext == ".js" || ext == ".java" || ext == ".cpp" || ext == ".h" || ext == ".sc") {
result = "//";
} else if (ext == ".asp" || ext == ".vbs") {
result = "\' ";
} else if (ext == ".inf" || ext == ".ini") {
result = ";";
}
return result;
}Инструкция по установке