Document property currentColumnNum returns different value with UE v16.00+

Help with writing and running scripts

Document property currentColumnNum returns different value with UE v16.00+

Postby Mofi » Tue Mar 16, 2010 8:10 am

Hello script writers!

Prior UltraEdit v16.00 and prior UEStudio v10.00 document property UltraEdit.activeDocument.currentColumnNum contains the current column number in the active line of the active file starting the count with 0.

But most script commands like gotoLine() or sortAsc() require value 1 for start of a line (= first column) because value 0 is interpreted as current column of the cursor in the file.

Therefore with using the tag list view with the standard tag list file taglist.uet, double clicking on list entry Get Column Number on tag group UE/UES Script Commands inserted following into the file (| marks the cursor position):

var | = UltraEdit.activeDocument.currentColumnNum + 1;

Starting with UltraEdit v16.00 and UEStudio v10.00 the counting changed. The first column has now value 1 and not 0 as in previous versions of UltraEdit and UEStudio. As a result of this change all scripts using currentColumnNum written for a previous version of UltraEdit are not working correct after upgrading to UE v16.00 or UES v10.00 or any later version. The scripts must be adapted. Often just + 1 must be removed, but it depends on the script what to do.

When a script writer has already written or wants to write a public released script using document property currentColumnNum, the script should work independent of the version of UltraEdit and therefore needs code which produces always the same result independent of the version of UltraEdit. This is possible for example with using following code:

Code: Select all
var nColNum = UltraEdit.activeDocument.currentColumnNum;
if (typeof(UltraEdit.activeDocumentIdx) == "undefined") nColNum++;

UltraEdit.activeDocumentIdx is not defined in UltraEdit prior v16.00 respectively UEStudio prior v10.00 and then the second code line increases the column number by 1 to get the same value for the column number as UE v16.00 / UES v10.00 contains in the document property and needed in most commands.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: Document property currentColumnNum returns different value with UE v16.00+

Postby jorrasdk » Tue Mar 16, 2010 8:29 am

Hello Mofi.

Thanks for the "heads up" - I wasn't aware of this until now.

Regards Jorrasdk
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Document property currentColumnNum returns different value with UE v16.00+

Postby jorrasdk » Tue Mar 16, 2010 8:50 am

Hello again

The explanation of currentColumnNum in the Help file of UE 16.00 (UE 16.00.0.1032) is still Returns value of current column number. The first column is numbered as "0".. This could sure lead to some confusion.

Mofi, I guess you are in the process of changing all your community released scripts (like FindSelectInnerOuter.js) and will send them to IDM to update the ones in the Extras page ? - and could you then be bothered to report the confusing help text, please ? Thanks.
User avatar
jorrasdk
Master
Master
 
Posts: 275
Joined: Mon Mar 19, 2007 11:00 pm
Location: Denmark

Re: Document property currentColumnNum returns different value with UE v16.00+

Postby Mofi » Wed Mar 17, 2010 1:40 pm

jorrasdk wrote:I guess you are in the process of changing all your community released scripts (like FindSelectInnerOuter.js) and will send them to IDM to update the ones in the Extras page ? - and could you then be bothered to report the confusing help text, please ?

My community released scripts are updated now on IDM's server. I reported also the wrong statement in help (corrected in help of UE v16.00.0.1036) and sent IDM an updated standard taglist.uet (installed into UltraEdit program directory with v16.00.0.1036).

Additionally I searched the forum for all topics containing script code with currentColumnNum and updated the code. I hope, I have not overseen an occurrence of currentColumnNum and have not made a mistake during editing the codes of those scripts. Furthermore I hope no author of the posted scripts which I modified to fix the compatibility problem feel that my modification of their scripts violates their copyright.
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 4058
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna


Return to Scripts