save standalone from script?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

save standalone from script?

Post by adventuresofgreg » Mon Mar 22, 2021 5:17 pm

As far as I can tell, the answer to this question is no.

Is there any way to create a standalone from within a script? I can't see any function for it aside from domenu, which doesn't work for saving standalone. Also I was able to use "select menuitem 25 of manu "File", but that depends on the exact state of the file menu at the time (it can change).

Thanks,
Greg

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

Re: save standalone from script?

Post by dunbarx » Tue Mar 23, 2021 3:44 am

Hi.

If you:

Code: Select all

select line 60 of menu "File"
you will start the standalone builder. I am not sure it will complete, though I do not see why not, assuming the standalone settings make sense.

Know that you can select any menuItem that way, but that all the submenus count as a line. I am not sure if the HC left-over command "doMenu" would also work.

Craig

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: save standalone from script?

Post by Thierry » Tue Mar 23, 2021 7:13 am

adventuresofgreg wrote:
Mon Mar 22, 2021 5:17 pm
I was able to use "select menuitem 25 of menu "File",.....
Quite hasardous to use fixed values for such cases.
And in the menu "File", because of the "Open Recent Files...",
nothing is fixed anyway.

So, a much better way:

Code: Select all

   constant SaSApp = "Save as Standalone Application..."
   get lineOffset( SaSApp, menu "File")
   if IT is not 0 then select line IT of the menu "File"
That said, I never tried for this specific command...

Good luck,

Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

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

Re: save standalone from script?

Post by dunbarx » Tue Mar 23, 2021 1:49 pm

Thierry.

I thought, while I was counting menuItem lines, it might be dicey to propose a fixed line number, but thought that the items in the "File" menu were not subject to change. But, as good practice, your way is definitely more robust.

I just tried it, though, and the process starts but will not complete. Selecting the menuItem by hand works, but not by script.

Craig

Thierry
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 875
Joined: Wed Nov 22, 2006 3:42 pm

Re: save standalone from script?

Post by Thierry » Tue Mar 23, 2021 2:25 pm

dunbarx wrote:
Tue Mar 23, 2021 1:49 pm
..... But, as good practice, your way is definitely more robust.

Craig
Thanks,
and yes, I hate any kind of numbers in any scripts :)

I just tried it, though, and the process starts but will not complete.
Selecting the menuItem by hand works, but not by script.
Well, I didn't try the next part....

What I can say is I was able in the past to buid a complete standalone by script,
even to upload it to my iPhone and debug it, all from Xcode,
but I did forget everything about it, sorry :(

Out of curiosity, where did you put your script to execute the menu item ?
In the stack to be saved as a standalone ?

Kind regards,
Thierry
!
SUNNY-TDZ.COM doesn't belong to me since 2021.
To contact me, use the Private messages. Merci.
!

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

Re: save standalone from script?

Post by FourthWorld » Tue Mar 23, 2021 5:06 pm

adventuresofgreg wrote:
Mon Mar 22, 2021 5:17 pm
Is there any way to create a standalone from within a script?
Yep. Menus in LC respond to a menuPick message where the argument passed is the menu item text.

Here's the script of the "Build App" button in my devolution toolkit, which will use the Standalone Builder's automated build option unless you've either not set it up before or choose to override it by holding the Shift key while pressing the button, in which case it'll bring up the Standalone Builder window:

Code: Select all

on mouseUp
   put the short name of the topstack into tStack
   put the customProperties["cRevStandaloneSettings"] of stack ( the mainstack of stack tStack) into tA
   if tA is not an array OR the shiftKey is "down" then
      dispatch "menuPick" to btn "File" of grp "revMenuBar" of stack "revMenuBar" \
            with "Standalone Application Settings..."
   else
      dispatch "menuPick" to btn "File" of grp "revMenuBar" of stack "revMenuBar" \
            with "Save as Standalone Application..."
   end if 
end mouseUp
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7210
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: save standalone from script?

Post by jacque » Tue Mar 23, 2021 8:19 pm

Another option, which I haven't tested, is to just call the actual IDE handler:

Code: Select all

revIDESaveAsStandalone the long id of the topStack 
I assume you could just pass the actual long ID of the stack itself instead of referencing the topstack.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: save standalone from script?

Post by adventuresofgreg » Tue Mar 23, 2021 10:33 pm

Thanks! Got standalone saving to work within a script. I don't suppose there is any way to continue the script AFTER the SA has been built hey?

Richard (FourthWorld), a long time ago we discussed various ways of launching clone applications intended to target multiple CPU's to take advantage of some controlled multi processing. This is what I'm doing with the SA's. And it works pretty slick:

A data optimization process that took 60 minutes on my 2013 Mac Pro using a single LC app, now takes a little less than 4 minutes using my 12 core 2019 Mac Pro. Currently, it takes all of pushing 3 buttons:

1. Save a new standalone

2. Clone standalones, one for each core, then launch them all.

Within this LC script, we make 12 (or however many cores you want to deploy) duplicates of the standalone, then launch them. Each standalone is named with the number of core it is targeting (ex: "CORE-2.exe" ). When each SA is launched, it recognizes that it is part of a multiprocessor function by the "-2" in it's filename. It uses the "2" to split the files to process by 12, and work on the 2nd subset only). When the SA is finished processing it's smaller subset of the large file list, then it sums it's findings in a file (or mySQL field) and quits.

3. Combine and clean-up

The last function combines all 12 of the summary files, deletes the SA's, and does the remaining data summary work (charts, stats, etc).

It would be great to combine all 3 buttons into 1 function/button, but I have no way of knowing when all 12 SA's and finished their work to make the summary and clean up. Also, as mentioned before, after I create the initial SA, I no longer have control of LC via my script.

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

Re: save standalone from script?

Post by FourthWorld » Tue Mar 23, 2021 10:43 pm

You should be able to launch one application multiple times to get as many runtime instances as you need with less build work:

https://www.cnet.com/news/how-to-open-m ... n-in-os-x/
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: save standalone from script?

Post by adventuresofgreg » Tue Mar 23, 2021 10:51 pm

FourthWorld wrote:
Tue Mar 23, 2021 10:43 pm
You should be able to launch one application multiple times to get as many runtime instances as you need with less build work:
Long story short: I'm using Windows for this in Parallels running on my Mac Pro. Reason is that you can't run LC v.<7 (32 bit apps) in BigSur, and the LC v.>7 which are 64 bit SUCK at processing anything. So.. I run LC v. 5.5 in Windows in Parallels which lets me use all of the CPU's and also runs very quickly. So, I can run a single .exe file multiple times, but we have to way of PASSING information to the SA about what it's supposed to do (the instrument it is playing in the multi processor orchestra). Spinning out SA's allows me to name each one, and therefore pass it instructions through the name.

Post Reply

Return to “Talking LiveCode”