Getting the name of the opened file

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Getting the name of the opened file

Post by bjb007 » Mon Sep 22, 2008 9:21 am

A search on this subject gives 14 or so pages
of results which would take quite a while to
read so...

When I open a file with

put URL ("file:" & it) into FileData

how do I get the name of the file that's opened?
Life is just a bowl of cherries.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Sep 22, 2008 9:48 am

bjb,

Assuming that the it variable contains a valid file name:

Code: Select all

put it into myFilePath
set the itemDel to slash
put last item of myFilePath into myFileName
put URL ("file:" & myFilePath) into myFileData
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Getting the name of the opened file

Post by bjb007 » Tue Sep 23, 2008 1:25 am

Thanks Mark.

Wise to add code to save itemDel and
restore after getting the file name else
in my case the file wouldn't load

Code: Select all

put it into myFilePath
put itemDel into someVar
set the itemDel to slash
put last item of myFilePath into myFileName
set itemDel to someVar
put URL ("file:" & myFilePath) into myFileData
Life is just a bowl of cherries.

Post Reply