Force the script editor to update?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Force the script editor to update?

Post by Zax » Mon Apr 22, 2024 12:45 pm

Hello,

Is there a way to force the script editor to update its tabs when closing a stack?

If I close a stack with locked messages and have some of its scripts opened in the script editor, the editor doesn't update and its tabs become nonsense.
On the other hand, if I close a stack with unlocked messages, the script editor updates correctly.
Of course, I could also close the script editor completely but that would also close the scripts of the other opened stacks, and that's not what I want.

The following tests are very simple to perform:

Code: Select all

on mouseUp
   lock messages
   close this stack
   -- look at the script editor and cry
end mouseUp

Code: Select all

on mouseUp
   close this stack -- OK
end mouseUp

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Mon Apr 22, 2024 1:25 pm

You can make the script editor 'split' into separate windows for each script, then you can close the script windows for the stack you are closing and leave ones for other stacks open.
-
SShot 2024-04-22 at 15.28.12.png

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9678
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Force the script editor to update?

Post by dunbarx » Mon Apr 22, 2024 2:45 pm

Hi.

So I understand, is it that the tabs stay alive when messages are locked? And you believe these tabs are now valueless?

If so, I get what you are saying, but also say that everything is working as advertised. After, all, even with the stack closed, you can still edit the scripts, and even save them, assuming the stack itself has only been closed and not removed from memory.

So what is the downside, apart from having those tabs cluttering up the place?

Craig

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Mon Apr 22, 2024 6:11 pm

Nice trick Richmond62 :)
Though, I would prefer a "full script" way, if possible.
dunbarx wrote:
Mon Apr 22, 2024 2:45 pm
If so, I get what you are saying, but also say that everything is working as advertised. After, all, even with the stack closed, you can still edit the scripts, and even save them, assuming the stack itself has only been closed and not removed from memory.
Sorry, I forgot to mention the closed stack was removed from memory. In this case, if you have several script editor tabs, with ones concerning the closed stack, and others concerning other opened stacks, tabs seem to no longer correspond to the right edited scripts. I'll make other tests in order to be more accurate.

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Tue Apr 23, 2024 8:03 am

Here is my testing procedure:
1 - opening a test stack, let's call it "TestStack"
2 - opening another stack, let's call it "AnyStack"
3 - editing the script of some controls of the "AnyStack" stack
4 - editing the script of some controls of the "TestStack" stack
5 - the "TestStack" stack has its destroyWindow and destroyStack enabled
6 - at this point, the script editor has several tabs, referring to our 2 stacks
7 - execution of the script:

Code: Select all

on mouseUp
   lock messages
   close stack "TestStack"
end mouseUp
8 - "TestStack" is now closed and removed from memory, but the tabs of the script editor referring to the closed stack are still open and no longer clickable. You can only close them manually.

So I'm looking for a way to automatically close these inactive tabs by script when closing the "TestStack" stack with the locked messages.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 8:29 am

I just opened 2 stacks, and 2 script editor windows: 1 for an object in the first stack, and 1 for a script in the second stack.

When I closed the first stack, the script editor for the object in that stack closed too.

What am I missing?

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Tue Apr 23, 2024 9:09 am

richmond62 wrote:
Tue Apr 23, 2024 8:29 am
What am I missing?
Maybe "lock messages" before closing?

Test.livecode.zip
(1 KiB) Downloaded 9 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 9:20 am

First of all, I opened my 2 stacks and their scripts, then typed lock messages into the messageBOx: no difference.

Secondly . . .

Opened your stack:
-
SShot 2024-04-23 at 11.22.11.png
-
And, as you explained, the script editors remain open when the stack is closed.

However, I have to ask: Why are you locking the messages in the first place?

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Tue Apr 23, 2024 9:37 am

richmond62 wrote:
Tue Apr 23, 2024 9:20 am
However, I have to ask: Why are you locking the messages in the first place?
For information, it is for the script of a button of a personal development tools palette which must close in a somewhat brutal way the stacks which I no longer use.
When developing, I often open several stacks to copy elements or pieces of scripts, and my screens and the Project Browser quickly become cluttered, so I would like to quickly close a few stacks that I no longer need.

Test2.livecode.zip
(1.3 KiB) Downloaded 12 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 9:39 am

my screens and the Project Browser quickly become cluttered
Erm: how many screens do you have?

I still do not understand why it is necessary for you to lock messages.

Aha:
Use the lock messages command when a handler performs an action (such as opening a stack) and you want to speed up access by preventing unnecessary navigation messages (such as openStack) from being sent.
Well, obviously one of the "unnecessary navigation messages" concerns closing script editor windows. :?

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Tue Apr 23, 2024 9:52 am

richmond62 wrote:
Tue Apr 23, 2024 9:39 am
Use the lock messages command when a handler performs an action (such as opening a stack) and you want to speed up access by preventing unnecessary navigation messages (such as openStack) from being sent.
Well, obviously one of the "unnecessary navigation messages" concerns closing script editor windows. :?
And also the famous "Would you like to save stack..." dialog when closing a stack you have not really modified ;)

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 10:05 am

Well, it is unfortunate that lockMessages does not have parameters so you can choose which of the "unnecessary navigation messages" you want to prevent working and which ones you do not want to prevent.

It would be wonderful if one could do this sort of thing (pseudo-code):

Code: Select all

set the lockMessages to true without scriptEditor

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 10:19 am

SShot 2024-04-23 at 12.18.34.png
-
I know this is extremely tedious, but one way to cope with this situation is to choose which messages to suppress.

Zax
Posts: 476
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: Force the script editor to update?

Post by Zax » Tue Apr 23, 2024 11:19 am

At least it would be useful if I could retrieve the list of open scripts in the editor. I could thus check if the stack that I want to close has some of its scripts edited, and warn.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9400
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Force the script editor to update?

Post by richmond62 » Tue Apr 23, 2024 12:31 pm

What is not clear to me (yet) is whether 'suppress messages' means:

1. Stop those messages from running.

or only

2. Stop those messages from showing up in the Message Watcher.
Last edited by richmond62 on Tue Apr 23, 2024 1:07 pm, edited 1 time in total.

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”