getting filename
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
getting filename
I am having issues trying to get the filename of the chosen file when I do this...
on mouseUp
answer file "Please choose a file"
answer it
end mouseUp
I know this will give me the full file path, but I want to know how to JUST get the name of the file the user chose. Normally, I would just put the file path in a variable then strip away all the words prior to the last word, but I can't seem to figure that one out...anyhow, I just want the file name the user chose....ideas?
			
			
									
									
						on mouseUp
answer file "Please choose a file"
answer it
end mouseUp
I know this will give me the full file path, but I want to know how to JUST get the name of the file the user chose. Normally, I would just put the file path in a variable then strip away all the words prior to the last word, but I can't seem to figure that one out...anyhow, I just want the file name the user chose....ideas?
Re: getting filename
hmmm....
set itemDel to "/"
???
Simon
			
			
									
									set itemDel to "/"
???
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
						Re: getting filename
Yes, try this:
Just an idea...
Kind regards, Jean-Paul.
			
			
									
									Code: Select all
on mouseUp
answer file "Please choose a file"
put IT into thePath
set the itemDelimiter to "\"
get last item of thePath
answer IT
end mouseUpKind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.
						Re: getting filename
on mouseUp
answer file "Please choose a file"
put it into tFilename
repeat while tFilename contains "/"
delete the first character of tFilename
end repeat
answer tFilename
end mouseUp
			
			
									
									
						answer file "Please choose a file"
put it into tFilename
repeat while tFilename contains "/"
delete the first character of tFilename
end repeat
answer tFilename
end mouseUp
Re: getting filename
magice wrote:on mouseUp
answer file "Please choose a file"
put it into tFilename
repeat while tFilename contains "/"
delete the first character of tFilename
end repeat
answer tFilename
end mouseUp
 
   
  
Re: getting filename
Hi Jean-Paul,
			
			
									
									Code: Select all
on mouseUp
   answer file "Please choose a file"
   if it = empty then exit mouseup
   set the itemDelimiter to "/"
   answer item-1 of it
end mouseUphttps://alternatic.ch
						Re: getting filename
that's far more help than I ever expected! Thanks to everyone...
			
			
									
									
						Re: getting filename
I like your <item-1 of IT>jmburnod wrote:Hi Jean-Paul,
Code: Select all
on mouseUp answer file "Please choose a file" if it = empty then exit mouseup set the itemDelimiter to "/" answer item-1 of it end mouseUp

But be aware with the itemDelimiter... This one "\" or not this one "/", that is the question
 
   
  
 Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.
						Re: getting filename
Hi friends,
Happy easter 
 
Best
Klaus
			
			
									
									
						whatever platform you are on, Livecode will internally ALWAYS (sic!) use the UNIX Slash / as a path delimiter!This one "\" or not this one "/", that is the question
Happy easter
 
 Best
Klaus
Re: getting filename
Not subtle enough?Klaus wrote:

Re: getting filename
A bit cumbersome, to say the least...magice wrote:Not subtle enough?Klaus wrote:


Re: getting filename
Aaah, this LC is so cleaver...whatever platform you are on, Livecode will internally ALWAYS (sic!) use the UNIX Slash / as a path delimiter!

Discovering LiveCode Community 6.5.2.
						