Page 1 of 1

How to save an alias of a file in a stack?

Posted: Wed Nov 09, 2016 12:23 pm
by Mag
I know that each file in a disk has a path, and I can store it in a LiveCode container (for example a customer property), is there also the possibility to store in a LiveCode container a sort of alias of a given file (not an alias) on disk? I need this because I want to keep track of a document on the disc that could be moved or renamed by the user.

Re: How to save a file in a stack?

Posted: Wed Nov 09, 2016 1:01 pm
by Klaus
Hi Mag,

store an "alias" (= just the pathname!):
...
set the cAlias2File of this stack to "/Users/klaus/Desktop/fingers.jpg"
...
Store an actual file:
...
set the cActualFile of this stack to url("binfile:" & specialfolderpath("desktop") & "/fingers.jpg")
...
"Spit" it out again:
...
put the cActualFile of this stack into url("binfile:" & specialfolderpath("desktop") & "/fingers_copy.jpg")
...

Best

Klaus

Re: How to save a file in a stack?

Posted: Wed Nov 09, 2016 1:51 pm
by Mag
But if the user moves the file to another location the path doesn't work. I seem to recall that in Supercard there was a way to store a "sort of" alias that refer to the actual file regardless its location or its name.

Re: How to save a file in a stack?

Posted: Wed Nov 09, 2016 2:00 pm
by Klaus
Hi Mag,
Mag wrote:But if the user moves the file to another location the path doesn't work.
yes, but that is not my fault! :D
Mag wrote:I seem to recall that in Supercard there was a way to store a "sort of" alias that refer to the actual file regardless its location or its name.
Sorry, no idea how this could be done.


Best

Klaus

Re: How to save a file in a stack?

Posted: Wed Nov 09, 2016 2:05 pm
by Mag
Thank you Klaus.

Maybe I have to create a disk alias on the fly and store it to some hidden and super secret location on the disk... :D

Re: How to save a file in a stack?

Posted: Wed Nov 09, 2016 3:44 pm
by dunbarx
Mag.

You may, each time, have to explicitly ask for the pathname with the "answer file" command. A pain, but at least the user is burdened with that task, and not you.

Perhaps you can ease that burden by pre-determining if the file exists in the expected location, using the "there is a" operator?

Craig

Re: How to save a file in a stack?

Posted: Fri Nov 11, 2016 11:01 am
by Mag
Thank you so much Craig, I will go with the use of "there is a" operator :)

Re: How to save a file in a stack?

Posted: Fri Nov 25, 2016 4:25 pm
by Mag
Klaus wrote:Hi Mag,

store an "alias" (= just the pathname!):
...
set the cAlias2File of this stack to "/Users/klaus/Desktop/fingers.jpg"
...
Store an actual file:
...
set the cActualFile of this stack to url("binfile:" & specialfolderpath("desktop") & "/fingers.jpg")
...
"Spit" it out again:
...
put the cActualFile of this stack into url("binfile:" & specialfolderpath("desktop") & "/fingers_copy.jpg")
...

Best

Klaus
Sorry Klaus, I just realized that the title of the thread was wrong, now I corrected. I meant an alias ...