Skip to main content
K.Daube
Community Expert
Community Expert
December 29, 2020
Answered

ScriptUI oList.removeAll() tilts FM

  • December 29, 2020
  • 1 reply
  • 285 views

Dear friends,

Back on stage I encounter a very strange problem. In the following short function I set up a DropDown list:

 

KLD_F.FillDlgList = function(oList, asListItems) { // ============
/*            Fill dialogue list from global array
Arguments     oList           dialogue list to be filled from the array
              asListItems     array with the list items
Returns       -
Called by     various call-back functions
History       2020-11-10 tested with FMfindRepl
*/
var j, nItems;
  nItems = asListItems.length;
  oList.removeAll ();                       // clear the list
  for (j = 0; j < nItems; j++) {
    oList.add ("item", asListItems[j]);
  }
} //--- end FillDlgList

 

It is encountered very often during executing the script FMfindRepl. Now I found that after certain sequences of operations, namely:

Find Cross-Reference (any) (2x)

Find Cross-Reference of Format ... (2x)

Find Cross-Reference (any) (2x)

Find Cross-Reference of Format ... → Zoingg

The script halts for a while in the line

 

  oList.removeAll ();                             // clear the list

 

and then FM disappears silently (no dump, no trumpets...)

When stepping through the script (having set a counter of its calls to set the breakpoint) I see that, when entering this statement,

  1. First the display of data disappears in the debugger (same behaviour in ESTK CC)
  2. Then after about 5 seconds FM disappears.

In the past two months I had used this function during the tests close to 100 times and it behaved. It was quite tricky to find the reason for the instant disappearance of FM in recent tests.

 

Edit

After introducing a statement

Console ("oList length = " + oList.items.length);

just before the removeAll line, I see this:

oList length = 0
oList length = 0
oList length = 0
oList length = 14

 Hence the removeAll fails if it should do what it is intended for...

I also need to check why in the other cases the list already emtpy.

This topic has been closed for replies.
Correct answer K.Daube

Well, again I shot into my leg.

There was this statement

 

wPalF.g01.lstCatalgF.items.length = 0;          // clear the list

 

Which I must have introduced in a phase of mental derangement ...

Removing this cured the problem!

 

Why the heck do I find solutions only after posting them to the forum????

1 reply

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthorCorrect answer
Community Expert
December 29, 2020

Well, again I shot into my leg.

There was this statement

 

wPalF.g01.lstCatalgF.items.length = 0;          // clear the list

 

Which I must have introduced in a phase of mental derangement ...

Removing this cured the problem!

 

Why the heck do I find solutions only after posting them to the forum????

Klaus Göbel
Legend
December 29, 2020

Hi Klaus,

last year I've posted how to delete a long list:

https://community.adobe.com/t5/framemaker/estk-very-fast-way-to-delete-a-huge-list-with-extendscript-howto/m-p/10774202?page=1

 

That would have helped you. This method deletes the container of the list. But there's missing something in this post: you have to add this group again. The next few days I'll post the complete solution.