Jump to content

Recommended Posts

Posted

"*.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.

Posted

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.

Posted

ok - I worked it out....

dim $var
$var = "test.ost"
$var2 = StringSplit($var,'.')

if $var2[2] = "ost" Then
    msgbox(0,"","working")
EndIf
Exit
Posted

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.

Posted

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

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
×
×
  • Create New...