Jump to content

An easy question - if you know the answer.....


60aside
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...