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

Deploying to Mac OS? Ask Mac OS specific questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

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

Post by Mag » Wed Nov 09, 2016 12:23 pm

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.
Last edited by Mag on Fri Nov 25, 2016 4:26 pm, edited 1 time in total.

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

Re: How to save a file in a stack?

Post by Klaus » Wed Nov 09, 2016 1:01 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to save a file in a stack?

Post by Mag » Wed Nov 09, 2016 1:51 pm

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.

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

Re: How to save a file in a stack?

Post by Klaus » Wed Nov 09, 2016 2:00 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to save a file in a stack?

Post by Mag » Wed Nov 09, 2016 2:05 pm

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

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

Re: How to save a file in a stack?

Post by dunbarx » Wed Nov 09, 2016 3:44 pm

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

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to save a file in a stack?

Post by Mag » Fri Nov 11, 2016 11:01 am

Thank you so much Craig, I will go with the use of "there is a" operator :)

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How to save a file in a stack?

Post by Mag » Fri Nov 25, 2016 4:25 pm

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 ...

Post Reply

Return to “Mac OS”