Crazymoomin
Crazymoomin

Reputation: 305

Microsoft Script Control - Expected "Then"

I've been developing some software to help organize my files better. To do this I have developed a script generator using Microsoft Script Control that then runs on files in a directory and returns a boolean value depending on whether they match the filter conditions.

Problem is, whenever I add any logical operators to the if statement, I get a COM exception because the code failed to compile, expecting "Then". I can't find a line number but I'm guessing it's something wrong with the If statement.

Here's an example which does compile:

Function FilterFiles(Name, Extension, Size, Directory, Created, Accessed, Modified)
Dim Result
If StrComp(Extension, ".jpg", 1) = 0 Then
Result = True
Else
Result = False
End If
FilterFiles = Result
End Function

And an example which doesn't:

Function FilterFiles(Name, Extension, Size, Directory, Created, Accessed, Modified)
Dim Result
If StrComp(Extension, ".jpg", 1) = 0 0r StrComp(Extension, ".png", 1) = 0 0r StrComp(Extension, ".psd", 1) = 0 Then
Result = True
Else
Result = False
End If
FilterFiles = Result
End Function

Upvotes: 0

Views: 342

Answers (1)

Ekkehard.Horner
Ekkehard.Horner

Reputation: 38755

Your

.. 0 0r ..

instead of

.. 0 Or ..

looks like you use 0 (zero) instead of O (capital letter o) for the 0perator.

Upvotes: 1

Related Questions