Scripts discussion (1)

Discuss and announce AkelPad plugins
Locked
  • Author
  • Message
Offline
Posts: 3234
Joined: Wed Nov 29, 2006 1:19 pm
Location: Киев, Русь
Contact:

Post by VladSh »

Изменил названия объектов на oCh и oStr, в следствие чего изменились все скрипты этого списка.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

cnnnc wrote:When InsertText.js do with column selection In each of Selected, the result same as normal selection.
When InsertText.js do with column selection In Selection, the result is diffterent to normal selection.
My NumberCount.js can insert text and/or number to every selected line even column selection. but there are some bugs I unable to fix. :(
Thank you for your attention, I'll try to fix it.
I agree, your script NumberCount.js is much better than mine.
Good idea with the numbers of lines. Congratulations. :)

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

I fixed InsertText.js script and I added support for the columnar selection.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Hi, I have a question.
I have done the columnar selection outside the text (after end of line)
How to read the begin and the end of selection and the caret offset?.
Methods AkelPad.GetSelStart and AkelPad.GetSelEnd fail in this case.

Offline
Site Admin
Posts: 6403
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

VladSh wrote:Instructor
Только заметил, что скрипт GetFirstVisibleChar.js исчез. Задача всё та же (что по ссылке).

Code: Select all

var hWndEdit=AkelPad.GetEditWnd();

WScript.Echo("" + GetOffset(hWndEdit, 10 /*AEGI_FIRSTVISIBLELINE*/));

function GetOffset(hWndEdit, nType /*AEGI_*/)
{
  var lpIndex;
  var nOffset=-1;

  if (lpIndex=AkelPad.MemAlloc(12 /*sizeof(AECHARINDEX)*/))
  {
    AkelPad.SendMessage(hWndEdit, 3130 /*AEM_GETINDEX*/, nType, lpIndex);
    nOffset=AkelPad.SendMessage(hWndEdit, 3136 /*AEM_INDEXTORICHOFFSET*/, 0, lpIndex);
    AkelPad.MemFree(lpIndex);
  }
  return nOffset;
}

Offline
Site Admin
Posts: 6403
Joined: Thu Jul 06, 2006 7:20 am

Post by Instructor »

KDJ wrote:How to read the begin and the end of selection and the caret offset?.

Code: Select all

var hWndEdit=AkelPad.GetEditWnd();

WScript.Echo("" + GetCharInLine(hWndEdit, 5 /*AEGI_CARETCHAR*/));

function GetCharInLine(hWndEdit, nType /*AEGI_*/)
{
  var lpIndex;
  var nCharInLine=-1;

  if (lpIndex=AkelPad.MemAlloc(12 /*sizeof(AECHARINDEX)*/))
  {
    AkelPad.SendMessage(hWndEdit, 3130 /*AEM_GETINDEX*/, nType, lpIndex);
    nCharInLine=AkelPad.MemRead(lpIndex + 8, 3 /*DT_DWORD*/);
    AkelPad.MemFree(lpIndex);
  }
  return nCharInLine;
}
But working with AECHARINDEX it is not easy like text offsets.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Thanks Instructor. You helped me very much. This function gives the column number of the caret.
My guess, to read the line number, I should use:
AkelPad.MemRead(lpIndex, 3 /*DT_DWORD*/).
And to know the coordinates of selection, I must use AEGI_FIRSTSELCHAR and AEGI_LASTSELCHAR.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

CalculatorJS.js now has a variable size window.

Offline
Posts: 2248
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ, I think script should validate such cases:
Image

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FeyFre wrote:KDJ, I think script should validate such cases:
Of course you're right, already corrected.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

KDJ wrote:CalculatorJS.js
Amazing!
Just one little correction: under Windows 7, the width of lpOutXYWH causes the Output Edit to intersect the Output type Combo. So I've changed this width from 471 to 469.
... and the function average seems to not working... It says 'Average' is undefined.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

DV thanks, I fixed it.

DV
Offline
Posts: 1292
Joined: Thu Nov 16, 2006 11:53 am
Location: Kyiv, Ukraine

Post by DV »

KDJ wrote:DV thanks, I fixed it.
Great!
Just for information: a remarkable ability of the calculator engine powered by JScript is to use local or global variables anywhere in your calculations.
E.g.

Code: Select all

var a = 10, b = 5, x = a + b; sin(x)/x
for local variables a, b and x.
Or just

Code: Select all

c = 100
to define a global variable c (within current instance of the calculator).

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

In CalculatorJS, variables x, X, y, Y, z, Z are defined as global.
They are used to store cache memory of the calculator.
You can use them in calculations such as: 15*x+y-Z/12.
But you can not use to manual assignment eg.: x=50.
To change the contents of memory x, you must type as the expression 50 and use the button "Result to X". Then the value of 50 will be assignment to the variables x and X, and will be displayed in the window memory.

Offline
Posts: 27
Joined: Sun Mar 16, 2008 10:26 pm

Post by kadvlad »

Приветствую.

Пробую запустить InsertTextLN.js от KDJ -- получаю ошибку 800A1391 ("AkelPad" - определение отсутствует) в строке

Code: Select all

var hMainWnd     = AkelPad.GetMainWnd(); 
Версия программы 4.1.10
В чём моя ошибка, подскажите, пожалуйста.
Locked