Stagger Script Edit Windows

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
pderks
Posts: 45
Joined: Sat May 14, 2011 4:25 pm
Location: Krefeld • Deutschland

Stagger Script Edit Windows

Post by pderks » Tue Apr 03, 2018 11:00 am

Hi,

I came up with a non-paschal mystery.
Her is a script, that staggers the open Script Editor Windows:

Code: Select all

 put the windows into WindowList
  filter WindowList with "revNewScriptEditor*"
  repeat with ii = 1 to the Number of lines in WindowList
    get line ii of WindowList
    set the Rect of window it to "100,100,1000,600"
    put Patt into fld "Find" of window it
    set the TopLeft of window it to 50 + (ii - 1) * 10,50 + (ii -1) * 10
  end repeat
This script works, If I put it with MouseUp into a button.
This script works, If I put it without MouseUp into the message box..
This script does not work, if I put it at the end of a handler A in the stacks's script, or if I put it into an own handler B in the stack's script, that is called by handler A: all script editor windows lie congruently on top of each other.

Thanks in advance

Peter

pderks
Posts: 45
Joined: Sat May 14, 2011 4:25 pm
Location: Krefeld • Deutschland

Re: Stagger Script Edit Windows - Solved

Post by pderks » Mon Apr 09, 2018 7:26 am

Hi,

I inserted the line

Code: Select all

go window WindowLine
so that my code now looks like

Code: Select all

on pda_WindowStagger_ScriptEditor Patt
  put the Windows into WindowList
  filter WindowList with "revNewScriptEditor*"
  repeat with ii = 1 to the Number of lines in WindowList
    put line ii of WindowList into WindowLine
    go window WindowLine
    set the Rect of window WindowLine to "100,100,1000,600"
    put Patt into fld "Find" of window WindowLine
    set the TopLeft of window WindowLine to 50 + (ii - 1) * 10,50 + (ii -1) * 10
  end repeat
end pda_WindowStagger_ScriptEditor
Regards

Peter

pderks
Posts: 45
Joined: Sat May 14, 2011 4:25 pm
Location: Krefeld • Deutschland

Re: Stagger Script Edit Windows - corrected Solution

Post by pderks » Mon Apr 09, 2018 10:04 am

Hi,

I correct my latest post giving an example button script:

Code: Select all

on MouseUp
  repeat with ii = 1 to 25
    edit the Script of btn ii
  end repeat
  send "pda_WindowStagger_ScriptEditor" && "on" to me in 10 ticks
end MouseUp
---
on pda_WindowStagger_ScriptEditor Patt
  put the Windows into WindowList
  filter WindowList with "revNewScriptEditor*"
  repeat with ii = 1 to the Number of lines in WindowList
    put line ii of WindowList into WindowLine
    set the Rect of window WindowLine to "100,100,1000,600"
    put Patt into fld "Find" of window WindowLine
    -- next line is optional: reverts the order of the windows
    go window WindowLine
    set the TopLeft of window WindowLine to 50 + (ii - 1) * 25,50 + (ii -1) * 25
  end repeat
end pda_WindowStagger_ScriptEditor
The critical code line is:

Code: Select all

  send "pda_WindowStagger_ScriptEditor" && "on" to me in 10 ticks
Regards

Peter

Klaus
Posts: 10327
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Stagger Script Edit Windows

Post by Klaus » Mon Apr 09, 2018 10:12 am

Hi Peter,

better always use PARENS when concatenating strings:

Code: Select all

...
send ("pda_WindowStagger_ScriptEditor" && "on") to me in 10 ticks
...
However they are not even neccessary here at all:

Code: Select all

...
send "pda_WindowStagger_ScriptEditor on" to me in 10 ticks
...
Should do :-)


Best

Klaus

Post Reply

Return to “Talking LiveCode”