Scripting IDE

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

nobaday
Posts: 36
Joined: Mon May 09, 2011 3:23 pm

Scripting IDE

Post by nobaday » Fri Jul 15, 2016 11:19 pm

HI,
Whenever I open Livecode I'm always spending a minute or two placing my windows.

If I understand correctly I could probably deal with this by creating a simple plugin.

So my questions are:

1. In a script can I get a list of all open stacks?

2. How would I open the Script Editor, Property Inspector, Projector Browser and Message Box via Script

3. Can I move them via script? Also, could I make them 'sticky' (i.e. if I had the message box below the script window, could the message box move automatically if I resize the script window, or is it better to just create a menu called 'Clean Up' and run that when I want my windows organized)

4. Can I script bringing a window to the front.

much appreciated!

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm
Location: Göttingen, DE

Re: Scripting IDE

Post by [-hh] » Sat Jul 16, 2016 12:26 am

[1] get the openstacks (read dictionary for variants and details ...)
[2], [3] the scheme is

Code: Select all

on mouseUp
  put "message box" into s
  open stack s
  -- mostly its better to set loc or topleft
  -- (NOT CHANGING width and height) <----------------
  set rect of stack s to 100,100,500,500 -- or whatever
end mouseUp
Other stack names:
  • put "revProjectBrowser" into s
  • put "revNewScriptEditor 1" into s --> better: "edit script of me"
  • put "revPropertyPalette 1" into s
  • put "revApplicationOverview" into s
(The "1" is for the button you use with the above script, this num may change).
You have to script the geometry connection of the rects of these stacks by yourself.

This is a good occasion to read the dictionary. Start with openstacks.
Also look into LC's preferences where you can set the visibility of "LC UI elements" in lists.
Then open the "Application Browser" and you see all the names.

[4] go stack "name"
This brings the window to front within its "layer category". Palettes ('system windows') are still over windows in the 'normal layer'. You have to hide or move the palettes in order to bring an ordinary stack window to front.
shiftLock happens

nobaday
Posts: 36
Joined: Mon May 09, 2011 3:23 pm

Re: Scripting IDE

Post by nobaday » Sat Jul 16, 2016 1:23 pm

Thanks. And yes, I was going to ask where in the dictionary is this but you answer that!
Will try this tomorrow.
Much apreciated.

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Fri Mar 09, 2018 6:51 pm

HI.
On LC 8.1.9 a

Code: Select all

go stack "RevApplicationOverview"
trows an error.
What gives? Is it because it is in the plugin ?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

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

Re: Scripting IDE

Post by FourthWorld » Fri Mar 09, 2018 7:24 pm

We may be able to answer that if we can know what the reported error is.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Fri Mar 09, 2018 7:32 pm

Unfortunately it does not make sense.
The code is:

Code: Select all

on Preopenstack
   set the defaultstack to me
   set the itemdelimiter to "/"
   --find if to break
   put the filename of this stack into _PathMain
   delete last item of _PathMain
   if item -1 of _PathMain <> "Plugins" and item 3 of  _PathMain = "MyUserName" then --only for me and if not in the plugin folder
      go stack "RevApplicationOverview"
      Breakpoint
   end if
---
The error is:
stack "MyStack": execution error at line 48 (if-then: error in statement), char 1
The error is not trows if I delete the line: go stack "RevApplicationOverview"
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

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

Re: Scripting IDE

Post by FourthWorld » Fri Mar 09, 2018 7:38 pm

I'll assume the error is "stack not found". There's a function provided by the IDE for obtaining the path to the IDE Plugins folder. I'm on a phone so I'm unable to look it up right now, but IIRC it's also listed in the v5.x release notes.

With that path you should be able to point to the stack file reliably.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Sat Mar 10, 2018 1:41 pm

Ok.
Considering that RevProjectBrowser has been renamed RevIDEProjectBrowser (?) and that we are talking of IDE plugin and not "MyLivecode" plugin, and that if you take off the ".rev" part of revapplicationoverview it does not work, and that all this should not be so difficult...
this works (on OSX. For Windows you need a different path):

Code: Select all

on Preopenstack
   put Specialfolderpath("engine") into tPathOverview
   set the itemdelimiter to slash
   put "tools/Plugins/revapplicationoverview.rev" into last item of tPathOverview
   go stack tPathOverview 
   go stack "RevIDEprojectBrowser"
end preopenstack
I wonder when they are going to fix the "revapplicationoverview/ProjectBrowser" odd couple. Specially the Project Browser that I believe needs a complete redraw.
Last edited by trevix on Sat Mar 10, 2018 2:01 pm, edited 1 time in total.
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Sat Mar 10, 2018 2:01 pm

Also, let's put a "wait 1 seconds with messages" so that the IDE loads. Otherwise, if you start LC double-clicking on a stack, there is a "merg...something" that will mess things up (if this is your starting stack, off course).

Code: Select all

on Preopenstack
   wait 1 seconds with messages
   put Specialfolderpath("engine") into tPathOverview
   set the itemdelimiter to slash
   put "tools/Plugins/revapplicationoverview.rev" into last item of tPathOverview
   go stack tPathOverview 
   go stack "RevIDEprojectBrowser"
end preopenstack
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Scripting IDE

Post by mwieder » Mon Mar 12, 2018 5:49 pm

Code: Select all

   local tPath
   local tFilePath
   
   put revEnvironmentPluginsPath() into tPath
   put tPath & slash & "revapplicationoverview.rev" into tFilePath
   go stack tFilePath

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Scripting IDE

Post by bogs » Mon Mar 12, 2018 10:15 pm

That is certainly short, sweet, and to the point.
Image

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Scripting IDE

Post by mwieder » Tue Mar 13, 2018 1:25 am

tested also.

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Tue Mar 13, 2018 9:47 am

One minor detail:
opening the project browser or the revapplicationoverview with a "GO" command, make them editable with the pointer tool. And this in not a great idea.
Is there some flag to set?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Location: Berkeley, CA, US
Contact:

Re: Scripting IDE

Post by mwieder » Tue Mar 13, 2018 11:59 am

use

Code: Select all

palette stack tFilePath
instead of

Code: Select all

go stack tFilePath

trevix
Posts: 960
Joined: Sat Feb 24, 2007 11:25 pm
Location: Italy
Contact:

Re: Scripting IDE

Post by trevix » Tue Mar 13, 2018 7:26 pm

Perfect. Thanks you all.
Where do you find things like revEnvironmentPluginsPath()?
Trevix
OSX 14.3.1 xCode 15 LC 10 DP7 iOS 15> Android 7>

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”