The script FileInfo.js now also shows detailed statistics of the text.
Posted: Sat Nov 13, 2010 10:53 am
by se7h
Infocatcher
разместите пожалуйста все свои скрипты в Script Collection, запарился их искать
Posted: Sat Nov 13, 2010 6:36 pm
by Infocatcher
se7h
Уфф, вроде, всё: viewtopic.php?p=9924#p9924.
Но кое-что и правда не совсем дописано, кое-что можно улучшить, а что-то – и вовсе переписать, но пока нет особой необходимости.
Ну вот, ограничение на длину. Придется делить на части.
Posted: Sat Nov 13, 2010 6:58 pm
by se7h
Infocatcher
респект!
Posted: Sat Nov 13, 2010 9:00 pm
by KDJ
I changed the name of the script from SelectRange.js to SelectRangeText.js.
I had not noticed before, the script SelectRange.js was placed by Instructor.
Both scripts have different functionality.
I'm sorry everyone for the confusion.
Posted: Mon Nov 15, 2010 6:48 pm
by KDJ
I have a question.
Date.toLocaleString() method returns the date as long.
How to convert long date to short date, according to the locale settings of the operating system?
Posted: Mon Nov 15, 2010 8:16 pm
by FeyFre
KDJ
All information about built-in JScript's, JavaScript's, ActionScript's and other ECMA262 standard implementations objects you can find on pages of standard. For instance here(2.35MB).(Сhapter 15.9 for your case. Or here you can find more friendly description.)
Posted: Mon Nov 15, 2010 9:24 pm
by KDJ
FeyFre, thank you for the book ECMA (readings for several months ).
But I do not see the JS function, that returns a short date.
I have such settings in the system:
short date format: "dd-MM-yyyy",
long date format: "dd MMMM yyyy".
Date.toLocaleDateString() method returns a long date. You can convert to using the functions getDate(), getMonth(), getFullYear(). But I do not know, how to read from the system short date format.
Posted: Mon Nov 15, 2010 11:28 pm
by FeyFre
KDJ, if something missing in JS, you always can get it from system using AkelPad.SystemFunction().Call("syslibrary::syscall",params).
I have already showed you how to get system time using system calls.
//! FROM WinNT.h
//! Typical values for first param of GetDateFormat and GetDateFormat syscalls
//! (or specified locale value. see MAKELCID define)
var LOCALE_USER_DEFAULT = 1024;
var LOCALE_SYSTEM_DEFAULT = 2048;
var LOCALE_INVARIANT = 127;
//! FROM WinNLS.h
// Date Flags for GetDateFormat(SECOND PARAM)
var DATE_SHORTDATE = 0x00000001 // use short date picture
var DATE_LONGDATE = 0x00000002 // use long date picture
var DATE_USE_ALT_CALENDAR = 0x00000004 // use alternate calendar (if any)
//! Only for >=Windows 2000
var DATE_YEARMONTH = 0x00000008 // use year month picture
var DATE_LTRREADING = 0x00000010 // add marks for left to right reading order layout
var DATE_RTLREADING = 0x00000020 // add marks for right to left reading order layout
//!
// Time Flags for GetTimeFormat(SECOND PARAM)
var TIME_NOMINUTESORSECONDS = 0x00000001 // do not use minutes or seconds
var TIME_NOSECONDS = 0x00000002 // do not use seconds
var TIME_NOTIMEMARKER = 0x00000004 // do not use time marker
var TIME_FORCE24HOURFORMAT = 0x00000008 // always use 24 hour format
// Date/Time Flags for both GetTimeFormat and GetDateFormat(SECOND PARAM) (OR-ed)
var LOCALE_NOUSEROVERRIDE = 0x80000000;
var LOCALE_USE_CP_ACP = 0x40000000;
var oSys = AkelPad.SystemFunction();
var lpstr = AkelPad.MemAlloc(256*_TSIZE);
AkelPad.MemCopy(lpstr, "", _TSTR);
var systime = AkelPad.MemAlloc(16 /*sizeof_SYSTEMTIME*/);
oSys.Call("kernel32::GetSystemTime", systime);
oSys.Call("kernel32::GetDateFormat"+_TCHAR,
LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
systime,
0,
lpstr,255);
var str = AkelPad.MemRead(lpstr, _TSTR);
AkelPad.MessageBox(0, str, "GetDateFormat"+_TCHAR, 0 /*MB_OK*/);
oSys.Call("kernel32::GetTimeFormat"+_TCHAR,
LOCALE_USER_DEFAULT,
TIME_FORCE24HOURFORMAT,
systime,
0,
lpstr,255);
str = AkelPad.MemRead(lpstr, _TSTR);
AkelPad.MessageBox(0, str, "GetTimeFormat"+_TCHAR, 0 /*MB_OK*/);
AkelPad.MemFree(systime);
AkelPad.MemFree(lpstr);
You should read MSDN carefully.
Posted: Tue Nov 16, 2010 5:15 pm
by Infocatcher
convertEscapes.js 0.1.1 - 2010-11-16
Добавил восстановление обратных слешей внутри строковых литералов.
Posted: Tue Nov 16, 2010 10:02 pm
by KDJ
Thanks FeyFre.
It seems to me, that I understand how it works.
var nBufferSize = 8;
var lpBuffer;
var i;
for (i = 0; i < 1000; ++i)
{
lpBuffer = AkelPad.MemAlloc(nBufferSize);
AkelPad.MemCopy(lpBuffer, 0, 4); //DT_WORD
AkelPad.MemCopy(lpBuffer + 2, 0, 4);
AkelPad.MemCopy(lpBuffer + 4, 0, 4);
AkelPad.MemCopy(lpBuffer + 6, 0, 4);
AkelPad.MemFree(lpBuffer);
}
This happens when executing the function:
AkelPad.MemCopy(lpBuffer + 6, 0, 4);
But not always. That is why I gave the count to 1000. This gives confidence that the error occurs.
I checked on two computers with Windows XP.
And where is the bug?
Posted: Thu Nov 18, 2010 7:30 pm
by FeyFre
KDJ, you are right, there is a bug in method.
4 Instructor:
IDocument.c
#line 950 #line 959 должно быть sizeof(WORD) и sizeof(BYTE)
иначе запись портит служебные данные кучи(я как раз недавно в одном плагине тоже такой недосмотр нашел).
Posted: Thu Nov 18, 2010 7:56 pm
by KDJ
But you can skip this error. It should enlarge the buffer size of 1 byte:
lpBuffer = AkelPad.MemAlloc(nBufferSize + 1);
Posted: Thu Nov 18, 2010 8:19 pm
by se7h
Instructor
реально доработать ChmKeyword.js так, чтобы можно было одновременно открывать несколько окон справки, то есть, фактически, была возможность выполнения других скриптов при открытом CHM-файле?