Save on Desktop instead of Applications folder

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

Post Reply
uelandbob
Posts: 72
Joined: Mon Dec 29, 2014 3:28 pm

Save on Desktop instead of Applications folder

Post by uelandbob » Mon Dec 29, 2014 10:50 pm

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.
uelandbob@gmail.com

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: Save on Desktop instead of Applications folder

Post by MaxV » Tue Dec 30, 2014 4:52 pm

Standalone application settings -> General -> Default build folder (it's the last field below) :D
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

uelandbob
Posts: 72
Joined: Mon Dec 29, 2014 3:28 pm

Re: Save on Desktop instead of Applications folder

Post by uelandbob » Tue Dec 30, 2014 5:11 pm

Thanks MaxV :) , but that seems only to apply when building standalone apps, not when saving regular LC stacks (File/Save As...)
uelandbob@gmail.com

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Save on Desktop instead of Applications folder

Post by jmburnod » Tue Dec 30, 2014 5:41 pm

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
Last edited by jmburnod on Wed Dec 31, 2014 11:13 am, edited 1 time in total.
https://alternatic.ch

uelandbob
Posts: 72
Joined: Mon Dec 29, 2014 3:28 pm

Re: Save on Desktop instead of Applications folder

Post by uelandbob » Tue Dec 30, 2014 9:54 pm

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 :D
uelandbob@gmail.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Save on Desktop instead of Applications folder

Post by jacque » Wed Dec 31, 2014 12:32 am

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

uelandbob
Posts: 72
Joined: Mon Dec 29, 2014 3:28 pm

Re: Save on Desktop instead of Applications folder

Post by uelandbob » Wed Dec 31, 2014 6:54 am

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.
uelandbob@gmail.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Save on Desktop instead of Applications folder

Post by jacque » Wed Dec 31, 2014 8:17 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

uelandbob
Posts: 72
Joined: Mon Dec 29, 2014 3:28 pm

Re: Save on Desktop instead of Applications folder

Post by uelandbob » Wed Dec 31, 2014 8:56 pm

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.
uelandbob@gmail.com

Post Reply