Adressing of files to included folders in standalone

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Adressing of files to included folders in standalone

Post by kresten » Sun Jul 21, 2019 12:54 pm

In a standalone with a selected "move substacks to individual files", permitting user to accumulate data in substacks , I found the option to include folders, and have thus included two named but empty folders meant to accumulate A) html files ( from parsings) and B) jpg files (from screenshots).
However I find no indication how to script the adressing of files to such folders in the relevant handlers.

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

Re: Adressing of files to included folders in standalone

Post by Klaus » Sun Jul 21, 2019 3:26 pm

Hi Kresten,

you will find everything later in your standalone here -> specialfolderpath("resources")
But be aware that only users with ADMIN permissions are allowed to write (save files in these folders) in the "Applications/Program files)" folder on the appropriate platforms!

So maybe you want to create and use (fill with files) your folder(s) in -> specialfolderpath("documents")


Best

Klaus

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Adressing of files to included folders in standalone

Post by kresten » Mon Jul 22, 2019 1:32 am

Hi Klaus
My application is freeware, so ADMIN permission should be implicit.

I am a little unsure about your use of the term "resources"

Does this just mean that my line
open file destination &"/"& parsings &"/"& filename (in the LC environment)
shall be
open file specialfolderpath("parsings")&"/"& filename (in the standalone) ???

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

Re: Adressing of files to included folders in standalone

Post by bogs » Mon Jul 22, 2019 9:43 am

kresten wrote:
Mon Jul 22, 2019 1:32 am
My application is freeware, so ADMIN permission should be implicit.
Heya Kresten :D
I think you misunderstood Klaus's statement, the permission he is describing has nothing to do with your program, per se, but with the structure of the underlying Operating System.

No matter which OS you use, you have a series of folders in the file system. Some, like 'Documents', 'Home', 'Desktop' and the like, are accessible to whomever is in the seat.

Other folders and files, usually pertaining to the OS itself, are only (readily) accessible to those with 'Administration' permissions attached to their account.

For example, if you wanted to edit the sources list in Linux (or really, any file below the Home folder), you would have to elevate your base user to "su", either temporarily using "sudo", or more permanently using "su", or login as "root", which is the top user.

Hopefully that clarifies Klaus's statement a bit :)
Image

kresten
Posts: 153
Joined: Tue Sep 30, 2008 3:01 pm
Location: Copenhagen
Contact:

Re: Adressing of files to included folders in standalone

Post by kresten » Mon Jul 22, 2019 3:15 pm

Thanks to both of you.

"So maybe you want to create and use (fill with files) your folder(s) in -> specialfolderpath("documents")"

Yes, apparently necessary !
But I am afraid I need detailed help in following this advice.
Optimally the standalone shall create a folder "Phenomenalog" containing a) folder "Parsings", b) folder "Snapshots" and c) a file "Diarysum.html"
How do I achieve this?
And if/when achieved how will I address these folder and this html file in the relevant handlers ?

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

Re: Adressing of files to included folders in standalone

Post by dunbarx » Mon Jul 22, 2019 4:57 pm

Hi.

Would not the "create folder" and "open file" commands do the trick?

Craig

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

Re: Adressing of files to included folders in standalone

Post by Klaus » Mon Jul 22, 2019 5:49 pm

Hi Kresten,

everything you add via the "Copy files" tab in the "Standlone Application Settings" for your standalone you will find here in the standalone -> specialfolderpath("resources")

So add your HTML file here and then do this on pre-/openstack/-card

Code: Select all

...
## Check if we need to create folder(s)
put specialfolderpath("documents") & "/Phenomenalog" into tFolder1
put specialfolderpath("documents") & "/Phenomenalog/Parsings" into tFolder2
put specialfolderpath("documents") & "/Phenomenalog/Snapshots" into tFolder3
if there is not a folder tFolder1 then
  create folder tFolder1
end if
## Same for tFolder2 and tFolder3

## Now copy the HTML file from resources folder to docs folder if neccessary:
put specialfolderpath("resources") & "/Diarysum.html" into tSourceFile
put specialfolderpath("documents") & "/Phenomenalog/Diarysum.html" into tTargetFile
if there is not a file tTargetFile then
  put url("file:" & tSourceFile) into url("file:" & tTargetfile)
end if
...
Now you can adresse you folder and files with:

Code: Select all

...
put specialfolderpath("documents") & "/Phenomenalog" into tPhenomenalogFolder
put specialfolderpath("documents") & "/Phenomenalog/Parsings" into tParsingsFolder
put specialfolderpath("documents") & "/Phenomenalog/Snapshots" into tSnapShotFolder
...
put specialfolderpath("documents") & "/Phenomenalog/Diarysum.html" into tHTMLFile
...
Get the picture?


Best

Klaus

Post Reply

Return to “Talking LiveCode”