Professional Documents
Culture Documents
Book of Rules
DriveWorksXpress and DriveWorks Solo Edition
www.driveworks.co.uk
DriveWorks Ltd.
www.driveworks.co.uk
2
The Little Book of Rules
3
Table of Contents
THE LITTLE BOOK OF RULES ................................... 1
TYPICAL RULES.....................................................11
6
The Little Book of Rules
7
DriveWorks Ltd.
8
What is a Rule?
The dictionary explanation of a rule is:
rule (noun) [rool]
www.driveworks.co.uk
DriveWorks Ltd.
10
The Little Book of Rules
Typical Rules
Below are some typical rules:
11
DriveWorks Ltd.
What’s in a Rule?
A rule, when broken down, is made up of two elements that
are separated by an equals sign:
ModelHeight = (234+987)*34
In English this means that the height of the model is equal to
34 multiplied by the result of adding 234 and 987.
When we start building a rule we ignore the left hand side,
because that is what we are building the rule for. The only
part we need to concentrate on is the right hand side – this is
what we call "The Rule".
Note that in the DriveWorksXpress Rule Builder the "="
must be present at the beginning of the rule. In DriveWorks
Solo’s Rule Builder the "=" is implied and is not shown.
The right hand side must be written in a certain form (this is
called syntax), as otherwise DriveWorks won’t be able to
understand it; much like a mathematical equation. The good
news is that DriveWorks’ syntax is easy to work with as it is
based on Microsoft Excel’s syntax and many people will have
used Excel or be familiar with it.
Elements of the rule can be fixed values (also called Literals),
e.g.
12 + 345 * 234
Or names that refer to values that are entered, or calculated
elsewhere:
WallGap + OpeningWidth * NumberOfDoors
12
The Little Book of Rules
Data Types
Values in a rule, as well as the result of the rule, have a data
type. The data types that are available in a rule are:
Numbers, e.g. 3, or -4.7
Text, e.g. "500 Kg"
Booleans, i.e. TRUE or FALSE
There is a fourth data type which is the Date/Time, but these
are generally entered as Text and are converted to a
Date/Time by a Date/Time function.
13
DriveWorks Ltd.
Operators
All mathematical operators can be used in a rule. Parentheses
can also be used as you would use them in any mathematical
formula.
- subtract
+ add
* multiply
/ divide
() parenthesis
^ power
Remember to use the asterisk for multiplication (*) and the
circumflex for "to the power" – (^) when creating your rules
in DriveWorks.
14
The Little Book of Rules
Functions
Functions are fantastic and are the real power of rules.
Functions start with their name; have parentheses, with zero
or more arguments in between.
Different functions have different numbers of arguments,
and some functions can have varying amounts of arguments.
So, a typical function would be:
ROUNDUP(345.876,2)
This function means that it will round up 345.876 to 2
decimal places.
SUM(234,765,912)
This function will add up the three numbers; 234, 765 and
912.
Notice that each argument is separated by a comma1.
Parentheses always surround the arguments, and the function
name always goes before the opening parenthesis:
FunctionName(Argument1,Argument2)
The type of value which gets returned depends on the
function.
For instance, the RoundUp function expects two numbers as
the arguments, and will give you back (or return) a number.
However, if you use the Left function, you will need to give it
two arguments, one as text and one as a number:
LEFT("DriveWorks",2)
The Left function will return the result "Dr", which is the
first two letters of "DriveWorks".
15
DriveWorks Ltd.
Literals
A literal is a value which is typed directly into a rule; it could
be a Number, Text, or a Boolean.
Numbers exist in rules to be calculated or to assist a function.
9 + 6
(4 ^ 4) * (4 + 2)
Text is used in rules for things like names of files, or
configurations.
Notice how literal text needs to be encased within speech
marks, whereas numbers do not.
So returning to an earlier rule:
IF(SafeWorkingLoad="500 Kg",200,250)
This is a function with three arguments; the first is comparing
the value referred to by a name (SafeWorkingLoad – which
isn’t in speech marks) with a literal value ("500 Kg"– which
needs to be in speech marks). If the comparison is true, then
the function will send back (or return) 200, and if it isn’t (i.e.
the comparison is false) then it will return 250.
Names
Names are references to values which come from somewhere
else. For example, the value that is typed into a textbox, an
option that is picked from a list of values, or the result of a
variable2.
16
The Little Book of Rules
Other Rules
A rule can also be nested – that is, it can contain bits of other
rules, for example:
ROUNDUP(OpeningHeight - 34, 3)
17
DriveWorks Ltd.
Making decisions
Making decisions is an essential part of many rules, for
example, the rule:
We use a support if the length of the
gantry is greater than 2 metres
shows one type of decision – a choice between two values.
Another type of decision is looking up one value in a table
and returning another value on the same row. This section
shows you how to make decisions in your DriveWorks rules.
IF
The IF function is probably one of the most common rules
used. The IF Function checks whether a specified condition
has been met, and returns one value if the condition is True
and another value if the condition is False.
Use IF to conduct conditional tests on values and formulas.
The format of the IF function is as follows;
IF(condition , value if condition is TRUE ,
value if condition is FALSE)
18
The Little Book of Rules
Conditions
Conditions allow you to determine if the User has made a
specific selection from a control, or entered a certain number.
Conditions can be set to determine when a variable equates to
a particular value or is under a certain value. Conditions can
evaluate who has logged onto the application. Basically,
conditions are arguments that determine if something has
happened.
A condition exists of three elements;
1. A reference that has a value
2. A comparison operator
3. A result to compare to the referenced value
A condition looks like this:
SafeWorkingLoad = "500 Kg"
Here, SafeWorkingLoad is a name referring to an input
control that can have a range of test values selected from it.
This condition asks if the selected value equals 500 Kg.
Comparison Operators
The chart below shows the available comparison operators
that can be used within a condition:
19
DriveWorks Ltd.
Values
Values determine the result of the IF function. If the
condition evaluates to True, the first of the two values is
returned. If the condition equates to False, the second value
is returned.
For example, a checkbox named ‘Mycheckbox’ can be
selected from the input form. The status of the checkbox
(checked or unchecked) determines whether to suppress or
unsuppress a captured feature. The rule for the captured
feature would look like this:
IF(MycheckboxReturn=TRUE,"Unsuppress",
"Suppress")
So when the checkbox is checked (i.e. equals TRUE), the
feature is to be unsuppressed. When the checkbox is
unchecked (i.e. equals FALSE), the feature is to be
suppressed.
Rule building can get a little complicated, especially when you
have a rule inside a rule. For instance, a rule can be built
within an IF function:
IF(SafeWorkingLoad="500 Kg",200,
IF(SafeWorkingLoad="100 Kg",250,300))
Here the third argument has been replaced by a complete IF
statement that will itself calculate a value based on its
condition. There is more about placing IF statements inside
other IF statements later on in this book.
20
Lookup
Constructing more powerful rules is discussed in the next
section. But before embarking on a complex series of IF
statements to achieve a result you may want to consider
Lookups.
Consider the following situation. Your user can select from a
list of Safe Working Loads (SWL) to specify a lifting gantry.
The safe working load selected determines the sectional size
of the I-section beam that carries the load. The table below
shows the effect the safe working load has on the section
depth, width and thickness.
Now the captured depth of the I-section model could be
driven by a rule in the form of a nested IF. And it would look
like…
IF(SWL=100,127,IF(SWL=250,152.4,IF(SWL=400,17
7.8,IF(SWL=600,203.2,IF(SWL=800,203.2,IF(SWL=
900,206.8,254))))))
However, we could table the data and bring this into the
DriveWorks project. This would look like the chart below:
www.driveworks.co.uk
DriveWorks Ltd.
22
The Little Book of Rules
Speech Marks
Using speech marks (""), you can determine which part of a
rule is plain text and which is a form control or variable:
OpeningHeight & "wide"
This would result in the following for an OpeningHeight of
4 inches:
4 wide
You may, however, want to include a double speech mark for
the inches, so the rule would be:
OpeningHeight & """ wide"
The result would now be:
4" wide
Notice that there are three speech marks together before the
word ‘wide’, as the double speech marks denote inches and
these must be included within a set of speech marks to ensure
they are shown in the return result.
23
DriveWorks Ltd.
Parentheses
Just like in any mathematical formula, the use of parentheses -
() - helps define which parts of the rule are calculated in
which order:
(12+345) * 234
The above formula has a different result to this one:
12 + 345 * 234
Parentheses are also required around function arguments:
SUM(123,132,322)
24
The Little Book of Rules
Advanced Rules
The rules covered so far should be sufficient to control
parameters in most circumstances. However more complex
situations may require a rule to have more depth. This section
explains how rules can be nested to achieve a single result
from many possible combinations.
Nested IF statement
The IF statement is a rule that is commonly nested. To
understand how to nest IF it is crucial that the basic IF
statement is understood. To recap on the earlier IF section:
The basic IF statement comprises a condition, a value when
true and a value when false. It appears in the following
format:
IF(condition,value if condition is TRUE,
value if condition is FALSE)
25
DriveWorks Ltd.
26
The Little Book of Rules
27
DriveWorks Ltd.
28
The Little Book of Rules
Becomes…
IF(OR
(WindowType="None",WindowType="Round",WindowT
ype="Crescent"), "Suppress" , "Unsuppress")
Exactly the same can be applied with the AND function. This
time all of the arguments within the AND function must be
true.
IF(AND(WindowType="None",WindowType="Round",W
indowType="Crescent"), "Suppress" ,
"Unsuppress")
29
DriveWorks Ltd.
30
The Little Book of Rules
Types of Rule
Rules define the outcome of a parameter.
Rules don’t need to be an elaborate equation or an involved
function. A fixed value defines the behavior of a parameter
just as much as a dynamic calculation.
In DriveWorks a rule is anything applied to a parameter or
property that drives the required outputs or behavior of the
user interface.
Rules in DriveWorksXpress are limited to parameters
captured from the models being driven. DriveWorks Solo can
drive model parameters more extensively, and also control
drawings and documents. DriveWorks Solo also allows rules
to be applied to control user form behavior (form navigation)
and the inputs added to each user form.
When using the value from a user form input value in a rule,
DriveWorksXpress will refer to it by name, while
DriveWorks Solo will suffix the name with the word Return.
For example a user form input called Length will be
LengthReturn (see page 17 for more details).
Note
In all of the following examples, where an input control is
referred to, we have used the DriveWorks Solo name (i.e.
suffixed with Return). When applying an example in
DriveWorksXpress do not use this suffix for a control name.
31
DriveWorks Ltd.
Unique naming
The top level component always requires a unique name, or
nothing will be generated.
Examples:
Include an input field on the user form, where a unique
number or code can be entered. Use this in the rule for the
file name:
32
The Little Book of Rules
Rule Meaning
Rule Meaning
33
Or make use of the inbuilt auto-number:
Rule Meaning
Intelligent naming
Using an intelligent naming convention means that
DriveWorks will recognize components that have previously
been built and will re-use them when it comes across the
name again.
Examples:
Use the input fields that affect the component to build up a
string of values:
Rule Meaning
www.driveworks.co.uk
TIP: Include text in between numeric input fields to indicate
what the number signifies:
Rule Meaning
Rule Meaning
Rule Meaning
www.driveworks.co.uk
DriveWorks Ltd.
Rule Meaning
IF( LengthReturn < Will delete the file the rule is applied to
1000 , "Delete" , when the value entered in the Length
"Unsuppress" ) control is less than 1000.
IF( LengthReturn < Will suppress the file the rule is applied to
1000 , "Suppress" , when the value entered in the Length
"Unsuppress" ) control is less than 1000.
Rule Meaning
IF( Length < 1000 , Will delete the file the rule is applied to
"Delete" , when the value entered in the Length
OrderNumberReturn) control is less than 1000, otherwise the
value entered in the OrderNumber input
will be appended to the master file name.
IF( Length < 1000 , Will delete the file the rule is applied to
"Delete" , "*" & when the value entered in the Length
OrderNumberReturn) control is less than 1000, otherwise the
value entered in the OrderNumber input
will be used as the file name of the
model.
36
Replacing components
A model can be replaced with a model that exists in the same
location as the model it is replacing. Make the File Name
result equal the name of the model to swap in.
The models being replaced must match, i.e. a part for a part.
Examples:
Rule Meaning
"M5x20 hex hd bolt" Will replace the file the rule is applied to
with a file named M5x20 hex hd bolt.
The file must exist in the same location
as the file being replaced.
www.driveworks.co.uk
Replacing driven components
A model that is being replaced into a new assembly can also
have captured parameters driven.
DriveWorks Solo uses its own <Replace> directive along
with the master name of the model. This avoids having to
apply the resulting name of the driven model.
Rule Meaning
www.driveworks.co.uk
The Little Book of Rules
Relative
To place the new model in a sub folder, named Results, of
the location the project is stored:
Rule Meaning
39
DriveWorks Ltd.
Rule Meaning
Absolute
When the model is not required to be within the Results
folder an absolute path can be used:
Rule Meaning
40
The Little Book of Rules
Configuration Rules
When configurations exist in the master model being driven,
they can be switched in the resulting model.
The result of the rule should be the name of the existing
configuration required to be used:
Rule Meaning
Rule Meaning
41
DriveWorks Ltd.
Dimension Rules
Linear Dimensions
A captured dimension will have a rule applied that results in a
numeric value. DriveWorks recommends driving dimensions
to positive numbers to avoid sketch defining issues.
Dimensions are driven in model units.
Rule Meaning
42
Angles
A captured angular dimension will have a rule applied that
results in a numeric value in degrees:
Rule Meaning
Patterns
Patterns can have the following basic parameters captured:
Spacing (Pitch) – Linear Patterns
Angle – Circular Patterns
Number of instances (Quantity) – Linear and
Circular Patterns
The captured spacing will have a rule applied that results in a
numeric value:
Rule Meaning
www.driveworks.co.uk
DriveWorks Ltd.
Rule Meaning
Rule Meaning
44
Tolerances
Captured dimensions can also have tolerances driven.
When controlling the tolerance of a captured dimension the
format of the output rule is:
NominalValue|LowerLimit|UpperLimit|Type
Where:
NominalValue - is the nominal dimension to be applied to
the parameter (in the SolidWorks document units)
LowerLimit - is the lower limit for the tolerance (in meters -
SolidWorks system units)
UpperLimit - is the upper limit for the tolerance (in meters -
SolidWorks system units)
Type - is an index number for the type of tolerance to be
applied - see chart below:
Basic 1
Bilateral 2
Limit 3
Symmetric 4
MIN 5
MAX 6
Fit 7
www.driveworks.co.uk
DriveWorks Ltd.
Rule Meaning
46
The Little Book of Rules
Feature Rules
Feature rules control the state of a feature, i.e. suppressed,
unsuppressed, or deleted.
Rule Meaning
47
DriveWorks Ltd.
Rule Meaning
D1Depth
Rule Meaning
48
D1DraftAngle
Rule Meaning
D1ApplyDraft
Rule Meaning
D1DraftOutward
Rule Meaning
D2Depth
Rule Meaning
www.driveworks.co.uk
DriveWorks Ltd.
D2DraftAngle
Rule Meaning
D2ApplyDraft
Rule Meaning
D2DraftOutward
Rule Meaning
50
The Little Book of Rules
Rule Meaning
D1Depth
Rule Meaning
D1DraftAngle
Rule Meaning
51
DriveWorks Ltd.
D2Depth
Rule Meaning
D2DraftAngle
Rule Meaning
52
The Little Book of Rules
Rule Meaning
D1Depth
Rule Meaning
D1DraftAngle
Rule Meaning
53
DriveWorks Ltd.
D1WallThickness
Rule Meaning
D2Depth
Rule Meaning
D2DraftAngle
Rule Meaning
D2WallThickness
Rule Meaning
54
The Little Book of Rules
ThinWallType
Rule Meaning
55
DriveWorks Ltd.
Rule Meaning
D1DraftAngle
Rule Meaning
D1ApplyDraft
Rule Meaning
56
The Little Book of Rules
D1DraftOutward
Rule Meaning
BothDirections
Rule Meaning
D2Depth
Rule Meaning
57
DriveWorks Ltd.
D2DraftAngle
Rule Meaning
D2ApplyDraft
Rule Meaning
D2DraftOutward
Rule Meaning
58
The Little Book of Rules
Rule Meaning
D1DraftAngle
Rule Meaning
D1WallThickness
Rule Meaning
59
DriveWorks Ltd.
BothDirections
Rule Meaning
D2Depth
Rule Meaning
D2DraftAngle
Rule Meaning
D2WallThickness
Rule Meaning
60
The Little Book of Rules
ThinWallType
Rule Meaning
61
DriveWorks Ltd.
Rule Meaning
TangentPropagation
Rule Meaning
KeepFeatures
Rule Meaning
62
The Little Book of Rules
EqualDistance
Rule Meaning
EdgeChamferAngle
Rule Meaning
EdgeDistance1
Rule Meaning
EdgeDistance2
Rule Meaning
63
DriveWorks Ltd.
Rule Meaning
KeepFeatures
Rule Meaning
PropagateToTangentFaces
Rule Meaning
64
RoundCorners
Rule Meaning
OverflowType
Rule Meaning
www.driveworks.co.uk
DriveWorks Ltd.
Rule Meaning
66
The Little Book of Rules
Rule Meaning
Note that each value is separated with the pipe (|) symbol.
67
DriveWorks Ltd.
Rule Meaning
RedReturn & "|" & Will write the result of the inputs
GreenReturn & "|" & Red, Green and Blue into the
BlueReturn custom property.
68
The Little Book of Rules
MaterialDatabaseName | MaterialName
Rule Meaning
69
DriveWorks Ltd.
Rule Meaning
70
The Little Book of Rules
Instance Rules
The instance rule is used to determine the suppression state,
as well as delete or replace the instance or change the
configuration of an instance of a part or sub-assembly in an
assembly.
An instance can have its state changed and configuration
switched by using the following format:
State Operation | Configuration Name
Rule Meaning
71
DriveWorks Ltd.
72
The Little Book of Rules
Drawing Rules
File Name Rule
The file name rule is used to determine the name of the
driven drawing.
Rule Meaning
73
DriveWorks Ltd.
Rule Meaning
74
The Little Book of Rules
Rule Meaning
Sheet State
Sheet state rules are used to delete or rename sheets.
Rule Meaning
75
DriveWorks Ltd.
Rule Meaning
76
View State Rules
View state rules are used to delete or change the
configuration of a view.
Rule Meaning
www.driveworks.co.uk
View Scale Numerator and Denominator Rules
View numerator and denominator rules are used to control
the scale of the view.
Rule Meaning
www.driveworks.co.uk
View Left and Top (Position) Rules
View left and top rules are used to control the position of the
view relative to the bottom left of the sheet.
Rule Meaning
www.driveworks.co.uk
DriveWorks Ltd.
Breakline Rules
Breakline rules are used to control the position of the
breaklines relative to the left and right of the view.
The Distance 1 reference is to the first breakline from the left
of the view edge. The Distance 2 reference is to the second
breakline from the right of the view edge.
Rule Meaning
80
The Little Book of Rules
Rule Meaning
Annotation Rules
The Annotation Note rule simply requires the result to be the
text required in the captured note.
There are many uses for driving notes, typically for
populating the text required in drawing title blocks. The
example below gives some idea of how to build rules to drive
notes.
Rule Meaning
81
DriveWorks Ltd.
Rule Meaning
82
The Little Book of Rules
83
DriveWorks Ltd.
84
The Little Book of Rules
Rule Meaning
85
DriveWorks Ltd.
86
The Little Book of Rules
Rule Meaning
Rule Meaning
87
DriveWorks Ltd.
Common Functions
There are hundreds of different functions that can be used
within the rules you build using DriveWorks. This chapter
will cover the most common ones, examples of how they can
be used and their correct syntax.
Please note:
Value can be a static number or a variable
Number is a number, or a reference to a number. A
reference can be a variable, such as
DWVariableNumber, or the result of a form
selection, such as SpinBoxReturn.
Text is a string of text or reference to some text. A
reference can be a variable, such as
DWVariableText, or the result of a form selection,
such as ComboBoxReturn.
88
Date and Time Functions
Date
This function returns the current date at the time it is called.
DATE()
If the DATE()function is called on the 21st August 2011, then
this will return the value: 21/08/2011
DateTime
This function converts a value into a date-time representation
using standard US English formatting (where . is used as the
decimal separator for decimal numbers).
DateTime([Value])
If DateTime(40631+30)is entered, this will return
04/28/2011.
If DateTime(DWVariableDate+20.5)is entered, this will
return 18/04/2011 12:00:00 when DWVariableDate is 40631.
DateTimeLocal
This function converts a value into a date-time representation
using standard current culture formatting.
DateTimeLocal([Value])
If DateTimeLocal(DWVariableDate+20,5)is entered, it
will return 18/04/2011 12:00:00 in UK type formatting
(04/18/2011 12:00:00 for US type formatting) when
DWVariableDate is 40631 on machines that use , as the
decimal separator.
www.driveworks.co.uk
DriveWorks Ltd.
DateValue
This function returns the system date value for the given date.
DATEVALUE()
If DATEVALUE("09/21/2010")is entered, this will return
the system value of 40442 for the given date.
If DATEVALUE(DATE())is entered, this will return the
system value of 40462 when called on the 11th October 2010.
Day
This function returns the day number from the given value.
DAY()
If DAY()is entered on the 11th October 2011, the value
returned will be 11.
If DAY(40462)is entered, this will return 11 from the given
system date value.
If DAY("09/21/2011")is entered, the value 21 will be
returned from the given date.
Hour
This function returns the hour, a number from 0 to 23, from
the given value.
HOUR()
If HOUR(NOW())is entered at the time of 13.20, then the
value returned will be 13.
If HOUR(0.555)is entered, this will return 13 from the given
system value time.
90
The Little Book of Rules
Minute
This function returns the minute, a number from 0-59, from
the given value.
MINUTE()
If MINUTE(NOW())is entered at the time of 13:20, then it will
return a value of 20.
If MINUTE("16:19:22")is entered, then the value of 19
will be returned from the given system value.
Month
This function returns the month number from the given
value.
MONTH()
If MONTH(DATE())is entered on the 12th August 2011, then
it will return the value of 8.
If MONTH("11 OCTOBER 2010")is entered, this will return
10 from the given date.
91
DriveWorks Ltd.
NetWorkDays
This function returns the number of work days between the
given dates.
NETWORKDAYS([StartDate],[EndDate],
[Holidays])
All dates must be in the mm/dd/yyyy format.
If NETWORKDAYS("10/08/2010","10/30/2010",
"10/12/2010")is entered, all the work days between
10/08/2010 and 10/30/2010 will be counted, except
10/12/2010 (indicated by Holidays), and will therefore
return 15 as the net amount of days worked.
If NETWORKDAYS("10/08/2010","10/30/2010",
"10/12/2010","10/13/2010")is entered, all the work
days between 10/08/2010 and 10/30/2010 will be counted
except the days of the 10/12/2010 and the 10/13/2010,
therefore returning a value of 14.
92
The Little Book of Rules
NetWorkDaysCustom
This function returns the number of work days between the
given dates, allowances for which days are weekend days and
holidays are specified by the WeekendValue and Holidays
values respectively.
NETWORKDAYSCUSTOM([StartDate],[EndDate],
[WeekendValue],[Holidays])
All dates must be in the mm/dd/yyyy format.
See Appendix A for WeekendValues.
NETWORKDAYSCUSTOM("10/08/2010","10/30/2010",3
,"10/12/2010")is entered, all work days between
10/08/2010 and the 10/30/2010 will be counted, where the
Mondays and Tuesday are taken as weekend days (3) and the
10/12/2010 is taken as holiday. This will return a value of 17
net work days.
Now
This function will return the current system date and time at
the time it is called.
NOW()
If NOW()is called on the 12th August 2011 at 9:19 am (and 12
seconds), the return value will be 12/08/2011 09:19:12
Second
This function returns the second, a number from 0 – 59,
from the given value.
SECOND()
If SECOND(NOW())is entered at the time of 13:20:47, a value
of 47 will be returned.
If SECOND("16;28;10")is entered, this will return 10 from
the given time value.
93
DriveWorks Ltd.
TimeValue
This function converts the given time to a serial number
value.
TIMEVALUE()
If the TIMEVALUE(NOW())function is called at the time of
13:17:02, it will return the system value of
0.553496458334848.
If TIMEVALUE("16;25;21")is entered, it will return a
system value of 0.684270833 for the given time.
Today
This function returns the current system date at the time the
function is called.
TODAY()
If TODAY()is called on the 12th August 2009, the value
returned is 12/08/2009
94
WeekDay
This function returns a number representing the day of the
week.
WEEKDAY([Date],[ReturnType])
Date is the date to return the weekday from.
ReturnType is a number representing the day in which the
week starts.
Please see Appendix B for ReturnType values.
If WEEKDAY(Today(),2)is called on a Monday, it will
return 1 as the ReturnType value defines Monday as the first
day (2).
If WEEKDAY("10/08/2010")is entered, this will return 6 as
the value as the date falls on a Friday and the ReturnType
has been omitted, which will mean Sunday is counted as the
first day of the week.
WeekNum
This function returns the week of the given date as a number.
WEEKNUM([Date],[ReturnType])
Date is the date to return the week number from.
ReturnType is a number representing the day on which the
week starts.
Please see Appendix C for ReturnType values.
If WEEKNUM(Today())is entered as a function on the
10/18/2010 it will return 43 as the week number.
If WEEKNUM("10/18/2010",12)is entered, this will return
a value of 42 as the date given falls on a Monday and the
week is set to start on a Tuesday (represented by
ReturnType value 12).
www.driveworks.co.uk
DriveWorks Ltd.
WorkDay
This function returns the date before or after a specified
number of work days.
WORKDAY([Date],[Days],[Holidays])
Date is the date to start counting the number of work days
from.
Days is the number of work days to include.
Holidays are the dates to be ignored.
If WORKDAY(Today(),10,"10/19/2010")is entered and
the function is called on the 18th August, the value returned
will be 12/08/2010.
WorkDayCustom
This function returns the date before or after a specified
number of work days.
WORKDAYCUSTOM([Date],[Days],[Weekend],
[Holidays])
Date is the date to return the week number from.
Days is the date to return the week number from.
Weekend is the date to return the week number from.
Please see Appendix D for Weekend values.
If WORKDAYCUSTOM(Today(),10,1,"10/27/2010")is
called on the 19th October 2010, then it will return the value
03/11/2010.
96
The Little Book of Rules
Year
This function returns the year from the given date or date
serial number.
YEAR([Date])
If YEAR(43563)is entered, the year 2019 will be returned
from the given date serial number.
If YEAR(Today())is called on the 19th October 2010 then it
will return the value of 2010.
97
Helper Functions
Color
This function takes three values and converts them to a color
value which can be used, for example, with the DWColor
custom property to drive a part color. Red, Green and Blue
are values from 0-255 (inclusive).
COLOR([Red],[Green],[Blue])
If the function entered is COLOR(123,51,204)then the
result returned will be 123|51|204 (red|green|blue).
DimensionText
This function displays text strings at the specified positions
around a dimension.
DIMENSIONTEXT([Left
Text],[RightText],[Top
Text],[BottomText])
LeftText is the text to be displayed to the left of the
dimension.
RightText is the text to be displayed to the right of the
dimension.
TopText is the text text to be displayed on the top of the
dimension.
Bottom Text is the text to be displayed at the base of the
dimension.
www.driveworks.co.uk
The Little Book of Rules
DimensionTextAll
This function sets all the text for that dimension to the
specified text.
DIMENSIONTEXTALL([AllText])
AllText is the text that you want to display on the dimension.
DIMENSIONTEXTALL(DimensionDescriptionTextBox
Return)would return the text from the Dimension
Description Text Box and display it on the dimension.
List
The List function is a helper that allows quick entry of a range
of items for inclusion into a list-type control.
"[Item A]|[Item B]|[Item C]"
Within the DriveWorks Rule Builder, lists can be entered by
entering each line item on a new line by hitting the return key.
Once all items have been entered into the editor, and Finish
is selected, the Rule Builder will automatically place | in
between each item and the entire string within quotes so it
can be displayed in a list-type control (e.g. List Box, Combo
Box or Option Group).
99
Text Builder
The Text Builder function is a helper that allows quick entry
of many values that require building into a single string of
text.
[ItemA]&""&[Item B]&""&[ItemC]
Enter text strings within quotes and numbers as values in the
Text Builder tab of the editor. Hit return after each entry to
create a joining item of text to include in the string. Click
Finish when the list is complete.
Once all items have been entered into the editor, and Finish
is selected, the Rule Builder will automatically apply the
syntax & " " & in between each item.
www.driveworks.co.uk
The Little Book of Rules
Logic Functions
And
The And function returns TRUE if all its arguments are
TRUE.
AND([LogicalExpression1],[Logical
Expression2],[LogicalExpression n])
Each LogicalExpression is a rule that, when evaluated,
returns either TRUE or FALSE.
There can be 1 to 255 LogicalExpressions in any one And
function.
If all LogicalExpressions return TRUE, the And function
will return TRUE.
If at least one of the LogicalExpressions returns FALSE,
the And function will return FALSE.
AND(LengthTextBoxReturn>=6,WidthTextBox
Return=<5)checks the return value of the Length Text Box
and the return value of the Width Text Box.
If the return value of the Length Text Box is greater than or
equal to 6, and the return value of the Width Text Box is less
than or equal to 5, then the And function will return TRUE.
If either one of the LogicalExpressions returns FALSE, then
the And function will return FALSE.
N.B. See the Chapter on Making decisions (page 188 onwards) for more
information on comparing values.
101
DriveWorks Ltd.
Boolean
This function converts a value into a Boolean representation
using standard US English spelling where decimal numbers
must use . as the decimal separator.
Boolean([Value])
Any number other than 0 will return TRUE. 0 will return
FALSE.
If Boolean(2.6)is entered, this will return TRUE.
If Boolean(DWVariableNumberToConvert)is entered, it
will return TRUE when DWVariableNumberToConvert is
not 0, and will return FALSE when
DWVariableNumberToConvert = 0.
If
This function specifies a logical test to perform.
IF([Condition],[IfConditionIsTrue],[If
ConditionIsFalse])
Condition is any rule which, when calculated, returns either
TRUE or FALSE.
IfConditionIsTrue is a rule or value which is returned if the
condition, when calculated, returns TRUE.
IfConditionIsFalse is a rule or value which is returned if the
condition, when calculated, returns FALSE.
IF(FormSpinButtonReturn<=5,"Can be shipped in
one container", "Will be shipped in several
packages.") checks the return value from the Form Spin
Button, and if the result is less than or equal to 5, it will
return "Can be shipped in one container". Otherwise it will return
"Can be shipped in several days".
N.B. See the Rule Building Operators chapter (page 14 onwards) for value
comparison information.
102
The Little Book of Rules
Not
The Not function reverses the logic of an argument.
NOT(LogicalExpression)
If the LogicalExpression returns TRUE, then the Not
function will return FALSE.
If the LogicalExpression returns FALSE, then the Not
function will return TRUE.
For example, NOT(ColorComboBoxReturn=
"Blue")means that the return value of the Color Combo
Box will be checked to see if it is equal to "Blue". If the Color
Combo Box return value is equal to "Blue", the
LogicalExpression will be evaluated as TRUE, therefore the
Not function will return FALSE.
Example Outcomes of the Not Function:
ColorComboBoxReturn = "Blue" Result of the NOT
function
TRUE FALSE
FALSE TRUE
N.B. Check out the Rule Building Operators section (page 11 onwards) for
more information on comparing values.
103
DriveWorks Ltd.
Or
The Or function returns TRUE if any argument is TRUE.
OR([LogicalExpression1],[Logical
Expression2],[LogicalExpression n])
LogicalExpressions are rules that return either TRUE or
FALSE.
There can be 1 to 255 LogicalExpressions in any one Or
function.
If at least one of the LogicalExpressions returns TRUE
then the Or function will return TRUE.
If all LogicalExpressions return FALSE then the Or
function will return FALSE.
OR(ProductComboBoxReturn="Door",ProductCode
TextBox="D355")means that if the Product Combo Box
return value is equal to "Door" or the Product Code Text
Box return value is equal to "D355" then the Or function will
return TRUE.
Example Outcomes of the Or Function:
N.B. Check out the Rule Building Operators section (page 11 onwards) for
more information on comparing values.
104
The Little Book of Rules
ChooseFrom
This function provides conversion functionality when a
specific input value is returned. A value is selected based on a
match with the input value. If no match is found the specified
default value is returned.
CHOOSEFROM([Input],[DefaultValue],
[InputValue],[Value1],
[InputValue2],[Value2],[InputValue
n],[Value n])
Input is the value or reference to a value that specifies which
value argument to select.
DefaultValue is the value to return when no InputValue is
found.
InputValue1, 2… n are the values being returned from the
Input.
Value 1, 2… n are the values to return when the
corresponding InputValue is returned.
InputValue and Value arguments work in pairs.
CHOOSEFROM(ColorReturn,"0|0|0","Red","255|0|0
","Blue","0|0|255", "White",
"255|255|255")means that:
0|0|0 is returned when the Color control entered is not Red,
Blue or White
255|0|0 is returned when the Color control value entered is
Red
0|0|255 is returned when the Color control entered is Blue.
255|255|255 is returned when the Color control entered is
White.
105
DriveWorks Ltd.
Math Functions
Abs
This function returns the absolute value of a number (i.e.
without regard to its sign).
ABS([Number])
ABS(-488.9)uses the number -488.9 and return the
absolute value of 488.9.
ABS(723)uses the number 723 and return the absolute value
of 723.
ACos
This function is used to calculate the arccosine (or inverse
cosine) of a Number.
ACOS([Number])
The value of Number can be a number between -1 and 1.
ACOS(-1)uses the number -1 and calculates the resulting
arccosine (inverse cosine), returning a value of
3.14159265358979.
ACosD
This function calculates the arccosine of a number. The result
is measured in degrees.
ACOSD([Number])
The value of Number can be any number between -1.0 to
1.0.
ACOSD(1)uses the number 1 and returns its arccosine
measured in degrees, giving a result of 0 degrees.
106
The Little Book of Rules
ACosH
The ACosH function, when calculated, returns the inverse
hyperbolic cosine, of the specified number.
ACOSH([Number])
ACOSH(10)will return the inverse hyperbolic cosine of 10,
which is 2.993222846.
ASin
This function is used to calculate the arcsine (or inverse sine)
of the specified number.
ASIN([Number])
The value of Number can be a number between -1 and 1.
ASIN(-0.45)uses the number -0.45 and calculates the
resulting arcsine giving a result of -0.466765339047296.
ASinD
This function calculates the arcsine of a specified number.
The result is measured in degrees.
ASIND( [Number] )
The value of Number can be any number between -1.0 and
1.0.
ASIND(1)uses the number 1 and returns its arcsine
measured in degrees. The result is 90.
107
DriveWorks Ltd.
ASinH
The ASinH function returns the inverse hyperbolic sine of
the specified number.
ASINH([Number])
ASINH(20)returns the inverse hyperbolic sine of 20, which is
3.689503869.
ATan
This function is used to calculate the arctangent (or inverse
tangent) of a specified number.
ATAN([Number])
ATAN(0.78)uses the number 0.78 and calculates the
resulting arctangent (inverse tangent). The result is
0.662426293833151.
ATan2
The ATan2 function, when calculated, returns the inverse
tangent of the chosen point, specified by the x-coordinate
and y-coordinate.
ATAN2([XCoordinate],[YCoordinate])
XCoordinate is the x-coordinate of the point that you want
to find the inverse tangent of.
YCoordinate is the y-coordinate of the point that you want
to find the inverse tangent of.
ATAN2(XCoordinateTextBoxReturn,YCoordinate
TextBoxReturn)will return the inverse tangent of the point
that is specified by the return values from the x-coordinate
and y-coordinate text boxes.
108
The Little Book of Rules
ATanD
The ATanD function calculates the arctangent of a number.
The result is measured in degrees.
ATAND([Number])
ATAND(1)will return the arctangent of 1 measured in
degrees. The result is 45.
ATanH
The ATanH function returns the inverse hyberbolic tangent
of the specified number.
ATANH([Number])
The Number must be between -1 and 1.
ATANH(0.7)returns the inverse hyperbolic tangent of 0.7
which is 0.867300528.
Ceiling
This function rounds a number up to the nearest specified
significance.
CEILING([Number],[Significance])
Significance is the number to which this function finds the
nearest (higher valued) multiple of.
CEILING(123.456,9)rounds the number 123.456 up to
the nearest multiple of 9. The resulting value is 126.
109
DriveWorks Ltd.
Choose
The Choose function returns a specified value from a range
of values that is specified by the index number.
CHOOSE([IndexNumber],[Value1],
[Value2],[Value n])
IndexNumber is a number, or reference to a number, that
specifies which value argument to select.
Value1 , Value2, Value n are the value arguments to choose
between.
There can be 1 to 254 Value arguments in any one Choose
function.
CHOOSE(CustomerNumberComboBoxReturn, "John
Smith","Sandra Thomas","Tom Harrison")uses the
return value from the Customer Number Combo Box to
return the corresponding value argument, which in this
example is the customer name.
Example Outcomes of the Choose Function:
Customer Value1 Value2 Value3 Result of
Number the
Combo CHOOSE
Box function
Return
Value
2 "John "Sandra "Tom Sandra
Smith" Thomas" Harrison" Thomas
110
The Little Book of Rules
Cos
This function calculates the cosine of the provided angle
(specified in radians).
COS([Angle])
COS(0.75)calculates the cosine of the provided angle (0.75
radians). The result is 0.731688868873821.
CosD
This function is used to calculate the cosine of an angle,
measured in degrees.
COSD([Angle])
COSD(90)returns the cosine of 90 degrees, which is 0.
CosH
The CosH function, when calculated, returns the hyperbolic
cosine of the specified hyperbolic angle.
COSH([HyperbolicAngle])
HyperbolicAngle is the specified hyperbolic angle to find
the hyperbolic cosine of.
COSH(2)returns the hyperbolic cosine of the hyperbolic
angle of 2. The result is 3.762195691.
111
DriveWorks Ltd.
Degrees
The Degrees function returns the specified angle in degrees.
DEGREES([Angle])
Angle is the specified angle, measured in radians, to be
converted to degrees.
DEGREES(CornerAngleTextBoxReturn)converts the
return value from the Corner Angle Text Box (6.283185307)
from radians to degrees, resulting in 360.
Even
This function rounds a number up to the nearest even
integer.
EVEN([Number])
If the Number is positive, the Even function will return the
specified Number rounded up to the nearest even integer.
If the Number is negative, the Even function will return the
specified Number rounded down to the nearest even integer.
EVEN(CustomerNumberTextBoxReturn)means that
depending on whether the return value from the Customer
Number Text Box is positive or negative, the Even function
will return the value of the Customer Number Text Box,
rounded up or down, to the nearest even integer.
Exp
The Exp function returns the constant, e, raised to the
specific number when calculated.
EXP([Number])
EXP(50)will return the constant e, raised to the number 50,
giving a result of 5.18471E+21.
112
The Little Book of Rules
Fact
The Fact function returns the factorial of the specified
number when calculated.
FACT([Number])
FACT(4)will multiply the numbers between 1 and 4 together
to obtain the factorial. In this example, the Fact function
would perform the following calculation: 1*2*3*4, resulting in
24.
FactDouble
The FactDouble function returns the double factorial of the
specified number.
FACTDOUBLE([Number])
If the specified Number is odd, the FactDouble function will
begin its multiplication at 1, and will cycle through the
numbers between 1 and the specified Number, in increments
of 2, multiplying them together.
If the specified Number is even, the FactDouble function
will begin its multiplication at 2, and will cycle through the
numbers between 1 and the specified Number, in increments
of 2, multiplying them together.
FACTDOUBLE(6)includes the number 6, which is even, so
the FactDouble function will perform the following
calculation: 2*4*6.
113
DriveWorks Ltd.
Floor
This function rounds a number down to the nearest specified
significance.
FLOOR([Number],[Significance])
Significance is the number to which this function finds the
nearest (lower valued) multiple of.
FLOOR(123.456,9)rounds the number 123.456 down to
the nearest multiple of 9, giving a resulting value of 117.
Int
This function rounds the specified number down to the
nearest integer.
INT([Number])
INT(46.932)rounds the number 46.932 down to the
nearest integer, which is 46.
IsEven
This function returns TRUE if the number is even.
ISEVEN([Number])
If the Number is even, then the IsEven function will return
TRUE.
If the Number is odd, then the IsEven function will return
FALSE.
ISEVEN(OrderNumberTextBoxReturn)checks the return
value of the Order Number Text Box and if it is an even
number, the IsEven function will return TRUE.
114
The Little Book of Rules
IsOdd
This function returns TRUE if the number is odd.
ISODD([Number])
If the Number is odd then the IsOdd function will return
TRUE.
If the Number is even then the IsOdd function will return
FALSE.
ISODD(PartCountTextBoxReturn)will check the return
value of the Part Count Text Box and if it is an odd number,
the IsOdd function will return TRUE.
Ln
The Ln function returns the natural logarithm of the specified
number.
LN([Number])
LN(3)will return the natural logarithm of 3, which is
1.098612289.
Log
The Log function returns the logarithm of the specified
number, to the selected base.
LOG([Number],[Base])
Base is a number that is the base of the logarithm.
LOG(30,2)finds the logarithm of the number 30 to base 2.
The result is 4.906890596.
115
DriveWorks Ltd.
Log10
The Log10 function returns the base-10 logarithm of the
specified number.
LOG10([Number])
LOG10(1000)will return the base-10 logarithm of 1000,
giving a value of 3.
Max
The Max function will return the largest value from the set of
numbers supplied.
MAX([Number1],[Number2],[Number n])
Number 1, Number2, Number n are numbers or
references to a number that you want to find the maximum
value of.
There can be 1 to 255 Numbers in any one Max function.
If no Numbers are entered then the Max function will return
0.
MAX(Part1CostTextBoxReturn,
Part2CostTextBoxReturn,Part3CostTextBox
Return)checks the return values of the Part 1, Part 2 and
Part 3 Cost Text Box return values. Whichever value is the
largest will be returned from the Max function.
116
The Little Book of Rules
Min
The Min function will return the smallest value from the set
of numbers supplied.
MIN([Number1],[Number2],[Number n])
Number1, Number2, Number n are numbers or references
to numbers from which you want to find the minimum value.
There can be 1 to 255 Numbers in any one Min function.
If no Numbers are entered then the Min function will return
0.
MIN(WidthTextBoxReturn,HeightTextBoxReturn,
DepthTextBoxReturn)will check the return values of the
Width Text Box, Height Text Box and Depth Text Box.
Whichever value is the smallest will be returned from the Min
function.
Mod
The Mod function divides the specified number by the
divisor and returns the remainder of the result.
MOD([Number],[Divisor])
Divisor is the number that you want to divide by.
MOD(BoardLengthTextBoxReturn,Slot
SpacingTextBoxReturn)divides the return value of the
Board Length Text Box by the return value of the Slot
Spacing Text Box. The remainder of the result is returned.
117
DriveWorks Ltd.
MRound
This function rounds the specified number to the specified
multiple.
MROUND([Number],[Multiple])
Multiple is the value you want to round the Number to.
MROUND(LengthTextBoxReturn,2)rounds the return
value from the Length Text Box (i.e. 15.3) to the nearest
multiple of 2, resulting in 16.
Odd
This function rounds a number up to the nearest odd integer.
ODD([Number])
If the Number is positive, the Odd function will return the
specified Number rounded up to the nearest odd integer.
If the Number is negative, the Odd function will return the
specified Number rounded down to the nearest odd integer.
ODD(CustomerNumberTextBoxReturn)will return the
value of the Customer Number Text Box (i.e. 12) rounded up
or down to the nearest whole integer, resulting in 13. If the
return value is negative (i.e. -9.42) the result would be -11, as
the function rounds down for negative numbers.
Pi
This function returns the value of pi, rounded to 14 decimal
places.
PI()
If PI()is entered, 3.14159265358979 is returned.
118
The Little Book of Rules
Power
The Power function returns a specified number raised to the
specified power.
POWER([Number],[Power])
Power defines the power to raise the specified Number to.
POWER(PartQuantityTextBoxReturn,2)will raise the
return value of the Part Quantity Text Box (i.e. 3) to the
power of 2, resulting in 9.
Product
The Product function multiplies all of the specified numbers
together and returns the result.
PRODUCT([Number1],[Number2],[Number n])
There can be 1 to 255 Numbers in one Product function.
PRODUCT(PartPriceTextBoxReturn,QuantityText
BoxReturn)multiplies the return values of the Part Price
Text Box and the Quantity Text Box together.
Quotient
This function divides the specified number by the specified
divisor, discarding the fractional part of the result to return
the integer.
QUOTIENT([Number],[Divisor])
QUOTIENT(TotalCostTextBoxReturn,QuantityText
BoxReturn)will divide the return value from the Total Cost
Text Box by the return value of the Quantity Text Box. The
integer part of the result will be the result, with the remainder
discarded.
119
DriveWorks Ltd.
Radians
This function returns the specified angle in radians.
RADIANS([Angle])
Angle is the angle, measured in degrees, which you want to
convert to radians.
RADIANS(CornerAngleTextBoxReturn)converts the
return value from the Corner Angle Text Box from degrees
to radians.
Rand
The RAND function returns a random number between the
values of 0 and 1.
RAND()
RAND()will return a random number between 0 and 1 when
called, such as 0.978623000429302 or 0.38559868530631.
RandBetween
The RandBetween function returns a random integer between
the smallest number and the largest number.
RANDBETWEEN([SmallestNumber],[Largest
Number])
SmallestNumber is the smallest integer that can be returned
when the RandBetween function is calculated.
LargestNumber is the largest integer that can be returned
when the RandBetween function is calculated.
RANDBETWEEN(NumberTextBoxReturn,Customer
CountTextBoxReturn)will return a random integer
between the return value from the Number Text Box and the
Customer Count Text Box.
120
The Little Book of Rules
Round
The Round function will return a specified number rounded
to the specified number of decimal places.
ROUND([Number],[DecimalPlace])
DecimalPlace is the number of decimal places to which the
specified Number should be rounded to.
ROUND(WidthTextBoxReturn/4,2)determines the return
value of the Width Text Box divided by 4, and rounds the
resulting value to two decimal places.
RoundDown
The RoundDown function will return a specified number
rounded down to the specified number of decimal places.
ROUNDDOWN([Number],[DecimalPlaces])
DecimalPlaces is the number of decimal places to which the
Number should be rounded.
ROUNDDOWN(WidthTextBoxReturn/4,2)determines the
return value of Width Text Box divided by 4 and rounds the
resulting value down to 2 decimal places.
RoundUp
The RoundUp function will return the specified number
rounded up to the specified number of decimal places.
ROUNDUP([Number],[DecimalPlaces])
DecimalPlaces is the number of decimal places to which the
specified Number should be rounded.
ROUNDUP(WidthTextBoxReturn/4,2)determines the
return value of Width Text Box divided by 4 and rounds the
resulting value up to 2 decimal places.
121
DriveWorks Ltd.
Sign
The Sign function returns the sign of a specified number.
SIGN([Number])
If the specified Number is positive, the Sign function will
return 1.
If the specified Number is negative, the Sign function will
return -1.
If the specified Number is 0, the Sign function will return 0.
SIGN(FundsAvailableTextBoxReturn)determines the
sign of the return value of the Funds Available Text Box.
Sin
The Sin function calculates the sine of the provided angle
(specified in Radians).
SIN([Angle])
SIN(0.46)calculates the sine of the given angle (0.46
radians). The result is 0.44394810696552.
SinD
The SinD function is used to calculate the sine of an angle,
measured in degrees.
SIND([Angle])
SIND(90)uses the angle of 90 degrees and returns the sine
of that angle. The result is 1.
122
The Little Book of Rules
SinH
The SinH function returns the hyperbolic sine of the
specified hyperbolic angle.
SINH([HyperbolicAngle])
HyperbolicAngle is the hyperbolic angle that you want to
find the hyperbolic sine of.
SINH(3)returns the hyperbolic sine of the hyperbolic angle
(3), resulting in the outcome of 10.01787493.
Sqrt
The Sqrt function returns the square root of the specified
number.
SQRT([Number])
SQRT(DepthTextBoxReturn)calculates the square root of
the return value from the Depth Text Box.
SqrtPi
The SqrtPi function multiplies the specified number by pi and
returns the square root of the result.
SQRTPI([Number])
SQRTPI(DepthTextBoxReturn)multiplies the return value
from the Depth Text Box by pi and returns the square root
of the result.
123
DriveWorks Ltd.
Sum
The Sum function adds all the specified numbers together
and returns the result.
SUM([Number1],[Number2],[Number n])
Number1, Number2, Number n are the numbers, or
references to different numbers, which you want to find the
sum of.
There can be 1 to 255 Numbers in any one Sum function.
SUM(PartPrice1TextBoxReturn,PartPrice2
TextBoxReturn,PartPrice3TextBoxReturn)adds the
return values of the Part Price 1, 2 and 3 Text Boxes together.
Tan
This function calculates the tangent of the provided angle
(specified in radians).
TAN([Angle])
TAN(0.22)calculates the tangent of the provided angle (0.22
radians). The result is 0.223619421518684.
TanD
This function is used to calculate the tangent of an angle,
measured in degrees.
TAND([Angle])
TAND(90)uses the angle of 90 degrees and returns the
tangent of that angle. The result in this case is positive infinity.
124
The Little Book of Rules
TanH
This function is used to calculate the hyperbolic tangent of a
specified hyperbolic angle.
TANH([HyperbolicAngle])
HyperbolicAngle is the hyperbolic angle that you want to
find the hyperbolic tangent of.
TANH(5)returns the hyperbolic tangent of the hyperbolic
angle of 5, giving a result of 0.999909204.
Trunc
This function truncates a specified number to an integer.
TRUNC([Number],[NumberofDigits])
NumberofDigits is the number of decimal places you
require the specified Number to be truncated to.
If the NumberofDigits is set to 0 or left blank, the Trunc
function will return the integer part of the Number.
If the NumberofDigits has a value greater than 0, then the
Trunc function will return the Number rounded to the
specific NumberofDigits.
TRUNC(LengthTextBoxReturn/2,2)will divide the
return value from the Length Text Box by 2 and the result
will be rounded to 2 decimal places.
Example Outcomes of the Trunc Function:
LengthTextBoxReturn/2 Number of Result of the
Value Digits TRUNC
function
17.482976 2 17.48
134.745734 0 134
125
DriveWorks Ltd.
Text Functions
Char
The Char function will return the character equivalent of the
specified number using the computer’s character set.
CHAR([Number])
Number is a number between 1 and 255 that is used to
specify the character you want.
CHAR(NumberComboTextBoxReturn)finds the equivalent
of the return value from the Number Combo Box.
Example Outcomes of the Char Function:
NumberComboBoxReturn Value Result of the
CHAR
function
97 A
70 F
94 ^
51 3
35 #
126
The Little Book of Rules
Concatenate
This function joins together, with no spaces, all of the
specified strings into one string.
CONCATENATE([String1],[String2], [String
n])
String1, String2, String n are text strings, or text string
references, which you want to join together.
There can be 1 to 255 Strings in any one Concatenate
function.
CONCATENATE(TitleTextBoxReturn,First
NameTextBoxReturn,SurnameTextBoxReturn) joins
the return values of the Title Text Box ("Miss"), the First
Name Text Box ("Sally") and the Surname Text Box
("Newark") together into one string: "Miss Sally Newark".
Dollar
This function converts a value to a text string and applies the
default currency formatting.
DOLLAR([Value],[DecimalPlace])
DecimalPlace denotes the number of decimal places
required in the resulting text string.
If more decimal places are required than are present in the
Value string, then the rest of the decimal places are made up
of zeros.
If less decimal places are required, then the Value is rounded
off to the nearest decimal unit to match the number of
decimal places specified.
DOLLAR(123456,2)will take the Value of 123456 and
convert it into a string with the default currency formatting
applied and round to two decimal places. This would result in
£123,456.00 in the UK.
127
DriveWorks Ltd.
Exact
The Exact function checks to see if two values are identical.
EXACT([Comparand1],[Comparand2])
Comparand1 and Comparand2 are strings, or references to
strings, that are to be compared.
If Comparand1 and Comparand2 are exactly the same,
TRUE is returned.
If Comparand1 and Comparand2 are not exactly the same,
FALSE is returned.
EXACT(CustomerNameTextBoxReturn,
CustomerComboBoxReturn)will compare the return value
of the Customer Name Text Box to the return value from the
Customer Combo Box. If the two values are an exact match,
then the function will return TRUE, otherwise it will return
FALSE.
Example Outcomes of the Exact Function:
128
The Little Book of Rules
129
DriveWorks Ltd.
Fixed
This function formats a number as text with a fixed number
of decimal places.
FIXED([Number],[DecimalPlaces],
[NoCommas])
This function rounds the value of the Number to the
number of decimal places defined by DecimalPlaces and
applies the comma format defined by the NoCommas value.
If NoCommas contains any value other than zero or is left
blank, then commas will be removed from the returned value.
FIXED(1124.03,1,1)will round the number ‘1124.03’ to
the defined number of decimal places and then remove all
commas to give the result 1124.0.
FIXED(11940.732,2,0)will round the number
‘11940.732’ to 2 decimal places and will leave the comma in
to give the result of 11,940.73.
Left
The Left function returns the specified number of characters,
starting from the first character in the text.
LEFT([Text],[NumberofCharacters])
NumberofCharacters is the amount of characters you want
to retrieve, starting from the start of Text.
If the specified NumberofCharacters is greater than the
total number of characters in the specified Text, then the
Left function will return the whole text string.
LEFT(ProductNameComboBoxReturn,5)will retrieve the
first 5 characters from the return value of the Product Name
Combo Box, resulting in "Windo" if the Combo Box option
selected was ‘Window’.
130
The Little Book of Rules
Len
The Len function returns the number of characters in the
specified text.
LEN([Text])
LEN(CustomerNameTextBoxReturn)will count each
character in the return value of the Customer Name Text Box
i.e. a return value of "Sandra", would return 6 as the result.
N.B. Any spaces in the specified Text are also counted as a character.
Lower
The Lower function converts the string of characters within a
text string to lowercase.
LOWER([Text])
LOWER("This is SOME TexT")will convert the text
string to lowercase, so it will result in "this is some text".
Mid
The Mid function returns a specified number of characters
from the chosen starting position.
MID([Text],[StartNumber],[Numberof
Characters])
StartNumber is the position of the first character you want
to retrieve.
NumberofCharacters is the amount of characters you want
to retrieve from the specified starting position.
MID(ProductCodeTextBoxReturn,1,3)will retrieve
three characters from the Product Code Text Box return
value, starting from the first character, so if the Product Code
Text Box return value is P7100GH, the result would be P71.
131
DriveWorks Ltd.
NewLine
This function allows for a new line to be inserted into a text
string.
NEWLINE()
"Hello" & NEWLINE() & "World" returns:
Hello
World
Proper
This function capitalizes all characters that follow a non-letter
character within a specified text string.
PROPER([Text])
PROPER("hello. my name is joe")capitalizes all
characters following a non-letter character. The resulting text
string is "Hello. My Name Is Joe".
Replace
This function replaces characters within text.
REPLACE([Original Text],
[StartPosition],[NumberofCharacters],
[ReplacementText])
REPLACE(CustomerNameTextBoxReturn,6,5,
NewSurnameTextBoxReturn)replaces five characters
(defined by NumberofCharacters), starting at the sixth
character (StartPosition) in the Customer Name Text Box
return text string (OriginalText) with the return value from
the New Surname Text Box (Replacement Text).
132
The Little Book of Rules
Rept
This function repeats the specific text n number of times.
REPT([Text],[NumberofTimes])
REPT("F",6)repeats the string "F" (Text) six times
(NumberofTimes), returning FFFFFF as the result.
Right
This function returns the specific number of characters
starting from the last character in the text.
RIGHT([Text],[NumberofCharacters])
If the specified NumberofCharacters is greater than the
total number of characters in the specified Text, the Right
function will return the whole text string when calculated.
RIGHT(ProductNameComboBoxReturn,5)will retrieve
the last five characters from the return value of the Product
Name Combo Box. So if the return value was "Window",
‘indow’ would be the result.
133
DriveWorks Ltd.
String
This function converts a value into a text representation using
standard US English formatting.
STRING([Value])
STRING(DWVariableNumber)converts the result of
DWVariableNumber from a number into text i.e. if
DWVariableNumber equals 2, the result will be two.
134
The Little Book of Rules
StringLocal
This function converts a value into a text representation using
standard current culture formatting.
STRINGLOCAL([Value])
STRINGLOCAL(DWVariableNumber)converts the result of
DWVariableNumber from a number into text i.e.
DWVariableNumber = 2.2, result = "2.2" in the US or "2,2"
in Germany.
Substitute
This function searches through a main string value for a
specified string, and replaces the numbered instance of that
found value with the replacement text specified.
SUBSTITUTE([TextToSearch],[Original
Text],[ReplacementText],[Instance
Number])
If the InstanceNumber is left blank, then the function will
replace the first instance of OriginalText by default with the
ReplacementText. If no occurrence of the OriginalText is
found within the TextToSearch, or if there are less instances
than the InstanceNumber specified, then the
TextToSearch will remain unchanged.
SUBSTITUTE("My name is Joe","Joe","Fred",1)
will search the string "My name is Joe" and find the first
instance (defined by Instance Number) of the value "Joe"
and replace it with the string "Fred", resulting in "My name is
Fred".
135
DriveWorks Ltd.
Text
The Text function converts a value to text and displays the
value using the specified format.
TEXT([Value],[Format])
TEXT(NumberTextBoxReturn,"$0.00")converts the
return value from the Number Text Box into text and applies
the currency formatting "$0.00" (Format) to the value. If the
Number Text Box return was 234.8343, the result of this rule
would be $234.83.
TextFormat
This function formats one or more values according to the
given formatting string using .NET framework 4 standard
format strings.
TEXTFORMAT([FormatString],[Values])
Trim
This function removes all whitespace characters between
other characters that are not single space characters. It also
removes all white space characters present at the beginning
and end of a string.
TRIM([Text])
TRIM(" Hello, my na
me is Joe ")will remove all whitespace at the beginning
and end of the string. It also removes the tabbed character
between the words "my" and "name" and it removes the
newline character present in the middle of the word "name".
The result is "Hello, my name is Joe".
136
The Little Book of Rules
Upper
This function converts the string of text to uppercase.
UPPER([Text])
UPPER("This is SOME TeXt")will convert all characters
in the text string to uppercase, returning the result "THIS IS
SOME TEXT".
Value
This function converts a value into a number representation
using standard US English formatting.
VALUE([Value])
VALUE(DWVariableNumber)converts the result of
DWVariableNumber (e.g. "2.2") from text to a number (2.2).
ValueLocal
This function converts a value into a number representation
using current culture formatting.
VALUELOCAL([Value])
VALUE(DWVariableNumber)converts the result of
DWVariableNumber (e.g. "2,2" in Germany, or "2.2" in the
US) from text to a number (2.2).
137
DriveWorks Ltd.
Table Functions
To provide an example of how Table Functions can be used,
the Sample Data below will be used throughout this section:
Sample Data – People Data:
Member ID Name Age Gender
42 Dave Sharp 25 Male
44 Joe Bloggs 37 Male
96 Sandra 42 Female
Shield
107 Thomas 21 Male
Knight
251 Isabelle 56 Female
Jones
CountIf
The CountIf function counts the number of cells within a
range that meet the given condition.
COUNTIF([Table],[ConditionExpression])
COUNTIF(PeopleTable,"=Male")will count the number
of cells in the People Table that equal Male and return 3.
COUNTIF(PeopleTable,"<50")will return 6 (two cells
from the ID column and four cells from the Age column).
138
The Little Book of Rules
DCount
This function counts all the cells in the given table’s specified
column that comply with the specified condition.
DCOUNT([Table],[Column], [Condition])
DCOUNT(PeopleTable,4,"=Male")counts the number of
cells in the fourth column (Column) of the People Table
(Table) that equal Male (Condition). The result is 3.
DMax
This function returns the largest value in the given table’s
specified column which complies with the specified
condition.
DMAX([Table],[ColumnIndex],[Condition])
DMAX(PeopleData,1,">100")will look in the People
Data table (Table) in column 1 (ColumnIndex) and return
the largest value that is less than 100 (Condition), resulting in
the value 96.
DMin
This function returns the smallest value in the given table’s
specified column which complies with the specified
condition.
DMIN([Table],[ColumnIndex], [Condition])
DMIN(PeopleData,1,">100")will look in the People
Data table in column 1 and return the smallest value that is
greater than 100, which is 107.
139
DriveWorks Ltd.
DWVLookup
This function searches a table for a specific value in a
specified column and returns a value from the same row.
DWVLOOKUP([Lookup],[In],
[LookupColumn],[ReturnColumn],
[MatchType])
DWVLOOKUP(AgeComboBoxReturn,PeopleData,3,2,
FALSE)will look in the third column (LookUpColumn) of
the People Data table (In) for an exact match (denoted by
FALSE as the MatchType) to the Age Combo Box return
value of 42, denoted by LookUp. If a match is found, the
function will then look to the second column (implied by
ReturnColumn) and return the value in the same row as the
match found, which is Sandra Shield.
If there were no matches to 42 in the Age Column, then no
result will be returned.
MatchType can be ‘FALSE’ (where an exact match to the
LookUp must be found), or ‘Nearest’ (where the nearest
match to the LookUp must be found).
GetTableValue
This function returns a value from a table from specified
column and row indexes.
GETTABLEVALUE([TableName],
[RowIndex],[ColumnIndex])
GETTABLEVALUE(PeopleData,2,4)returns the value in
row 2, column 4 of the People Data table, which is Male.
140
The Little Book of Rules
ListAll
The ListAll function retrieves all data cells from the specified
column within the selected table and returns a list.
LISTALL([Table],[Column])
LISTALL(PeopleData,3)will look in the People Data
table and retrieve all data from the third column. The list
returned for this specific function will be: 25|37|42|21|56
ListAllConditional
This function lists all values from a table’s column, where
specified conditions are met for each row within that
specified column.
LISTALLCONDITIONAL([Table],[Column],
[ConditionalColumn1],[Condition1])
LISTALLCONDITIONAL(PeopleData,2,3,"<56")will
look in the People Data table and retrieve all the data in the
second column where the values in the third column are less
than 56. This would return the list Dave Sharp|Joe
Bloggs|Sandra Shield|Thomas Knight.
ListAllConditionalDistinct
This function lists distinct values from a table where specified
conditions are met for each row within the specified column.
This is identical to the ListAllConditional function (see above
for syntax) except that any values that are repeated within the
search will only be shown once within the resulting list.
LISTALLCONDITIONALDISTINCT(PeopleData,4,3,
"<56")will look in the People Data table and retrieve all the
data in the fourth column where the values in the third
column are less than 56. This would return the list
Male|Female.
141
DriveWorks Ltd.
ListAllDistinct
This function lists distinct values from a table’s specified
column.
LISTALLDISTINCT([Table],[Column])
LISTALLDISTINCT(PeopleData,4)will look in the
People Data table and retrieve all the data in the fourth
column. Any repeated values will only be shown once, so the
resulting list would be: Male|Female.
ListCountItems
This function counts the number of items in a specified list.
LISTCOUNTITEMS([List])
LISTCOUNTITEMS("A|B|C|D|E|F")returns the result of 6
as there are 6 items in the List. The Variable name for a list
(i.e. DWVariableListItems) would also return 6 if the result of
the Variable was A|B|C|D|E|F.
ListFindItems
This function finds the index of a specified item in a given
list.
LISTFINDITEMS([List],[Item])
LISTFINDITEMS(DWVariableListItems,"D")searches
the DWVariableList of A|B|C|D|E|F for D and return the
result of 4, as D is the fourth character.
142
ListGetItems
This function returns the specified item from a list of items.
LISTGETITEMS([List],[ItemIndex])
LISTGETITEMS(DWVariableList,2)returns the second
item (indicated by ItemIndex value) of the DWVariableList
of A|B|C|D|E|F, which is B.
ListJoin
This function combines two or more values or lists together
into a single list.
LISTJOIN([List/Value1],[ListValue2])
LISTJOIN("A|B|C","D|E|F")returns the result of
A|B|C|D|E|F.
TableGetColumnCount
This function returns the number of columns in the given
table.
TABLEGETCOLUMNCOUNT([TableName])
TABLEGETCOLUMNCOUNT(PeopleData)will return the
number of columns in the People Data table, which is 4.
TableGetRowCount
This function returns the number of rows in the given table.
TABLEGETROWCOUNT([TableName])
TABLEGETROWCOUNT(PeopleData)would return the
number of rows in the People Data table, which is 6.
www.driveworks.co.uk
DriveWorks Ltd.
VLookup
This function searches the first column in the selected table
for a match and moves across the row to return the value of a
cell.
VLOOKUP([Lookup],[In],[Column],
[MatchType])
VLOOKUP(MemberIDComboBoxReturn,PeopleData,2,F
ALSE)will look in the People Data table in the first column
of the table for the value returned from the Member ID
Combo Box (i.e. 251). If a match is found, the function then
looks across to the second column and returns the value in
the same row as the match found, which in this case is Isabelle
Jones.
MatchType can be ‘FALSE’ (where an exact match to the
LookUp must be found) or ‘Nearest’ (where the nearest
match to the LookUp must be found).
144
The Little Book of Rules
Validation Functions
IsError
This function indicates whether the specified value is an error
by returning TRUE or FALSE.
ISERROR([Value])
ISERROR(TotalReturn)will check the return value of
TotalReturn, which in this example is #NAME?, to
determine if it is an error. In this case, the IsError function
will return TRUE as #NAME? is an error.
IsMatch
This function indicates whether the pattern specified finds a
match in the specified input string.
ISMATCH([Input],[Pattern])
ISMATCH("0000000000000001","0*[1-9] [0-
9]*")uses the pattern "0*[1-9][0-9]*" to search for a match
within the Input string "0000000000000001". This function
returns TRUE in this instance as the Input text string
matches the Pattern specified.
IsNonText
This function indicates whether the specified value is not text
by returning TRUE or FALSE.
ISNONTEXT([Value])
ISNONTEXT(InformationReturn)checks the return value
of Information and if it isn’t text (i.e. 29), the IsNonText
result will return TRUE. If the return value is "29", the
outcome of the function will return FALSE.
145
DriveWorks Ltd.
IsNumber
This function indicates whether the specified value is a
number by returning TRUE or FALSE.
ISNUMBER([Value])
ISNUMBER(InformationReturn)checks the return value
of Information and if it is a number (i.e. 29), the IsNumber
function will return TRUE. If it is not a number (i.e.
"Engine" or "29"), the function will return FALSE.
IsText
This function indicates whether the specified value is text by
returning TRUE or FALSE.
ISTEXT([Value])
ISTEXT(InformationReturn)checks the return value of
Information and if it is text (i.e. "29"), the IsText function
will return TRUE. If it is not text (i.e. 29), the function will
return FALSE.
IsValidDirectory
This function checks the specified directory and ensures it is
of a valid structure and syntax.
ISVALIDDIRECTORY([Directory])
ISVALIDDIRECTORY("\hello\world\directory")
validates the Directory "\hello\world\directory" and returns
TRUE as it is structurally and syntactically valid.
An invalid Directory such as "\hello\world\file.txt", will
return a FALSE result.
146
The Little Book of Rules
IsValidEmailAddress
This function checks that the specified e-mail address is
structurally and syntactically valid.
ISVALIDEMAILADDRESS([EmailAddress])
ISVALIDEMAILADDRESS("someone@email.com")would
validate the EmailAddress "someone@email.com" and
return TRUE as it is structurally and syntactically valid.
".someone@email.com" or "hello" will return FALSE
results.
IsValidFileName
This function checks the specified file name and ensures it is
of a valid structure and syntax.
ISVALIDFILENAME([FileName])
ISVALIDFILENAME("helloworld.txt")validates the
FileName "helloworld.txt" and returns TRUE as it is
structurally and syntactically valid.
"hello:world.txt" will return a FALSE result.
IsValidFileNameResult
This function checks the specified file name and validates it
based on the fact it can have a '*' character at the beginning
and / or end of the file name, or none at all.
ISVALIDFILENAMERESULT([FileName])
ISVALIDFILENAMERESULT("helloworld.txt")
validates the FileName "helloworld.txt" and returns TRUE
as it is structurally and syntactically valid.
"file*txt" will return a FALSE result.
147
DriveWorks Ltd.
IsValidPath
This function checks the specified path and ensures it is of a
valid structure and syntax.
ISVALIDPATH([Path])
ISVALIDPATH("\hello\world\directory\file.txt"
)validates the Path "\hello\world\directory\file.txt" and
returns TRUE as it is structurally and syntactically valid.
"\hello\world\" will return a FALSE result.
IsValidRelativePathResult
This function checks that the specified path is structurally and
syntactically valid and contains no file information.
ISVALIDRELATIVEPATHRESULT([Path])
ISVALIDRELATIVEPATHRESULT("\hello\world\")
validates the Path "\hello\world\" and returns TRUE as it is
structurally and syntactically valid.
"\hello\world\*.txt" will return a FALSE result.
148
The Little Book of Rules
FsGetDirectoryName
This function returns the parent directory path from a given
file path.
FSGETDIRECTORYNAME([Path])
FSGETDIRECTORYNAME("C:\DriveWorks8\Parent
Directory\Child Directory") will return the path:
C:\DriveWorks8\Parent Directory.
FsPathCombine
This function combines 2 file paths.
FSPATHCOMBINE([FirstPath], [SecondPath])
FSPATHCOMBINE("C:\DriveWorks 8\New
Functions","Child Folder")will return the value:
C:\DriveWorks 8\New Functions\Child Folder.
149
DriveWorks Ltd.
Appendix
NetWorkDaysCustom function WeekendValues:
The Weekend Value column of the chart below are
referenced in the NetworkDaysCustom function (see page 93
for more information)
Weekend Value Weekend Days
1 or Omitted Saturday, Sunday
2 Sunday, Monday
3 Monday, Tuesday
4 Tuesday, Wednesday
5 Wednesday, Thursday
6 Thursday, Friday
7 Friday, Saturday
11 Sunday only
12 Monday only
13 Tuesday only
14 Wednesday only
15 Thursday only
16 Friday only
17 Saturday only
150
The Little Book of Rules
151
DriveWorks Ltd.
152
The Little Book of Rules
153
DriveWorks Ltd.
Index
Abs ...............................106 CountIf........................ 138
ACos ............................106 Date ............................... 89
ACosD .........................106 DateTime ...................... 89
ACosH .........................107 DateTimeLocal ............ 89
And...............................101 DateValue ..................... 90
ASin ..............................107 Day ................................ 90
ASinD ..........................107 DCount ....................... 139
ASinH ..........................108 Degrees ....................... 112
ATan ............................108 DimensionText ............ 98
ATan2 ..........................108 DimensionTextAll ....... 99
ATanD .........................109 DMax .......................... 139
ATanH .........................109 DMin ........................... 139
Boolean ........................102 Dollar .......................... 127
Ceiling ..........................109 DWVLookup ............. 140
Char ..............................126 Even ............................ 112
Choose .........................110 Exact............................ 128
ChooseFrom ...............105 Exp .............................. 112
Color .............................. 98 Fact .............................. 113
Concatenate ................127 FactDouble ................. 113
Cos ...............................111 Find ............................. 129
CosD ............................111 Fixed ............................ 130
CosH ............................111 Floor ............................ 114
154
The Little Book of Rules
155
DriveWorks Ltd.
156