Checking a string for spaces

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
dbailey
Posts: 23
Joined: Fri Sep 06, 2013 4:47 pm

Checking a string for spaces

Post by dbailey »

Hi All,

What is the easiest way to check a string for spaces?.

If I have a filename called "The movie.mov" contained in a string say tFilename and I want the movie player to play that file without error?.
dbailey
Posts: 23
Joined: Fri Sep 06, 2013 4:47 pm

Re: Checking a string for spaces

Post by dbailey »

I just figured out a solution:-

replace space with "%20" in tFileName

seems to work :D
Klaus
Posts: 14325
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Checking a string for spaces

Post by Klaus »

What is the easiest way to check a string for spaces?
replace space with "%20" in tFileName
Hm, I am having a hard time to figure out the context of these two statements... :shock:
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10507
Joined: Wed May 06, 2009 2:28 pm

Re: Checking a string for spaces

Post by dunbarx »

Klaus.

Who knows what evil lurks in the hearts of men...

dbailey, good that you found a solution, but do you also see other ways to actually discover or delineate whether (and where) a string might contain spaces? A repeat loop that checks each char, or maybe the "is among" operator, that can drill down to the character level?

Craig Newman
kray
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 56
Joined: Sat Apr 08, 2006 5:28 pm
Contact:

Re: Checking a string for spaces

Post by kray »

dbailey wrote:If I have a filename called "The movie.mov" contained in a string say tFilename and I want the movie player to play that file without error?.
FYI: If you're working with a full path to the file, and you're using Windows, you can use the shortFilePath function, which returns an 8.3 formatted file path with no spaces:

Code: Select all

put "C:/Program Files/My App/My App Files/The movie.mov" into tPath
put shortFilePath(tPath) into tShortPath

--> puts the string "C:/PROGRA~1/MYAPP~1/MYAPP~1/THEMOV~1.mov" into tShortPath
Of course you already found a solution, but keep this in mind for the future if you need it.
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Post Reply