Subscribe Bookmark RSS Feed

Auto-Run - weird behavior noted

djhanson

Community Trekker

Joined:

Jun 23, 2011

Hi All, does anyone know why auto-running a JSL script cannot detect an already open JMP window?  This is bizarre to me as I'd expect the behavior of auto-running or manually running a JSL script to be the same (but it does not appear to be so).  Any thoughts or tricks to get around this?  thanks, DJ

Weirdness noted - prior to running the JSL below a JMP window with title "My Open Window" is already open.

Case 1. Auto-Run (//!): it DOES NOT detect the JSL window already open (incorrect).  In this case the Log shows an empty list for the window title.

//!

for(i=1,i<=nitems(window()),i++,

  if(contains(window(i)<<get window title,"My Open Window")!=0,

    write("Open Window Detected: " || char(window(i)<<get window title))

  )

);

Case 2. No Auto-Run (i.e. manually running the JSL script in the JMP script window): it DOES detect the specific JSL window already open (correct).  In this case the Log does show the "My Open Window" for the window title.

////!

for(i=1,i<=nitems(window()),i++,

  if(contains(window(i)<<get window title,"My Open Window")!=0,

    write("Open Window Detected: " || char(window(i)<<get window title))

  )

);

1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Change your i=1 in the for loop to i=0 and see if that works. If it does, then the Window() list appears to be 0-based, which for JSL is odd and probably a bug.

3 REPLIES
Solution

Change your i=1 in the for loop to i=0 and see if that works. If it does, then the Window() list appears to be 0-based, which for JSL is odd and probably a bug.

ms

Super User

Joined:

Jun 23, 2011

Yes, Melanie's right about there being a Window(0). But it's probably not a bug.

Window(0) is always the front window. If running the script manually the script editor would be Window(0).

If I run the below manually, Window(0) refers to the script window but after activating another window by JSL the reference changes. Thus, care must be taken when addressing windows by number, especially if the script is generating windows (of any kind) or shifting their focus.

Print(Window(0) << get window title);

Window(1) << Bring Window To Front;

Print(Window(0) << get window title);

/*

"untitled script"

"Scripting Index"

*/

djhanson

Community Trekker

Joined:

Jun 23, 2011

Excellent!!!!  Thanks very much - that worked.  Makes sense now