60aside Posted December 19, 2009 Share Posted December 19, 2009 Why is this not working? dim $var $var = "test.ost" if $var = "*.ost" Then msgbox(0,"","working") EndIf Exit Link to comment Share on other sites More sharing options...
dantay9 Posted December 19, 2009 Share Posted December 19, 2009 "*.ost" isn't the same as "test.ost". Simple as that. Wildcards aren't supported in variable names. The strings are compared literally and those strings aren't the same. Link to comment Share on other sites More sharing options...
60aside Posted December 19, 2009 Author Share Posted December 19, 2009 ok. so if I need to do something if a variable does contain ".ost" is there a simple way to do this? or do I have to read the filename somehow, seperate to the right of the "." and then do if var="ost" sorry, just starting out..... Thanks. Link to comment Share on other sites More sharing options...
60aside Posted December 19, 2009 Author Share Posted December 19, 2009 ok - I worked it out.... dim $var $var = "test.ost" $var2 = StringSplit($var,'.') if $var2[2] = "ost" Then msgbox(0,"","working") EndIf Exit Link to comment Share on other sites More sharing options...
Anteaus Posted December 20, 2009 Share Posted December 20, 2009 You can use StringSplit, but the most-useful function here is StringInStr()For example:$result = StringInStr("test.ost",".ost") should yield a numeric 5 as the substring is found (starting) in the fifth position. If ".ost" is not present, the function will return numeric zero. You can use the returned value directly in an If statement, as zero will be interpreted as False, any other number as True. If you want to be sure that something precedes the ".ost" then check for a value greater than one. The other more sophisticated method is to use regular expressions, but beware the trap that a regexes use different logic from filesystems. "*" in a regex has a very different meaning from "*.exe" or whatever in a filename. Link to comment Share on other sites More sharing options...
60aside Posted December 20, 2009 Author Share Posted December 20, 2009 Thanks in the end I used this :- dim $var $var = "test.ost" $var2 = StringRight($var,4) if $var2 = ".ost" then msgbox(0,"","working") EndIf Exit Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now