What is the mode of the "Code Editor" stack?

LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.

Moderators: LCMark, LCfraser

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

Re: What is the mode of the "Code Editor" stack?

Post by richmond62 » Fri Jul 29, 2022 4:25 pm

it is under the control of the scripter though the style property, and various commands that determine mode including ask, answer, sheet, palette, modeless, and others.
Thank you, that is worth knowing.

Is there any documentation where there is some sort of equivalence table where each style is matched against a specific mode?

The Dictionary offers information anent 4 styles:
-
SShot 2022-07-29 at 18.33.13.png
-
and there are 14 modes (0 - 13).

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: What is the mode of the "Code Editor" stack?

Post by stam » Fri Jul 29, 2022 5:06 pm

Mode 0 was the one of interest to me. The alternative was a roundabout way of checking if stack is open and if it's visible - and this doesn't correspond to styles. Another great convenience!

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by FourthWorld » Fri Jul 29, 2022 5:13 pm

richmond62 wrote:
Fri Jul 29, 2022 4:25 pm
Is there any documentation where there is some sort of equivalence table where each style is matched against a specific mode?
Possibly.

The mode property is rarely needed unless one is making window management tools for an IDE.

More common in practice is to control window layering and other behavior with the style property and the various commands for window behavior.

The descriptions of the modes in the Dictionary appear, IIRC, to make it reasonably clear what actions a scripter would take to see each mode.

For example, whatever numeric constant is used for the modeless behavior is achieved by either setting the style of a stack to modeless, or temporarily setting it by using the modeless command.

I don't know for certain whether such a complete listing mapping actions to mode constants exists, because even though I make IDE tools and used to maintain a complete IDE for this engine I've very rarely needed to think about the mode property.

If you'd like to have one it shouldn't take but a few minutes for you to assemble it. Feel free to post what you can easily derive and note any that aren't clear and I'd be happy to fill in the blanks.

And I'm curious, to help me understand user workflows: what are you working on that requires using the mode property?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by FourthWorld » Fri Jul 29, 2022 5:16 pm

stam wrote:
Fri Jul 29, 2022 5:06 pm
Mode 0 was the one of interest to me. The alternative was a roundabout way of checking if stack is open and if it's visible - and this doesn't correspond to styles. Another great convenience!
That's exactly the sort of edge case where the mode property can be useful.

To help me understand how these language elements are used in practice, can you describe the circumstance where awareness of mode 0 was useful in your work?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: What is the mode of the "Code Editor" stack?

Post by richmond62 » Fri Jul 29, 2022 5:17 pm

what are you working on that requires using the mode property?
I am not, but the OP is.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by FourthWorld » Fri Jul 29, 2022 6:29 pm

richmond62 wrote:
Fri Jul 29, 2022 5:17 pm
what are you working on that requires using the mode property?
I am not, but the OP is.
He was looking for the mode of the Script Editor. IDE stuff, and solved.

Mode is occasionally useful in consumer-facing apps, but not often.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: What is the mode of the "Code Editor" stack?

Post by stam » Fri Jul 29, 2022 9:09 pm

FourthWorld wrote:
Fri Jul 29, 2022 5:16 pm
That's exactly the sort of edge case where the mode property can be useful.

To help me understand how these language elements are used in practice, can you describe the circumstance where awareness of mode 0 was useful in your work?
I require unloading of several library (script only) stacks in the IDE for reloading after editing in an external editor. Mode 0 simplifies that, and although i delve into the dictionary and of course pay attention to the forums i had missed his. But this is mainly for an IDE utility as far as my needs go.

Although i don't have a specific need for this in standalone perhaps it might be useful if for example upgrading components that need to be unloaded from memory if running.

Stam

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by PaulDaMacMan » Sun Aug 14, 2022 4:45 pm

x they refer to was called revNewScriptEditor
May be obvious but...
That 'revNewScriptEditor' not going to have a mode because it's a script-only stack that's used as a template to generate script editor window UIs, so you may have stacks "revNewScriptEditor 1", "revNewScriptEditor 2", "revNewScriptEditor 3", etc. open if you're doing a lot of script editing, which are transient stacks, they go away after a control/part script is compiled.
Last edited by PaulDaMacMan on Thu Aug 18, 2022 12:19 am, edited 1 time in total.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by FourthWorld » Sun Aug 14, 2022 5:35 pm

Script-only stacks won't have a style property, because of course that format only supports the behavior property but no others.

But the mode of a stack reflects its state once loaded, independent of its storage format.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by PaulDaMacMan » Thu Aug 18, 2022 12:32 am

FourthWorld wrote:
Sun Aug 14, 2022 5:35 pm
Script-only stacks won't have a style property, because of course that format only supports the behavior property but no others.

But the mode of a stack reflects its state once loaded, independent of its storage format.
The point was, in Richmonds test that stack has a Mode. of 0, which means "closed but loaded" but the transient editor window stacks would have a non-zero mode...

but I stand corrected... so a non-loaded stack has a mode of 'empty'?
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9802
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by FourthWorld » Thu Aug 18, 2022 12:45 am

PaulDaMacMan wrote:
Thu Aug 18, 2022 12:32 am
so a non-loaded stack has a mode of 'empty'?
Hmmm... Curious question. How could one test it? Under what circumstances would it matter?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by PaulDaMacMan » Thu Aug 18, 2022 1:42 am

FourthWorld wrote:
Thu Aug 18, 2022 12:45 am
PaulDaMacMan wrote:
Thu Aug 18, 2022 12:32 am
so a non-loaded stack has a mode of 'empty'?
Hmmm... Curious question. How could one test it? Under what circumstances would it matter?

Code: Select all

 -- How could one test it:
if the mode of stack "path/to/stackfile" is empty then -- do stuff to closed file such as...
-- Under what circumstances would it matter?
   doStuffThatInvolvesEnsuringStackFileIsNotOpenInIDESuchAsExternalEditingThenReload
end if
Granted that's a very niché use, and I'm sure there's bunches of other ways to check if a file is open, but if you also have to check for 'palette','modal, etc. modes and can kill two birds then why not?
Anyway I got no time to test these thought right now.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

stam
Posts: 2634
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: What is the mode of the "Code Editor" stack?

Post by stam » Thu Aug 18, 2022 10:49 am

PaulDaMacMan wrote:
Thu Aug 18, 2022 1:42 am

Code: Select all

 -- How could one test it:
if the mode of stack "path/to/stackfile" is empty then -- do stuff to closed file such as...
-- Under what circumstances would it matter?
   doStuffThatInvolvesEnsuringStackFileIsNotOpenInIDESuchAsExternalEditingThenReload
end if
I don't think there's any restriction in editing or manipulating 'physical' files loaded into memory hence i don't think checking for empty is helpful. You can open/edit/save/delete these with no immediate impact on the IDE if these are in memory.

However, if a file is loaded into memory it won't automatically 'reload' when edited/saved externally - it needs to be removed from memory first and then reloaded, which is the use case i described above - i have an alternate solution in place to unload libraries etc, to reload them when edited in an external editor (in my case, VSCode), but checking mode 0 would be much more straightforward and reliable.

But as it stands i edit all files (loaded or not) in VSCode with no issues - it's just the reloading in the IDE that is the issue.
So I'm with Richard on this one - I can't really see a point in checking for empty...

S.

PaulDaMacMan
Posts: 616
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: What is the mode of the "Code Editor" stack?

Post by PaulDaMacMan » Mon Aug 22, 2022 2:38 am

stam wrote:
Thu Aug 18, 2022 10:49 am
PaulDaMacMan wrote:
Thu Aug 18, 2022 1:42 am

Code: Select all

 -- How could one test it:
if the mode of stack "path/to/stackfile" is empty then -- do stuff to closed file such as...
-- Under what circumstances would it matter?
   doStuffThatInvolvesEnsuringStackFileIsNotOpenInIDESuchAsExternalEditingThenReload
end if
I don't think there's any restriction in editing or manipulating 'physical' files loaded into memory hence i don't think checking for empty is helpful. You can open/edit/save/delete these with no immediate impact on the IDE if these are in memory.

However, if a file is loaded into memory it won't automatically 'reload' when edited/saved externally - it needs to be removed from memory first and then reloaded, which is the use case i described above - i have an alternate solution in place to unload libraries etc, to reload them when edited in an external editor (in my case, VSCode), but checking mode 0 would be much more straightforward and reliable.

But as it stands i edit all files (loaded or not) in VSCode with no issues - it's just the reloading in the IDE that is the issue.
So I'm with Richard on this one - I can't really see a point in checking for empty...

S.
right, so I posted example pseudo code, but I guess mode 0 is good enough, or any other way of checking for open files really.

-- How could one test it:
if the mode of stack "path/to/stackfile" is empty then -- do stuff to closed file such as...
-- Under what circumstances would it matter?
doStuffThatInvolvesEnsuringStackFileIsNotOpenInIDESuchAsExternalEditingThenReload
end if

At any rate, this thread probably doesn't belong in LiveCode Builder, as it's not really related in any way that I can think of.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “LiveCode Builder”