Page 1 of 1

Checking a string for spaces

Posted: Tue Oct 01, 2013 9:57 am
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?.

Re: Checking a string for spaces

Posted: Tue Oct 01, 2013 10:15 am
by dbailey
I just figured out a solution:-

replace space with "%20" in tFileName

seems to work :D

Re: Checking a string for spaces

Posted: Tue Oct 01, 2013 12:48 pm
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:

Re: Checking a string for spaces

Posted: Tue Oct 01, 2013 4:10 pm
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

Re: Checking a string for spaces

Posted: Wed Oct 02, 2013 3:19 pm
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.