Sample Rule 1

This page explores a simple rule to concatenate information taken from the item text to be placed in the [Net Location] folder. The value in the Net Location folder is then used to automatically open a folder on a server. There are two variations of the rule to explore the subtle differences and possibilities. First is a rule that makes use of conditionals within the value and the second places the conditionals at th end of the statement.

The item text (ITT) in this case is very specific consisting of five numbers and a possible leading 'W' taking the form, for example, 07289 or W07301 where the first two characters represent the year (07) and the remaining three a project number, the leading W indicates that the project is an inspection project whereas without the W it is an engineering project.

The first rule developed took this form:

++:I!+-:iff([Engineering Projects],"""H:\20"+match(ITT,'\b(\d\d)\d\d\d\b')+"\" + match(ITT,'\b\d\d(\d\d\d)\b')+"""",iff([Inspection Projects],"""I:\20" + match(ITT,'\b\w(\d\d)\d\d\d\b')+"\" + match(ITT,'\b\w\d\d(\d\d\d)\b')+"""","")):len(ITT)=5 OR len(ITT)=6

where;

++:
required at the start of all rules
I!+-:
the flags that tell the rule when it is to work or not work (see Flags Values Conditions for details) the flag basically triggers when the text is initial created and anytime that it changes.
iff(
the start of th iff() statement (see rules for details) which is in the form iffcondition,true,false)
[Enginering Projects],
The condition statement which in this case is true if the ITT is in the [Engineering Projects] folder where [Engineering Projects] is a check mark folder therefore if checked it is true.
"""H:\20"+
this is a fixed string which sets up the initial value to drive H and th start of the year 20xx
"match
the match function which extracts information from a string match(string,pattern)
(ITT,'\b(\d\d)\d\d\d\b')
the item text first two numbers are extracted from a total of five (see patterns for more information) in this case the first two numbers represent the year

"+"\"+"
this sets up the slash required to indicate a subdirectory the balance of the rule is just extraction of different parts of the ITT and concatenating it to the start

len(ITT)=5 OR len(ITT)=6
two conditionals to force the value to be calcualted and inserted only if the length (len(string)) of the ITT is eitehr 5 or 6.


The final result is "H:\2007\289" or "I:\2007\301", based on the examples above. It should be noted that the double quote marks are not necessary but are inserted as if the [Net Location] value has spaces in it, unless it is captured between double quotes, it will not work.


The rule was changed after examination and study to be simpler and more readable. The change is based on the fact that more than one rule may be applied at any time. In this case the rule was split into two rules as follows:

++:MTI!+:"""H:\20"+match(ITT,'\b(\d\d)\d\d\d\b')+"\" + match(ITT,'\b\d\d(\d\d\d)\b')+"""":[Engineering Projects]

++:MTI!+:"""I:\20"+match(ITT,'\b\w(\d\d)\d\d\d\b')+"\" + match(ITT,'\b\w\d\d(\d\d\d)\b')+"""":[Inspection Projects]


Note the difference in the flags MTI!+- to manually set the flags (M) and then to only work on the top level item (T) and then on first creation and when ever the ITT is changed. The concatenation remains the same as above but there are no imbedded conditionals, the conditional is simply the [Folder Name] at the end, after the last colon(:). This simplifies the rules making them work faster and are easier to read.

[the expression can simple replaced by "iff([Engineering Projects], replace("ITT","(W?)(\d{2})(\d{3})", '"H:\20$2\$3"', "")"]
[by slangmgh]


In keeping with this change the rules can read:

++:MT!+:ireplace(ITT,"(w?)(\d{2})(\d{3})", "H:\20$2\$3"):[Engineering Projects]

++:MT!+:ireplace(ITT,"(w?)(\d{2})(\d{3})", "I:\20$2\$3"):[Inspection Projects]