Fog Creek Software
Discussion Board




Knowledge Base
Documentation
Terry's Tips
Darren's Tips

Foreach loops

Is is feasible to define a loop with two "and" conditions and one "not" condition? I presume it is, but can't get the coding right, or maybe its the positioning of the brackets.

The basic arrangement I'm trying is:
foreach x in (and (folder "A") (before today-90)(not keyword_contains Disablelisting))

do stuff
next
I've got the curly brackets and dollar signs in the right places. I've tried various combinations of brackets but get error messages with a number 819, or 820. Is there anywhere an index of those number?
You can see I'm a neophyte.

Keith King
Monday, November 25, 2002

What you're doing looks OK, but it would help if you could show us the actual code from your article rather than an approximation. There may be a typo or other error, rather than an error in your 'and' statement.

Darren Collins
Monday, November 25, 2002

The following example is working fine for me:

{$ foreach x in (and(not(keyword_contains "private")) (not(folder "family")) (not(filename "Index"))) SortDescendBy .fileddate $}

Does this help you?

Scott McDonald
Tuesday, November 26, 2002

Keith,

I see 3 conditions and only one "and". Also, I think Disablelisting should be in ""

Please post the exact script and the exact error code of citydesk.

Adriaan van den Brand
Tuesday, November 26, 2002

Thanks everyone! Sorry for the abbreviations in my script. In fact Scott shows the solution. It was really a logic problem of mine, not recognising that the "not" condition wqs part of the initial "and" and hence the required number of closing parentheses were only two after the last condition - if this is clear!

Keith King
Tuesday, November 26, 2002

The code ended up as:
{$ foreach x in (and (folder "Reports")(after today-90)(not (keyword_contains "DisableListing")))
        SortDescendBy .fileddate $}
This is not quite the same as I quoted in the earlier abbreviation, but same in principle I guess.

Keith King
Tuesday, November 26, 2002

*  Recent Topics

*  Fog Creek Home