Page 1 of 1
Save on Desktop instead of Applications folder
Posted: Mon Dec 29, 2014 10:50 pm
by uelandbob
When I choose to Save a stack LC always suggests Applications folder (on Mac), but I want it to be Desktop. Is there some preference or something else where I can default the suggested save location as Desktop instead of Applications folder.
Re: Save on Desktop instead of Applications folder
Posted: Tue Dec 30, 2014 4:52 pm
by MaxV
Standalone application settings -> General -> Default build folder (it's the last field below)

Re: Save on Desktop instead of Applications folder
Posted: Tue Dec 30, 2014 5:11 pm
by uelandbob
Thanks MaxV

, but that seems only to apply when building standalone apps, not when saving regular LC stacks (File/Save As...)
Re: Save on Desktop instead of Applications folder
Posted: Tue Dec 30, 2014 5:41 pm
by jmburnod
Hi uelandbob,
What about:
Code: Select all
put specialfolderpath() & "/ " & "myStack" into tFile
save stack "MyStack" as tFile
Best regards
Jean-Marc
Edit: Sorry I forgot "desktop" the correct syntax is
Code: Select all
put specialfolderpath("desktop") & "/ " & "myStack" into tFile
save stack "MyStack" as tFile
Re: Save on Desktop instead of Applications folder
Posted: Tue Dec 30, 2014 9:54 pm
by uelandbob
Thanks Jean Marc,
It is not big deal it is easy to choose a different folder each time I want to save a file, but your code can come in very handy in many situations

Re: Save on Desktop instead of Applications folder
Posted: Wed Dec 31, 2014 12:32 am
by jacque
The Save dialog opens to whatever folder is currently the defaultFolder. When you launch LiveCode, that's the Applications folder. To change it, do this in a script or from the message box:
Code: Select all
set the defaultFolder to specialfolderpath("desktop")
You only need to do that once per session and after that it will stick unless a script changes it to something else later. The folder will reset on each launch, so you have to reset it each time. Or you can create a plugin that sets it, and have the plugin load when the IDE starts up.
Re: Save on Desktop instead of Applications folder
Posted: Wed Dec 31, 2014 6:54 am
by uelandbob
Thanks Jacque,
Very good solution, even though I do not know how to write a plugin. Is that difficult? Where do you get info on how to do that? In the good old days of HyperCard there was this concept of Home stack. In Home stack you could just put the code on OpenStack handler. Does LiveCode have something similar to the Home stack.
Re: Save on Desktop instead of Applications folder
Posted: Wed Dec 31, 2014 8:17 pm
by jacque
A plugin is just a regular stack that you can tell LC to launch at startup. You can put any handlers in there that you need and make it function like HC's Home stack script used to by putting the stack script into use. But for this one-time deal you wouldn't want to do that. You'd just want it to do the setup once and then go away.
So, make a new stack and in the card script put this:
Code: Select all
on preOpenStack
set the defaultFolder to specialFolderPath("desktop")
end preOpenStack
Save the stack and move it into your Plugins folder. You can see where that is in LC preferences at the bottom of the Files & Memory pane ("User extensions".) If you don't have a Plugins folder yet, create one at that location. Note that the "user extensions" folder is the one that encloses the Plugins folder; don't point User Exentions to the plugins folder itself.
Restart LC and it will load your plugin.
You can now open the plugin stack by choosing it from the Development/Plugins menu and it will set the defaultfolder when it opens. But you probably want that to happen automatically, so choose Plugin Settings and select your stack from the top popup button. Select the radio button to start up the plugin "When LiveCode starts up" and set it to open as "invisible". The next time you launch LC the stack will open invisibly, the preopencard handler will run, and the defaultfolder will be set.
As written, this leaves the stack open in RAM. I do that because I have dozens of handlers in the stack script that I use during development. My preOpenStack handler in the first card inserts the stack script into the backscripts and they are available at all times, just like HC Home scripts used to do. If you don't want the stack hanging around, add a "close this stack" command to the preopenstack handler and it will go away.
Re: Save on Desktop instead of Applications folder
Posted: Wed Dec 31, 2014 8:56 pm
by uelandbob
Thanks Jacque, this is brilliant

This will make it possible to make my own box of ready made scripts to use each time I create a new stack.