filenames and fields

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
Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

filenames and fields

Post by Damlimey » Sun Jun 14, 2009 5:02 pm

Hi all,

I want to display in a field, the filename that I have already loaded into a player. I've managed to get the filename into a field but it includes the path to the file, how do I return just the filename and it's extension?

Thanks in advance,

G

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

Post by SparkOut » Sun Jun 14, 2009 5:41 pm

Something like

Code: Select all

set the itemDelimiter to slash
answer file "Choose the file"
put the last item of it into theFileName
if theFileName is not empty then
  -- and whatever other error trapping you need here
  put theFileName into field "theFileNameField"
end if
since Rev uses a slash "/" as its native file path separator, you can use that as the itemDelimiter. If you are working with raw Windows filepaths, then you may need to change "/" to "\" (slash to backslash) or adjust for other file systems as appropriate. If you use the ask file version, then Rev should automatically use the "/" in the path. You can change the itemDelimiter at will, and it will stick for that current handler, and revert to comma after the handler has exited.

Damlimey
Posts: 31
Joined: Sun May 31, 2009 10:56 am

Thank you very much

Post by Damlimey » Sun Jun 14, 2009 6:39 pm

Thank you Sparkout, that's pushed me on a bit!

G

Post Reply