I'm trying to simply remove the extension from a filename that I have in a variable. I can't seem to find a substring type of function or keyword.
Ex:
put "My Song.mp3" into tTrack
answer tTrack // I want this to print "My Song" without the extension.
Substring function
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Substring function
Hi jwbuzz,
this is a case for the very flexible and settable "itemdelimiter"!
...
put "My Song.mp3" into tTrack
set itemdel to "."
## Display all ITEMS but the last of tTrack
answer item 1 to -2 of tTrack
...
Cool, isn't it?
You could also e.g.:
delete char -4 to -1 of tTrack
Hope that helps!
Best from germany
Klaus
this is a case for the very flexible and settable "itemdelimiter"!
...
put "My Song.mp3" into tTrack
set itemdel to "."
## Display all ITEMS but the last of tTrack
answer item 1 to -2 of tTrack
...
Cool, isn't it?

You could also e.g.:
delete char -4 to -1 of tTrack
Hope that helps!
Best from germany
Klaus
Re: Substring function
Thanks.. That's great.. Just a little unfamiliar coming from other languages.
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: Substring function
You could also resolved by thinking like this : I would remove the extension of my file.
So:
Now for manipulating substring, you can play with:
- items introduced nicely by Klaus
- chars
e.g. :
-> return "Gre"
- words
e.g. :
-> return "is great"
- lines
e.g. :
-> return "That is great
really great"
and you can combining all this key words:
e.g.:
-> return "gr"
There is language and language, depending that if you think like computers or humans
Regards,
So:
Code: Select all
put "My Song.mp3" into tTrack
set itemdel to "."
delete last item of tTrack
return tTrack
- items introduced nicely by Klaus

- chars
e.g. :
Code: Select all
put char 1 to 3 of "Great!"
- words
e.g. :
Code: Select all
put word 2 to 3 of "That is great"
- lines
e.g. :
Code: Select all
put line 1 to 2 of "That is great
really great
Cool!"
really great"
and you can combining all this key words:
e.g.:
Code: Select all
put char 1 to 2 of word 2 of line 2 of "That is great
really great
Cool!"
There is language and language, depending that if you think like computers or humans

Regards,
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel