Where store my general use scripts library?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Where store my general use scripts library?

Post by Fjord » Fri Aug 13, 2021 4:04 pm

Hi!
I have a general purpose stack, which I use for most of my programming, with a 'start using stack "scripts.livecode"'. It sits in one of my Livecode-related folder. Since 2001 (or so, IIRC), I have changed Macs and reorganised my Rev/LC folders, of course. Now I have about twenty versions of that stack :cry: .
Whenever I rearrange my files and folder, my old stacks can't run anymore, as they don't find the stack "scripts", because of the pathnames changes.
If I leave a copy of it near each of my stacks and use relative pathnames, that would be a 'bread crumbs' approach with dozens/hundreds of copies. I'd rather put it into some fixed place once for all. Is there a place that seems better than others? I've thought of:
- the Livecode folder in Applications but I don't like the idea of leaving a stack there
- the 'Development > Objects Library' but I can't seem to add anything to it; and can I add a script or a stack?
- anywhere else?
- or, of course, some fixed folder… which is still the same problem.
I feel most people here have solved that same problem, but I missed the right solution!
--
François

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

Re: Where store my general use scripts library?

Post by stam » Fri Aug 13, 2021 4:41 pm

Why not use an approach outlined by Richard here: viewtopic.php?p=207876#p207849
Basically serve it off the net - same stack accessible everywhere (although admittedly more difficult to update i suppose)

RCozens
Posts: 138
Joined: Thu Aug 05, 2021 6:42 am
Location: Manchester, CA USA

Re: Where store my general use scripts library?

Post by RCozens » Fri Aug 13, 2021 6:14 pm

Hello François,

Here is a handler I wrote many years ago:

on startLibrary libraryName
set the itemDelimiter to "/"
put the effective fileName of this stack into libraryPath
put libraryName into item -1 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
put "PlugIns" into item -1 of libraryPath
put "/"&libraryName after libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
switch (the platform)
case "Win32"
get specialFolderPath("Documents")&"/"&libraryName
if there is a stack it then
start using stack it
return empty
end if
break
case "MacOS"
if char 1 of the systemVersion < 7 then
delete item -5 to -3 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
delete item -2 of libraryPath
if there is a stack libraryPath then
start using stack libraryPath
return empty
end if
end if
break
end switch
return true -- = error
end startLibrary

It looks for the library stack in the same folder as the stack using it first. If the library stack is not there, it looks for it in a folder named "Plugins" in the same folder as the calling stack. If the library is not there, it looks in the Documents folder on Windows or somewhere else on MacOs (I don't remember the details...I have not used MacOS in many years).

Hope this helps.
Rob Cozens dba Serendipity Software Company
Manchester, CA USA

Each new generation gives more attention to the man-made world...
and less attention to the world that made man.

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Where store my general use scripts library?

Post by Klaus » Fri Aug 13, 2021 6:43 pm

Bonsoir François,

why not use the build-in means?

1. Put the lib stack(s) into the same folder as the later standalone stack
2. Add your lib stack(s) via the "Copy files" tab in the "Standalone Application Settings" for your standalone.
3. Now you can access these stack(s) in your runtime as well as in the IDE!

Code: Select all

...
## Works on ANY platform, desktop and mobile AND in the IDE!
start using stack (specialfolderpath("resources") & "/scripts.livecode")
...
Hope that helps!


Best

Klaus

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

Re: Where store my general use scripts library?

Post by jacque » Sat Aug 14, 2021 5:25 pm

I've used a similar development library for years. I keep it in the user Plugins folder. LC will recognize it at startup. I've set it up in the Plugins Manager to open invisibly at startup. The stack itself has an openstack handler on the first card that inserts the stack script into back.

This allows all versions of LC to use it and I never have to move it or even think about it. I usually have more than one version of LC open and they all use it simultaneously.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

AndyP
Posts: 615
Joined: Wed Aug 27, 2008 12:57 pm
Location: Seeheim, Germany (ex UK)
Contact:

Re: Where store my general use scripts library?

Post by AndyP » Sun Aug 15, 2021 6:50 am

I do the same type of thing. Have the libraries in the plugins folder but, I have the plugins folders in a Dropbox account, which means that whatever computer I am using LiveCode on just has to have the plugins folder set to the Dropbox location. Just one location to worry about.😊
Andy Piddock
https://livecode1001.blogspot.com Built with LiveCode
https://github.com/AndyPiddock/TinyIDE Mini IDE alternative
https://github.com/AndyPiddock/Seth Editor color theming
http://livecodeshare.runrev.com/stack/897/ LiveCode-Multi-Search

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

Re: Where store my general use scripts library?

Post by jacque » Sun Aug 15, 2021 6:59 am

Funny, mine's in Dropbox too. It used to matter but I no longer use the laptop so it's kind of moot now. But I'm ready for the future if things change.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Where store my general use scripts library?

Post by Fjord » Fri Aug 20, 2021 9:39 pm

@Jaqueline
I just set up my general purpose script the same way as you described. Works just fine, of course. Thanks for the great idea!! :D
--
François

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Where store my general use scripts library?

Post by Fjord » Wed Aug 03, 2022 11:15 am

Back to that same subject, almost one year later:
I put my general purpose stacks 'Scripts.livecode' in Dropbox/Livecode Extensions/Plugins. Works all right.

Today I tried to make that stack a script-only stack, because that's what it should be, basically.

1) I copied the stack script from 'Scripts.livecode', removed the stack from Dropbox, created a script-only stack 'Skripts.livecodescript' (note the k, in order to avoid mix-ups) in that same Dropbox folder, pasted into the stack script, saved. Then in the IDE I went to the ‘’Development’ > Plugins' menu to declare the new stack. Couldn’t see it.
2) I tried to put 'Scripts.livecode' back into the ‘Plugins’ folder, I could see that stack, both in the ‘Windows’ menu and in the ‘’Development’ > Plugins' menu.
3) I removed the prefs, restarted LC, redefined the ‘Livecode Extensions’ folder, restarted LC, looked again, same situation.
I did all that stuff several times, of course.

Did I do something wrong? Or is there something that prevents a script-only stack to be a plugin?
--
François

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

Re: Where store my general use scripts library?

Post by richmond62 » Wed Aug 03, 2022 11:22 am

Personally all my "permanent cr*p" lives on 2 external USB drives (they are exact copies of each other)
so that when I am working on one of the 6 machines I use on a regular basis (bedroom, study (x 2)),
school (x 3), I have access to them as one of those 2 disks is always in my jacket pocket/sporran/shoulder bag.

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

Re: Where store my general use scripts library?

Post by stam » Wed Aug 03, 2022 12:14 pm

If you use iCloud and store desktop/documents in the cloud you can have a dedicated folder inside your Documents folder for example. As this is in iCloud it will be available on whatever
Mac you log in on with your iCloud account but also via a web browser interface for those systems you either don’t use iCloud mirroring or other OS’s. And you don’t have to worry about physical drives dying or theft, both of which have affected me previously (I guess this is similar to the dropbox method but is a step easier as you don’t have to set sync folders etc)

It is a Mac-centric approach and not useful to anyone that doesn’t use these settings.

But it is what I do and it works fantastically well (I’ve had to switch macs back and forth recently and it has worked perfectly). And as the plug-ins folder also resides in the Documents folder this is also taken care of…

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

Re: Where store my general use scripts library?

Post by richmond62 » Wed Aug 03, 2022 12:36 pm

It is a Mac-centric approach
As I live a double life: half Macintosh, half Linux, I stick to the external drive method. 8)

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Where store my general use scripts library?

Post by SparkOut » Wed Aug 03, 2022 1:23 pm

There are other options for automated cloud sync that don't rely on Mac only environments too. (Google Drive, Microsoft OneDrive, DropBox, mega.nz for instance).
And apps like Allway Sync that can manage synchronisation in a granular manner between all sorts of different services and drives, local, networked and removable.

Fjord
Posts: 132
Joined: Sat Dec 06, 2008 6:18 pm
Location: France

Re: Where store my general use scripts library?

Post by Fjord » Wed Aug 03, 2022 4:58 pm

Thanks, but I'm afraid you didn't really read the questions I asked, which was NOT 'where should I drop my files' (that was solved August 2021), but why can't I seem to use a script-only stack as a plugin?
--
François

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

Re: Where store my general use scripts library?

Post by jacque » Wed Aug 03, 2022 5:50 pm

Fjord wrote:
Wed Aug 03, 2022 4:58 pm
Thanks, but I'm afraid you didn't really read the questions I asked, which was NOT 'where should I drop my files' (that was solved August 2021), but why can't I seem to use a script-only stack as a plugin?
I'm guessing that LC filters plugins by extension and will only accept ".livecode" . Or it might check that the file is a stack, and SOS are saved as text files.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Talking LiveCode”