What's wrong with if (fileName ends with ".mov" or ".avi") then

What’s wrong with this syntax:

if (fileName ends with ".mov" or ".avi") then

This compiles and .mov are handled correctly, but .avi are ignored.

If I change the order

if (fileName ends with ".avi" or ".mov") then

.avi’s are handled.

Thanks. My first posting in a while. Been away from AS.

Try this instead:

if (fileName ends with ".mov" or fileName ends with ".mov") then

Thank you. Now that I see the correction, I remember this happening before. I need better record keeping and remembering to look at.

The key here is that you are ANDing or ORing two statements that have true or false values, not the conditions, so you have to include the whole true/false statement on each side of the boolean test.

I’ll try to keep that in mind in the future. But since AS is trying to be English like, it should work either way IMHO.

I wish there was a somewhat more structured program (language) than AS to use with Mac programs. I used to try to use Frontier which met that requirement; but it had its own problems. But I must be in a small minority because there doesn’t seem to be such a program anymore. Maybe it’s because the only language I more or less learned was Fortran (way back when), and I haven’t had enough motivation to learn something like Objective C.

Model:

if (fileName ends with ".mov" or fileName ends with ".mov") then

Now why won’t this compile:

if (folder triggerFolderCanon exists or folder triggerfolderminota exists)  then

I got syntax error: Expected “given”, “with”, “without”, other parameter name, etc. but found “or”.

This compiles:

if (folder triggerFolderCanon exists) then

when a term like this doesn’t work, I always try it with parentheses:

	if ((folder triggerFolderCanon exists) or (folder triggerfolderminota exists)) then

Thanks for the parentheses. It worked. I had tried a few parentheses, but not those. I guess the error should have clued me in where to look.

thanks again

Hi MtnBiker,

The reason why it errors is because ‘exists’ is a command and not a property. So when you do this:

(folder triggerFolderCanon exists or folder triggerfolderminota exists)

It’s the same as doing this:

(exists folder triggerFolderCanon or folder triggerfolderminota exists)

Since exists is a command, it’s looking for a parameter if there is anything past:

exists folder triggerFolderCanon

with ‘with’, ‘given’, etc., but it finds ‘or’ and as Stefan says the parenthisis denotes the end of the command.

gl,

Interesting I would have thought the “or” in the middle should be out side of the parenthesis at the same level as the “if” and the “then” as in

	if (folder triggerFolderCanon exists) or (folder triggerfolderminota exists) then

You’re right. In this case you can omit the outer parentheses,
but e.g in this term they are needed:

if (folder triggerFolderCanon exists) or ((folder triggerfolderminota exists) and (folder triggerfolderNikon exists)) then