reverse Filter String until FileDoesExist
I want to create loop that runs through a string until it finds the first DoesFileExist == true and then execute the script.
for example:
varString = C:\users\mike\donuts\bunnies\v01
(run backwards through string checking until true) varString
C:\users\mike\donuts\bunnies\v01 = FALSE
C:\users\mike\donuts\bunnies = FALSE
C:\users\mike\donuts = TRUE
stringn = "C:\Users\Joker\Desktop\cool\maybe\v01" for i=1 to stringn.count do ( tempStream = (substring stringn 1 (stringn.count as integer - i)) isValidDir = doesFileExist tempStream print tempStream print isValidDir )
Comments
Thanks
Thank you Anubis for helping out.
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
my logical mistake :)
it happens often when i write a directly to the site without testing :) so, thanks for asking. Now the While loop not break due to the boolean test (pathParts.count > 0) that return true to the end. So, here is fixed function:
my recent MAXScripts RSS (archive here)
Anubis
When I run the code below it returns = "C:\"
When in reality the folders go as deep as = "C:\Users\Joker\Desktop\cool\"
So it should be returning that = "C:\Users\Joker\Desktop\cool\
Why is that?
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
I think you can optimize a
I think you can optimize a bit the function if you kick out the 'return' call. Something like ... (I write it on-the-fly, ie not tested):
my recent MAXScripts RSS (archive here)
solution if anyone needs it!
John Martini
Digital Artist
http://www.JokerMartini.com (new site)