You are on page 1of 156

The Little

Book of Rules
DriveWorksXpress and DriveWorks Solo Edition

www.driveworks.co.uk
DriveWorks Ltd.

The Little Book of Rules (DriveWorksXpress and


DriveWorks Solo Edition)

Copyright © 2011 DriveWorks Ltd.

www.driveworks.co.uk

All rights reserved. No part of this book may be reproduced


or transmitted in any form or by any means without written
permission of the author.

2
The Little Book of Rules

About this Book

This book has been written as a pocket guide to accompany


DriveWorksXpress and DriveWorks Solo Design
Automation software products, developed by DriveWorks
Ltd.

Throughout this book we have used this symbol to


identify information that is relevant exclusively to
DriveWorks Solo.
DriveWorksXpress has been incorporated as core
functionality into every license of SolidWorks. ‘How to’
Video clips, Tutorials and Sample Projects are available for
you at www.driveworksxpress.com

DriveWorks Solo is available to purchase worldwide through


the SolidWorks/DriveWorks Value Added Reseller Channel.
A FREE 30 day license is available to allow you to TRY
DriveWorks Solo.

Simply register online at www.driveworkssolo.com, request


the 30 day license and download the software. ‘How to’
Video Clips, Training Tutorials and Sample Projects are all
also available on the web at www.driveworkssolo.com

3
Table of Contents
THE LITTLE BOOK OF RULES ................................... 1 

ABOUT THIS BOOK ................................................ 3 

WHAT IS A RULE? .................................................. 9 

WHY ARE RULES GOOD? ......................................10 

TYPICAL RULES.....................................................11 

WHAT’S IN A RULE? .............................................12 


DATA TYPES ............................................................ 13
WHAT CAN GO IN A RULE? ......................................... 14
Operators ......................................................... 14
Functions.......................................................... 15
Literals ............................................................. 16
Names .............................................................. 16
Other Rules ...................................................... 17
MAKING DECISIONS .................................................. 18
IF ...................................................................... 18
Conditions ........................................................ 19
Comparison Operators ..................................... 19
Values .............................................................. 20
Lookup ............................................................. 21
CONCATENATE OR JOIN TEXT, VALUES AND FUNCTIONS .... 23
SPEECH MARKS........................................................ 23
PARENTHESES .......................................................... 24
www.driveworks.co.uk
DriveWorks Ltd.

ADVANCED RULES ............................................... 25


NESTED IF STATEMENT .............................................. 25
NESTING AND COMBINING OTHER FUNCTIONS ................ 28
TYPES OF RULE .................................................... 31
INPUT CONTROL LIST RULES ....................................... 32
FILE NAME RULES..................................................... 32
Unique naming ................................................ 32
Intelligent naming ............................................ 34
Remove Master File Name ............................... 35
Move Master File Name to the End ................. 35
Deleting or suppressing components ............... 36
Replacing components ..................................... 37
Replacing driven components .......................... 38
RELATIVE PATH RULES ............................................... 39
Relative ............................................................ 39
Absolute ........................................................... 40
CONFIGURATION RULES ............................................. 41
Delete unused configurations .......................... 41
DIMENSION RULES ................................................... 42
Linear Dimensions ............................................ 42
Angles .............................................................. 43
Patterns ........................................................... 43
Tolerances ........................................................ 45
FEATURE RULES ....................................................... 47
ADVANCED FEATURE RULES ....................................... 48
Advanced Base Extrude and Base Extrude Thin
Parameters ...................................................... 48
Advanced Boss Extrude Parameters ................ 51
Advanced Boss Extrude Thin Parameters......... 53
Advanced Cut Extrude parameters .................. 56

6
The Little Book of Rules

Advanced Cut Extrude Thin parameters .......... 59


Advanced Chamfer parameters ....................... 62
Advanced Fillet parameters ............................. 64
Advanced Text parameters .............................. 66
CUSTOM PROPERTY RULES ......................................... 67
Driving the Color .............................................. 67
Driving the Material......................................... 69
Driving the Texture .......................................... 70
INSTANCE RULES ...................................................... 71
DRAWING RULES ...................................................... 73
File Name Rule ................................................. 73
Relative Path Rule ............................................ 74
Layer State Rule ............................................... 75
Sheet State ....................................................... 75
Sheet Scale Numerator and Denominator Rules
......................................................................... 76
View State Rules .............................................. 77
View Scale Numerator and Denominator Rules78
View Left and Top (Position) Rules................... 79
Breakline Rules................................................. 80
Drawing Custom Property Rules ...................... 81
Annotation Rules ............................................. 81
Dimension Text Rules ....................................... 82
Surface Finish Symbol Rules ............................. 83
Surface Finish Value Rules ............................... 85
Combining Surface Finish Symbol and Value
Rules ................................................................ 87
COMMON FUNCTIONS .........................................88
DATE AND TIME FUNCTIONS ....................................... 89
HELPER FUNCTIONS .................................................. 98

7
DriveWorks Ltd.

LOGIC FUNCTIONS .................................................. 101


MATH FUNCTIONS.................................................. 106
TEXT FUNCTIONS .................................................... 126
TABLE FUNCTIONS .................................................. 138
VALIDATION FUNCTIONS .......................................... 145
FILE SYSTEM FUNCTIONS.......................................... 149
APPENDIX ......................................................... 150
NetWorkDaysCustom function WeekendValues:
....................................................................... 150
WeekDay function ReturnType values: .......... 151
WeekNum function ReturnType values:......... 152
WorkDayCustom function Weekend values:.. 153
INDEX................................................................ 154

8
What is a Rule?
The dictionary explanation of a rule is:
rule (noun) [rool]

1. A principle or regulation governing conduct


The rules of chess

2. The customary or normal circumstance


The rule rather than the exception

3. A prescribed mathematical method for performing


a calculation or solving a problem
If x is > y, add 200

When used as a verb, to rule implies exercising controlling


authority over somebody or something.
In this book, we will be discussing rules in the sense of a
mathematical method for solving a problem. This type of rule
works best when it can be defined in words:
 We use a support if the length of the
gantry is greater than 2 metres

 We always have a ¼ inch gap around


the door frame, unless the frame is
over 4 feet wide, in which case the
gap is increased to 5/16th of an inch

 Customers in the USA are invoiced in


US dollars; customers in Europe are
invoiced in Euros.

www.driveworks.co.uk
DriveWorks Ltd.

Why are Rules good?


Rules are a great way of defining the solution to a given
problem. Rules allow your knowledge to be captured and
transferred in a simple way to others.
Rules can also be a great way of telling a computer how to
work something out. This allows computers to perform
mundane tasks that humans undertake day in and day out,
allowing us to concentrate on more interesting and important
responsibilities.
If you can put some of your knowledge and intelligence (or
rules) into a computer, you can then use that rule to make
relevant decisions and actions.
Rules can work out many things, and be applied in many
different scenarios.
Rules can be based on:
 A mathematical formula
 A conditional or logical statement
 The stringing together of lots of text
 A lookup in a table on a value you have entered
If you create enough of these rules, then you can automate
some of your daily tasks. This is the idea behind DriveWorks.
This book aims to help you to understand rules and how they
®
can be used in DriveWorks to automate your SolidWorks
designs.

10
The Little Book of Rules

Typical Rules
Below are some typical rules:

A typical mathematical formula would be:


(34 + 98) x 5

A logical rule may look something like this:


IF(SafeWorkingLoad="500 Kg",200,250)

Stringing text together (also called Concatenation) might look


something like this:
OpeningWidth & "wide x" & SafeWorkingLoad &
"safe working load"

And a lookup on some data might look like this:


VLookup(Customer,CustomerTable,3,False)

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.

What can go in a Rule?


A rule can be made up of:
 Operators
 Functions
 Literals (e.g. a Number or Text value)
 Names (Which refer to values entered or calculated
elsewhere)
 Other Rules

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".

1 On English language installations, the default system separator is the comma.


Other languages may use the semi-colon (;) as the system separator.

15
DriveWorks Ltd.

There is a comprehensive list of functions, what arguments


they expect, and what they return in the ‘Common Functions’
section of this book.

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.

2 Variables are available in DriveWorks Solo only.

16
The Little Book of Rules

You’ve already seen names used in various examples, for


example:
IF(SafeWorkingLoad="500 Kg",200,250)
In this example, SafeWorkingLoad is a name which refers
to the selected value in an input control which shows a list of
values.
Similar to the way the type of a function’s return value
depends on the function, the type of a name depends on the
value to which it refers.
In DriveWorks, names can be used in place of numbers, text,
and Booleans, for example:
OpeningHeight – 345
where OpeningHeight is a name which refers to the result
of a textbox. Keep in mind that if you have not entered or
calculated a value for the OpeningHeight then it will
actually be seen as an empty text string, and so cannot have
345 taken away from it.
Input controls in DriveWorks Solo provide many properties
(for example Min, Max and Visibility) in addition to the input
value. So to get the input value from the control, the term
Return is added to the end of the control name, e.g.
MyTextBoxReturn.
DriveWorksXpress only provides the value coming from the
input control, so all input controls are referred to by the name
applied when they were created, e.g. MyTextBox.

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.

In this example, OpeningHeight – 34 is effectively a rule


on its own, and the result is used as the first argument of the
ROUNDUP function.
In the next section, we’ll see another example which chains
together IF functions to make decisions.

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)

IF initiates the function.


Separators divide the condition and the values.
Using the IF Wizard in DriveWorks allows you to
concentrate on building the condition and the values; the
wizard takes care of adding the initiating IF, the opening and
closing parentheses and the separators.

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:

Comparison Operator Example


= equal to SafeWorkingLoad = "500 Kg"
> greater than Length > 100
< less than Width < 1000
>= greater than or equal to Length >= 3000
<= less than or equal to Width <= 1000
<> not equal to Width <> 1000

19
DriveWorks Ltd.

Values that can be included in a comparison can be Numeric,


Boolean or Text.

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))))))

As you can see, this is getting a little difficult to read.

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.

This table has multiple purposes. It will allow us to use the


LISTALL2 function to present the SWL column into a list
control for selection by the user. It also contains all the other
data that the SWL selection affects.
So we can now use the VLOOKUP function to select the
required I-section beam depth, as below:
VLOOKUP(SWLReturn,DWLookupBeamData,2,FALSE)
What this function is actually saying is; look for the SWL
selected by our user (SWLReturn) in the table brought into
DriveWorks (DWLookupBeamData) and when an exact
match is found (FALSE) return the value from the
corresponding Depth column (2).
The ‘V’ in VLookup means vertical, so the search takes place
vertically, i.e. down the left most column.
VLookup is limited by the way your table of data is
constructed in that the values to be searched for must be in
the first column.
DriveWorks Solo provides a built in function to overcome
this limitation - DWVLOOKUP, where the search value can
exist in any column, and the value returned can be any other
column to the left or right of this. DWVLOOKUP is
discussed in a later section of this book.

22
The Little Book of Rules

Concatenate or Join text, values and


functions
Two options are available when strings of text, values or
formulae need to be joined.
First of all the function ‘Concatenate’ can be used. This looks
like this:
Concatenate(Length,"long")
Secondly using the ampersand symbol (&) will achieve the
same result. This looks like this:
Length & "long"
Which one you use depends on your preference.

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)

IF initiates the function. Separators divide the condition and


the values. The condition and values are encased within open
and close parenthesis.
Nesting IF requires the basic structure to be maintained while
embedding an identically structured argument. This means
the original parenthesis and separators need to remain. The
embedded argument will replace either the ‘value when true’
or the ‘value when false’ portions of the original statement.
The example below shows Nesting IF statements to four
levels deep:
IF(WindowType="None","Suppress",
IF(WindowType="Round","Suppress" ,
IF(WindowType="Crescent","Suppress",
IF(WindowType="Square","Unsuppress" ,
"Suppress") ) ) )

25
DriveWorks Ltd.

Here we can see the original IF statement (normal font), with


the ‘value when false’ being replaced with a second IF
statement (bold font), and the ‘value when false’ of that level
being replaced with a third IF statement (italic font).This goes
even deeper with a fourth IF statement (bold and italic font)
replacing the ‘value when false’ portion of the third IF
statement (second largest font).
How the nested IF is evaluated is shown in the diagram
below:

26
The Little Book of Rules

To give this example further explanation, WindowType is an


input control from which the values None, Round,
Crescent, Square and Triangular can be selected.
This rule is built for a captured feature that represents the
Square selection. Starting from the left of the nested IF
statement, the first condition is evaluated, if the user had
selected None from the WindowType control, the feature
would be suppressed. If None had not been selected the next
condition would come into play.
The next condition (does WindowType equal Round?) gets
evaluated in the same way, with the same outcome. This
pattern goes on until a valid outcome is obtained.
You will note that Triangular could have been selected
from the WindowType control, and that no condition exists
in the nested IF statement to take this into consideration.
This is because the outcome when the last condition is false
allows for the Triangular selection.
When nesting IF statements it is important to ensure any
conditions take into account the flow of the evaluation.
For instance, if nested conditions used the less than (<)
comparison operator, it is important to position the smallest
possible value at the start of the nested IF statement, as
below:
IF(MyValue<10,"less than 10", IF(MyValue
<20,"Between 10 and 20", IF(MyValue
<30,"Between 20 and 30","Over 30")))

When MyValue equals 14 the above statement would equate


to "Between 10 and 20". This is because the first
condition is False, so the second condition is evaluated which
returns the True value.

27
DriveWorks Ltd.

If this was constructed with the largest value first as below:


IF(MyValue<30,"less than 30", IF(MyValue
<20,"Between 10 and 20", IF(MyValue <10,"Less
than 10","Over 30")))

When MyValue equals 14 the above rule would equate to


"Less than 30", which of course is correct but we may
have expected the result "Between 10 and 20". This is
because the first condition to be evaluated is True and the
value when this is true is a definite result (not another IF
function).
One final point to note on nesting IF functions is that the
nested IF is not required to be placed at the false position in
the outer IF function. The nested IF could also be used in the
true position in the outer IF function, or, both positions.
Nesting the IF statement can become involved, and although
DriveWorks Solo provides some excellent diagnostic tools to
drill into every level of a nested IF you may want to consider
one of the Lookup functions as an alternative

Nesting and combining other


functions
It’s not just IF statements that can be nested. Any function
that requires arguments in order for it to calculate can have
another function nested in place of the argument.
Nesting is used when a further function needs applying to the
result of an initial function.
Consider this:
ROUNDUP (MAX (Width,Height,Depth)*1000,4)

Initially the MAX value of 3 inputs is required to be known


and multiplied by 1000, so the formula used would be:
MAX(Width, Height, Depth)*1000

28
The Little Book of Rules

Next the result of the MAX function is required to be


rounded up to 4 decimal places so the function:
ROUNDUP(number,4)
is used.
So now we can nest the first function in place of the number
argument in the second function, like so:
ROUNDUP(MAX (Width, Height, Depth)*1000, 4)

Also, nesting the OR function within an IF statement can


simplify a potentially complex statement. If any of the
conditions are true the OR function returns true, otherwise it
will return false. For example:
OR
(WindowType="None",WindowType="Round",WindowT
ype="Crescent")

If the user selects either None, Round or Crescent from the


WindowType selection the OR function will return true. So
to nest this into an IF function, we replace the condition
portion of the IF, so:
IF(condition,"Suppress","Unsuppress")

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.

Combining functions is used when the result of one function


needs applying to the result of another function.
Consider this
LEFT(CompanyReturn,3) & ROUND(LengthReturn,0)
& VLOOKUP(BracketType,BracketCodes,2,FALSE)

This formula is used to create a unique part number for a


bracket that is produced by DriveWorks. Here we are
calculating the first 3 letters of the entered company name:
LEFT(CompanyReturn,3)

And then combining the calculated size which is rounded to


zero decimal places:
& ROUND(LengthReturn,0)

And then appending a code selected from a table of codes:


& VLOOKUP(BracketType, BracketCodes,2,FALSE)

So we end up with DRI 238 CX03 (spaces are shown to


separate the results of the 3 combined functions).

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.

Input Control List Rules


The Items property of an input control of a ComboBox, or
other list controls determines the items shown in the list. This
property is always driven by a rule, so we need a way to create
a list of values in a rule.
The pipe bar (|) is a special character used by DriveWorks to
separate lists of data. For example:
"One | Two | Three"
And using the ampersand can help you to combine values
from other inputs or variables into a single list:
FirstInput & "|" & SecondInput & "|" &
ThirdInput

File Name Rules


The file name parameter is used to determine the name of the
driven model, or, in the case of a subassembly or part, to
delete it or control its suppression state or visibility in the
parent assembly.

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

OrderNumberReturn Will append the value entered in


the OrderNumber input to the
master file name for
automatically created file.

"*" & OrderNumberReturn Creates a model with its file


name set to the value entered in
the OrderNumber input.

"*" & OrderNumberReturn Creates a model with its file


& "*" name set to its original name,
prefixed with the value entered
in the OrderNumber input.

Tip: If using DriveWorks Solo you can ensure data entered in


the input field is valid for a file name by using the
IsValidFileNameResult function on the Error Result
property of the control as below:

Rule Meaning

IF( Will check the value entered in the


IsValidFileNameResult( OrderNumber input for illegal
OrderNumberReturn) characters. If no illegal characters
=FALSE , "Invalid exists (=FALSE) the message
Characters Entered for "Invalid Characters Entered for the
Order Number!","") Order Number" in the task list
during specification.

33
Or make use of the inbuilt auto-number:

Rule Meaning

DWSpecificationId Will append the DriveWorks


Solo auto-number to the master
file name for the automatically
created file.

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

HeightReturn & Will append the result of the input


WidthReturn & controls Height, Width and Length to the
LengthReturn master file name for the automatically
created file. For example, when Height is
55, Width is 33 and Length is 66, the value
553366 will be appended.

www.driveworks.co.uk
TIP: Include text in between numeric input fields to indicate
what the number signifies:

Rule Meaning

HeightReturn & " Will append the result of the input


High x " & controls Height, Width and Length to the
WidthReturn & " master file name for the automatically
Wide x " & created file. Each value will be separated
LengthReturn & " with the corresponding text. For example,
Long" when Height is 55, Width is 33 and Length
is 66, the value 55 High x 33 Wide x 66
Long will be appended.

Remove Master File Name


Making use of the wildcard or asterisk symbol * on a file
name rule will remove the original file name.
Example:

Rule Meaning

"*" & Will use the value entered in the


OrderNumberReturn OrderNumber input as the file name
for automatically created file.

Move Master File Name to the End


Using this at the end of the rule will add the original file name
after the result of the rule:

Rule Meaning

"*" & Will prefix the master file name with


OrderNumberReturn & the value entered in the OrderNumber
"*" input for the automatically created file.

www.driveworks.co.uk
DriveWorks Ltd.

Deleting or suppressing components


Components can be deleted or suppressed in the resulting
assembly, typically by using the IF function in a rule on the
File Name parameter of the component.

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.

If a new version of the component is required the File Name


parameter will need to result in a suitable value to apply to the
file name:

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.

IF( When the input SheetThickness is


SheetThicknessReturn greater than 3 it will replace the file the
> 3 , "M5x20 hex hd rule is applied to with a file named
bolt" , OrderNumber M5x20 hex hd bolt. This must exist in
) the same location as the file being
replaced, otherwise a new file will be
created using the OrderNumber input
value as the file name.

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

"<Replace>Part B" Will replace the model the rule is


applied to with the model created
from the model named Part B

IF( DoorStyleReturn = When the input value of DoorStyle is


"Flat" , not “Flat” or “Glass” the model, the
"<Replace>Cupboard rule is applied to, will be created with
Right Door" , IF( the DWSpecificationID.
DoorStyleReturn =
"Glass" , When the input value of DoorStyle is
"<Replace>Cupboard “Flat” the model will be replaced with
Right Door Framed" , the model Cupboard Right Door.
DWSpecificationID ) )
When the input value of DoorStyle is
“Glass” the model will be replaced
with the model Cupboard Right Door
Framed model

www.driveworks.co.uk
The Little Book of Rules

Relative Path Rules


The relative path parameter determines the folder each new
model will be stored in.
The term Relative refers to a location relative to where the
DriveWorks Solo project is stored.
If the result of the relative path rule does not exist,
DriveWorks will create the folder.

Relative
To place the new model in a sub folder, named Results, of
the location the project is stored:

Rule Meaning

"" Will place the new model in a folder


named ProjectLocation\Results.
Or left blank
ProjectLocation is the location of the
project file (ProjectName.driveproj)

39
DriveWorks Ltd.

To place the new model in a sub folder of the Results folder,


relative to the project location, using a special variable to
name the folder, see the following examples:

Rule Meaning

DWSpecificationID Will place the new model in a folder


named ProjectLocation\Results\1234.

ProjectLocation is the location of the


project file (ProjectName.driveproj).
1234 is the auto-number assigned by
DriveWorks.

OrderNumberReturn Will place the new model in a folder


named according to the value entered in
the OrderNumber input in the location
ProjectLocation\Results\

ProjectLocation is the location of the


project file (ProjectName.driveproj).

Absolute
When the model is not required to be within the Results
folder an absolute path can be used:

Rule Meaning

"\\dataserver\models" Will place the model in the folder


\models on the data server machine

"C:\models\parts" Will place the model in the folder


\models\parts on the C: of the local
machine

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

"Section A" Switches the configuration to Section A.

Delete unused configurations


Using the wildcard or asterisk * symbol in the resulting
configuration rule will delete all other configurations from the
new model and any associated design table if present:

Rule Meaning

"*Section A" Switches the configuration to Section A,


and deletes all unused configurations.

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

12 Will always drive the parameter the rule is


applied to a value of 12

(WidthReturn- Will always drive the parameter the rule is


(2*5)-89)/2 applied to the result of the value of the
equation, factoring in the value coming
from the Width input.

(WidthReturn- Will always drive the parameter the rule is


(2*DWVariableClear applied to the result of the value of the
ance)- equation, factoring in the values coming
DWVariableFrameAl from the Width input and the Clearance
lowance)/2 and FrameAllowance variables.

42
Angles
A captured angular dimension will have a rule applied that
results in a numeric value in degrees:

Rule Meaning

AngleReturn Will always drive the parameter


the rule is applied to the value
coming from the Angle input.

TAND(AngleReturn) Will always drive the parameter


/2 the rule is applied to the Tangent
of the value coming from the
Angle input, divided by 2.

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

LengthReturn - (2 * Will always drive the parameter


DWVariableDistFromEnd the rule is applied to the result of
)/ the equation.
(DWVariableInstances-1)

www.driveworks.co.uk
DriveWorks Ltd.

The captured angle will have a rule applied that results in a


numeric value in degrees.

Rule Meaning

TAND(Angle) / Will always drive the parameter


Adjacent the rule is applied to the Tangent
of the value coming from the
Angle input, divided by 2.

The captured number of instances will have a rule applied


that results in a whole number:

Rule Meaning

ROUNDUP(( LengthReturn- Will always drive the parameter


(2* the rule is applied to the result of
DWVariableDistFromEnd ) ) the equation, factoring in the
/DWVariablePitch , 0 ) values coming from the Length
input and the DistFromEnd and
Pitch variables.

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:

Type of Tolerance Index Number

Basic 1

Bilateral 2

Limit 3

Symmetric 4

MIN 5

MAX 6

Fit 7

Fit with tolerance 8

Fit tolerance only 9

www.driveworks.co.uk
DriveWorks Ltd.

Rule Meaning

25 & "|"& -0.002 Will always drive the parameter


&"|"& 0.001 &"|"& 2 the rule is applied to a nominal
value of 25 with a bi-lateral
tolerance applied with a lower
limit of -0.002 and an upper
limit of 0.001

NominalDiameterReturn Will always drive the parameter


& "|" & the rule is applied to the value
DWVariableLowerLimit coming from the input
* (25.4/1000) & "|" & NominalDiameter with a limit
DWVariableUpperLimit tolerance applied that has the
* (25.4/1000)&"|"& 3 lower and upper limits driven to
the equations defined in the rule.

46
The Little Book of Rules

Feature Rules
Feature rules control the state of a feature, i.e. suppressed,
unsuppressed, or deleted.

Rule Meaning

TRUE Unsuppresses the feature.

You could also use


"Unsuppress" (in quotes), or
"U" (in quotes).

FALSE Suppresses the feature.

You could also use "Suppress"


(in quotes), or "S" (in quotes).

"DELETE" Deletes the feature.

IF(LengthReturn < Suppresses the feature when the


1000 , "Suppress", value in the Length input is less
"Unsuppress") than 1000. Otherwise the feature
will be unsuppressed.

47
DriveWorks Ltd.

Advanced Feature Rules


Most features also have advanced parameters that can be
controlled by DriveWorks Solo only.
The most common types of advanced parameter available are
listed in this section.

Advanced Base Extrude and Base Extrude Thin


Parameters
The following advanced feature parameters are available for
the base extrude feature:
BothDirections

Rule Meaning

TRUE Will extrude the base feature in


direction 1 and direction 2.

FALSE Will extrude the base feature in


direction 1 only.

D1Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

48
D1DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

D1ApplyDraft

Rule Meaning

True Applies draft in direction 1.

False Will not apply draft to direction


1.

D1DraftOutward

Rule Meaning

TRUE Applies outward draft to the


extrusion.

FALSE Applies inward draft to the


extrusion.

D2Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 2 to the value
coming from the Length input.

www.driveworks.co.uk
DriveWorks Ltd.

D2DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 2 to 15
degrees.

D2ApplyDraft

Rule Meaning

TRUE Applies draft in direction 2.

FALSE Will not apply draft to direction


2.

D2DraftOutward

Rule Meaning

TRUE Applies outward draft to the


extrusion.

FALSE Applies inward draft to the


extrusion.

50
The Little Book of Rules

Advanced Boss Extrude Parameters


BothDirections

Rule Meaning

TRUE Will extrude the base feature in


direction 1 and direction 2.

FALSE Will extrude the base feature in


direction 1 only.

D1Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

D1DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

51
DriveWorks Ltd.

D2Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 2 to the value
coming from the Length input.

D2DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 2 to 15
degrees.

52
The Little Book of Rules

Advanced Boss Extrude Thin Parameters


BothDirections

Rule Meaning

TRUE Will extrude the base feature in


direction 1 and direction 2.

FALSE Will extrude the base feature in


direction 1 only.

D1Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

D1DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

53
DriveWorks Ltd.

D1WallThickness

Rule Meaning

IF( MaterialReturn = Sets the Wall thickness for the


"Stainless Steel" , extrusion in direction 1 to the
1.6 , 1.5 ) value calculated by the rule.

D2Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 2 to the value
coming from the Length input.

D2DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 2 to 15
degrees.

D2WallThickness

Rule Meaning

IF( MaterialReturn = Sets the Wall thickness for the


"Stainless Steel" , 1.6 , 1.5 ) extrusion in direction 2 to the
value calculated by the rule.

54
The Little Book of Rules

ThinWallType

Rule Meaning

"OneDirection" Sets the Thin wall type for the


feature to be one direction.

"OneDirectionReverse" Sets the Thin wall type for the


feature to be the reverse one
direction.

"MidPlane" Sets the Thin wall type for the


feature to be mid plane.

"TwoDirection" Sets the Thin wall type for the


feature to be two directions.

55
DriveWorks Ltd.

Advanced Cut Extrude parameters


D1Depth

Rule Meaning

LengthReturn Sets the Depth for the


extrusion in direction 1 to the
value coming from the Length
input.

D1DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

D1ApplyDraft

Rule Meaning

TRUE Will apply draft to the extrusion


in Direction 1.

FALSE Will not apply draft to the


extrusion in Direction 1.

56
The Little Book of Rules

D1DraftOutward

Rule Meaning

TRUE Will apply Draft outwardly in


direction 1.

FALSE Will apply Draft inwardly in


direction 1.

BothDirections

Rule Meaning

TRUE Sets the extrusion in both


directions.

FALSE Sets the extrusion in the D1


direction only.

D2Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 2 to the value
coming from the Length input.

57
DriveWorks Ltd.

D2DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

D2ApplyDraft

Rule Meaning

TRUE Will apply draft to the extrusion


in Direction 1.

FALSE Will not apply draft to the


extrusion in Direction 1.

D2DraftOutward

Rule Meaning

TRUE Will apply Draft outwardly in


direction 2.

FALSE Will apply Draft inwardly in


direction 2.

58
The Little Book of Rules

Advanced Cut Extrude Thin parameters


D1Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

D1DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 1 to 15
degrees.

D1WallThickness

Rule Meaning

2 Sets the wall thickness for the


extrusion in direction 1 to 2.

59
DriveWorks Ltd.

BothDirections

Rule Meaning

TRUE Sets the extrusion in both


directions.

FALSE Sets the extrusion in the D1


direction only.

D2Depth

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 2 to the value
coming from the Length input.

D2DraftAngle

Rule Meaning

15 Sets the draft angle for the


extrusion in direction 2 to 15
degrees.

D2WallThickness

Rule Meaning

2 Sets the wall thickness for the


extrusion in direction 2 to 2.

60
The Little Book of Rules

ThinWallType

Rule Meaning

"OneDirection" Sets the Thin wall type for the


feature to be one direction.

"OneDirectionReverse" Sets the Thin wall type for the


feature to be the reverse one
direction.

"MidPlane" Sets the Thin wall type for the


feature to be mid plane.

"TwoDirection" Sets the Thin wall type for the


feature to be two directions.

61
DriveWorks Ltd.

Advanced Chamfer parameters


Type

Rule Meaning

"AngleDistance" Sets the chamfer type to angle


and distance inputs.

" DistanceDistance" Sets the chamfer type to distance


and distance inputs.

" Vertex" Sets the chamfer type to vertex


inputs.

TangentPropagation

Rule Meaning

TRUE Set the Tangent Propagation


property of the Chamfer.

KeepFeatures

Rule Meaning

TRUE Set the Keep Features property


of the Chamfer

62
The Little Book of Rules

EqualDistance

Rule Meaning

TRUE Set the Equal Distance Of the


Chamfer.

EdgeChamferAngle

Rule Meaning

45 Sets the angle of the chamfer to


45.

EdgeDistance1

Rule Meaning

5 Sets the edge distance in


direction 1 to be 5.

EdgeDistance2

Rule Meaning

10 Sets the edge distance in


direction 1 to be 10.

63
DriveWorks Ltd.

Advanced Fillet parameters


DefaultRadius

Rule Meaning

LengthReturn Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

KeepFeatures

Rule Meaning

TRUE Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

PropagateToTangentFaces

Rule Meaning

TRUE Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

64
RoundCorners

Rule Meaning

TRUE Sets the Depth for the extrusion


in direction 1 to the value
coming from the Length input.

OverflowType

Rule Meaning

"Default" Sets the overflow fillet type to


default.

"KeepEdge" Sets the overflow fillet type to


keep edge.

"KeepSurface" Sets the overflow fillet type to


keep surface.

www.driveworks.co.uk
DriveWorks Ltd.

Advanced Text parameters


Text controls the text in the sketch if present.

Rule Meaning

"Designed By " & Sets the sketch text to be


DrawnByReturn Designed By and the value
coming from the DrawnBy
input.

66
The Little Book of Rules

Custom Property Rules


Custom property rules control the text written into a custom
property.

Rule Meaning

Today() Will write the current date into


the custom property.

DrawnByReturn Will write the result of the input


DrawnBy into the custom
property.

Driving the Color


To drive the color of a model, first create and then capture a
custom property named DWColor. The result of the rule for
this property should return the required RGB value in the
format:
RedValue | GreenValue | BlueValue

Note that each value is separated with the pipe (|) symbol.

67
DriveWorks Ltd.

Rule Meaning

"0|0|255" Will write the value 0|0|255


into the custom property. The
color of the model will be driven
to the RGB equivalent of this
value when applied to a custom
property named DWColor.

RedReturn & "|" & Will write the result of the inputs
GreenReturn & "|" & Red, Green and Blue into the
BlueReturn custom property.

Color( 0 , 0 , 255 ) The Color function will write the


value 0|0|255 into the custom
property. The color of the model
will be driven to the RGB
equivalent of this. Value when
applied to a custom property
named DWColor.

Color(RedReturn , Will write the result of the inputs


GreenReturn , BlueReturn) Red, Green and Blue into the
custom property.

68
The Little Book of Rules

Driving the Material


Capture a custom property named DWMaterial. The result
of the rule for this property should return a string in the
following format:

MaterialDatabaseName | MaterialName

Rule Meaning

" SolidWorks Will write the value SolidWorks


Materials|Alloy Steel" Materials|Alloy Steel to the
custom property. The material
will be driven to this value when
applied to a custom property
named DWMaterial

" SolidWorks Materials|" & Will write the value SolidWorks


MaterialReturn Materials|and the value coming
from the input Material to the
custom property.

69
DriveWorks Ltd.

Driving the Texture


Capture a custom property named DWTexture. The result of
the rule for this property should return a string in the
following format:
PathToTextureBitmap | ScalePercentage |
AngleInDegrees

Rule Meaning

"\\Data\ Textures\ Will write the value


Plastic.jpg|0.45|90" \\Data\Textures\Plastic.jpg|0.45|90
to the custom property. The texture
will be driven to this value when
applied to a custom property named
DWTexture.

DWVariablePath & Will write the value calculated by the


TextureReturn & variable Path (combined with the
".jpg |" & 0.45 & value of the Texture input and .jpg)
"|" & 90 to the custom property.

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

TRUE Unsuppresses the instance. You


could also use "Unsuppress" (in
quotes), or "U" (in quotes).

FALSE Suppresses the instance. You


could also use "Suppress" (in
quotes), or "S" (in quotes).

"DELETE" Deletes the instance from its


parent assembly.

"Red" The configuration of the


instance is switched to red.

"<Replace> Replaces the instance with a


MyComponentSetName" component set called
MyComponentSetName.

"U|Red" Will unsuppress the instance and


switch it’s configuration to Red.

71
DriveWorks Ltd.

" <Replace> Replaces the instance with a


MyComponentSetName | component set called
Red " MyComponentSetName and
switches the configuration of the
replacement file to Red.

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

"Delete" Prevents the drawing from being


generated.

DWSpecificationId Creates a drawing with its file


name set to be its original file
name, suffixed with the
specification number. Eg:
"Block.slddrw" would become
"Block 1.slddrw" if it was
generated by the first
specification.

"*" & DWSpecificationId Creates a drawing with its file


name set to be the specification
number. Eg: "Block.slddrw"
would become "1.slddrw" if it
was generated by the first
specification.

"*" & DWSpecificationId & Creates a drawing with its file


"*" name set to its original name,
prefixed with the specification
number. Eg: "Block.slddrw"
would become "1 Block.slddrw"
if it was generated by the first
specification.

73
DriveWorks Ltd.

Relative Path Rule


The relative path rule controls the folder that the drawing is
created in. The folder is specified relative to the "Results"
folder which is in the same folder as the project file.

Rule Meaning

"" If the project is located at


"C:\DriveWorks Pro\My
Cupboard\My
Cupboard.driveproj" then the
driven drawing will be created in
"C:\DriveWorks Pro\My
Cupboard\Results\".

DWSpecificationId If the project is located at


"C:\DriveWorks Pro\My
Cupboard\My
Cupboard.driveproj" and the
specification number is 56 then
the driven drawing will be
created in "C:\DriveWorks
Pro\My
Cupboard\Results\56\".

" \\dataserver\ The driven drawing will be


models\cupboards" created in \\dataserver\models
\cupboards.

74
The Little Book of Rules

Layer State Rule


Layer state rules are used to control the visibility of a layer.

Rule Meaning

TRUE Shows the layer.

You could also use "Show" (in


quotes).

FALSE Hides the layer.

You could also use "Hide".

Sheet State
Sheet state rules are used to delete or rename sheets.

Rule Meaning

"" Leaves the sheet as it is.

TRUE Leaves the sheet as it is.

FALSE Deletes the sheet.

You could also use "Delete" (in


quotes).

"PDF" Renames the sheet to be "PDF".

75
DriveWorks Ltd.

Sheet Scale Numerator and Denominator Rules


Sheet numerator and denominator rules are used to control
the scale of the sheet.

Rule Meaning

Scale Numerator = 1 Will set the scale of the sheet


to be 1:2
Scale Denominator = 2

Scale Numerator = When Height is less than 1000,


IF(HeightReturn<1000,2,1) the sheet will be scaled to a
ratio of 2:1. Otherwise the
Scale Denominator = sheet will be scaled to a ratio of
IF(HeightReturn<1000,1,2) 1:2

Scale Numerator = When Height is less than 1000


IF(OR(HeightReturn<1000, or Width is less than 500 the
WidthReturn<500) ,2,1) sheet will be scaled to a ratio of
2:1. Otherwise the sheet will be
Scale Denominator = scaled to a ratio of 1:2
IF(OR(HeightReturn<1000,
WidthReturn<500),1,2)

76
View State Rules
View state rules are used to delete or change the
configuration of a view.

Rule Meaning

"" Leaves the view as it is.

TRUE Leaves the view as it is.

FALSE Deletes the view.

You could also use "Delete" (in


quotes).

"Red" Changes the view to show the


"Red" configuration of the
referenced model.

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

Scale Numerator = 1 Will set the scale of the view to


be 1:2.
Scale Denominator = 2

Scale Numerator = When Height is less than 1000,


IF(HeightReturn<1000,2,1) the view will be scaled to a
ratio of 2:1. Otherwise the view
Scale Denominator = will be scaled to a ratio of 1:2.
IF(HeightReturn<1000,1,2)

Scale Numerator = When Height is less than 1000


IF(OR(HeightReturn<1000, or Width is less than 500, the
WidthReturn<500) ,2,1) view will be scaled to a ratio of
2:1. Otherwise the view will be
Scale Denominator = scaled to a ratio of 1:2.
IF(OR(HeightReturn<1000,
WidthReturn<500),1,2)

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

View Left = 20 Sets the left position 20 units


from the left and 250 units from
View Top = 250 the bottom.

View Left = Sets the left position to the value


DWVariableLeft calculated by DWVariableLeft
from the left and the value
View Top = calculated by DWVariableTop
DWVariableTop units from the bottom.

View Left = IF( Sets the left position 20 units


LengthReturn < 2000,20,40) from the left, when the Length is
less than 2000 and 250 units
View Top = IF( from the bottom when the
HeightReturn < Height is less than 1000.
1000,250,350)

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

Distance 1 = 15 Sets the first breakline 15


document units from the left
Distance 2 = 35 of the view, and the second
breakline 35 document units
from the right of the view.

Distance 1 = Sets the first breakline to the


DWVariableBreakLeft value calculated by
DWVariableBreakLeft from
Distance 2 = the left of the view, and the
DWVariableBreakRight second breakline to the value
calculated by
DWVariableBreakRight from
the right of the view.

Distance 1 = Sets the first breakline 15


IF(LengthReturn<2000,15,45) document units from the
left, when the Length is less
Distance 2 = than 2000 and 45 document
IF(LengthReturn<2000,35,65) units from the left when the
Length is greater than 2000.
Sets the second breakline 35
document units from the
right, when the Length is <
2000 and 65 document units
from the right when the
Length is > 2000.

80
The Little Book of Rules

Drawing Custom Property Rules


Custom property rules control the text of a custom property
in a drawing.

Rule Meaning

CustomerReturn Results in the custom property


being set to the value the user
typed into the input Customer.

DrawnByReturn Will write the result of the input


DrawnBy into the custom
property.

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

"Total Quantity = " & Sets the note to be Total


QuantityReturn Quantity = 5 (when the value in
the form control QuantityReturn
is 5)

81
DriveWorks Ltd.

Dimension Text Rules

The text displayed around a dimension (either reference or


model item dimension) in a drawing view can be controlled
by DriveWorks.
SETTEXT([TextPosition],[Text])
Where TextPosition is an index number representing the
position to place the text where:
1 = Places text to the left of the display dimension
2 = Places text to the right of the display dimension
3 = Places text above the display dimension
4 = Places text below the display dimension
5 = Replaces all text in the display dimension with the
string
Text is a number or text to insert in that position.

Rule Meaning

"SetText(2,OAll Length)" Places the text OAll Length


after the display dimension.

"SetText(4,Reference Places the text Reference Only


Only)" below the display dimension.

82
The Little Book of Rules

Surface Finish Symbol Rules


A surface finish symbol rule consists of separate functions to
control individual elements of the surface finish (SF) symbol.
The functions can be used individually, to control just that
element of the SF Symbol, or together to control the whole
of the SF Symbol. When used together the functions are
separated using the pipe bar (|).
SETSYMBOL([SymbolIndexNumber],
[SurfaceTextureIndexNumber],[AllAround])
Where:
SymbolIndexNumber is the index number of the required
symbol (see chart below).
SurfaceTextureIndexNumber is the index number of the
required texture symbol (see chart below).
AllAround is either True or False (see chart below).

83
DriveWorks Ltd.

84
The Little Book of Rules

Rule Meaning

"SetSymbol (2,0,True)" Results in the Machining


Prohibited, All Around
symbol being used.

"SetSymbol(" & Results in Machining


DWVariableSymbolNumber & Prohibited, Local symbol
"," & being used, when the results
DWVariableTextureNumber & of the variables used are 2 and
"," & "False)" 0 respectively.

"SetSymbol(" & Results in Machining


DWVariableSFString & ")" Prohibited, Local symbol
being used, when the result of
the variable,
DWVariableSFString, is the
string ,2,0,False

Surface Finish Value Rules


SETTEXT([PositionIndexNumber],[Text])
Where:
PositionIndexNumber is the index number for the required
position of the value to display (see chart below).
Text is the value to display.

85
DriveWorks Ltd.

86
The Little Book of Rules

Rule Meaning

"SetText (5,6.3)|SetText Sets the Rmax value to be 6.3


(6,1.6)" and the Ra value to be 1.6

"SetText(5," & Sets the Rmax value to be the


DWVariableRmax & result of the variable
")|SetText (6," & DWVariableRmax, and the
DWVariableRa & ")" Ra value to be the result of the
variable DWVariableRa

Combining Surface Finish Symbol and Value Rules


Surface Finish Symbol and Values are combine by separating
the Symbol and Value syntax with the pipe bar (|) symbol.

Rule Meaning

"SetSymbol(" & Results in Machining


DWVariableSFString & Required, Local symbol being
")|SetText(5," & used, when the result of the
DWVariableRmax & variable,
")|SetText(6," & DWVariableSFString, is the
DWVariableRa & ")" string ,1,0,False.

Also sets the Rmax value to be


the result of the variable
DWVariableRmax, and the
Ra value to be the result of the
variable DWVariableRa

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:

ProductCombo ProductCode Result of the OR


BoxReturn = TextBox = function
"Door" "D355"
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE

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:

CustomerName CustomerCombo Result of the


TextBoxReturn BoxReturn Value EXACT
Value function

"Sandra Smith" "Sandra Smith" TRUE

"john smith" "John Smith" FALSE

128
The Little Book of Rules

Find (Case Sensitive)


The Find function finds one text value within another.
FIND([FindText],[WithinText],[Start
Number])
FindText is the string of text to be found.
WithinText is the string of text within which FindText is to
be located.
StartNumber is the number of the character in the
WithinText value where the search will start from.
The Find function searches the WithinText value from the
specified StartNumber for the first occurrence of the
FindText string.
The Find function returns the starting position of the first
character of the occurrence found in the WithinText value.
FIND(ProductCodeComboBoxReturn,ProductTextBox
Return,1)means that the Find function will start its search
at the first character of the Product Text Box return entry
looking for the return value from the Product Code Combo
Box.
Example Outcomes of the Find Function:
ProductCode ProductTextBox Start Result of
ComboBox Return Value Number the FIND
Return Value function
"C786" "Castor C786" 1 8
"MB" "MBTinMB" 2 6

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.

Search (Case Insensitive)


This function searches within text for a specified text string
from a specified character.
SEARCH([FindText],[WithinText],[Start
Number])
If no value is entered for StartNumber, then the search will
begin with the first character of the WithinText string.
If no occurrence of the FindText string is found, then a null
value is returned. Otherwise, the number of the first character
of the occurrence is returned.
SEARCH("Hello","And I said Hello to
them",1)searches the string "And I said Hello to them" for
the first occurrence of the string "Hello", starting the search
from the first character. The result of the Search function
would be 9, the starting character of "Hello" in the
WithinText string.

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

File System Functions


FsChangeExtension
This function returns the full file path and name of the given
file, substituting its existing file extension with the given
extension.
FSCHANGEEXTENSION([Path],[Extension])
FSCHANGEEXTENSION("C:\DriveWorks8\NewFunction
\FileExtension\MyFileName","xml") will return the
value:
C:\DriveWorks8\NewFunction\FileExtension\MyFileName.xml.

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

WeekDay function ReturnType values:


The Return Type column of the chart below are referenced in
the WeekDay function (see page 95 for more information)

Return Type Number Returned


1 or Omitted Numbers 1 (Sunday) through 7 (Saturday)
2 Numbers 1 (Monday) through 7 (Sunday)
3 Numbers 0 (Monday) through 6 (Sunday)
11 Numbers 1 (Monday) through 7 (Sunday)
12 Numbers 1 (Tuesday) through 7
(Monday)
13 Numbers 1 (Wednesday) through 7
(Tuesday)
14 Numbers 1 (Thursday) through 7
(Wednesday)
15 Numbers 1 (Friday) through 7 (Thursday)
16 Numbers 1 (Saturday) through 7 (Friday)
17 Numbers 1 (Sunday) through 7 (Saturday)

151
DriveWorks Ltd.

WeekNum function ReturnType values:


The Return Type column of the chart below are referenced in
the WeekNum function (see page 95 for more information)

Return Type Number Returned


1 or Omitted Sunday
2 Monday
11 Monday
12 Tuesday
13 Wednesday
14 Thursday
15 Friday
16 Saturday
17 Sunday
21 Monday

152
The Little Book of Rules

WorkDayCustom function Weekend values:


The Weekend Value column of the chart below are
referenced in the WorkDayCustom function (see page 96 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

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

GetTableValue............140 Min............................... 117


Hour ............................... 90 Minute ........................... 91
If ...................................102 Mod ............................. 117
Int .................................114 Month............................ 91
IsError .........................145 MRound ...................... 118
IsEven ..........................114 NetWorkDays .............. 92
IsOdd ...........................115 NetWorkDaysCustom 93
Left ...............................130 NewLine ..................... 132
Len ...............................131 Not............................... 103
List .................................. 99 Now ............................... 93
ListAll...........................141 Odd.............................. 118
ListAllConditional ......141 Or................................. 104
ListAllConditionalDistinc Pi .................................. 118
t .....................................141
Power .......................... 119
ListAllDistinct ............142
Product........................ 119
ListCountItems...........142
Proper.......................... 132
ListFindItems .............142
Quotient ...................... 119
ListGetItems ...............143
Radians ........................ 120
ListJoin ........................143
Rand ............................ 120
Ln .................................115
RandBetween ............. 120
Log ...............................115
Replace ........................ 132
Log10 ...........................116
Rept ............................. 133
Lookup .......................... 21
Right ............................ 133
Lower ...........................131
Round .......................... 121
Max...............................116
RoundDown............... 121
Mid ...............................131

155
DriveWorks Ltd.

RoundUp .....................121 TanH ........................... 125


Search ...........................134 Text.............................. 136
Second ........................... 93 Text Builder ................ 100
Sign ...............................122 TextFormat................. 136
Sin .................................122 TimeValue .................... 94
SinD .............................122 Today............................. 94
SinH .............................123 Trim ............................. 136
Sqrt ...............................123 Trunc ........................... 125
SqrtPi ...........................123 Upper .......................... 137
String ............................134 Value............................ 137
StringLocal ..................135 ValueLocal .................. 137
Substitute .....................135 VLookup ..................... 144
Sum ..............................124 WeekDay ...................... 95
TableGetColumnCount WeekNum .................... 95
......................................143
WorkDay ...................... 96
TableGetRowCount ..143
WorkDayCustom......... 96
Tan ...............................124
Year ............................... 97
TanD ............................124

156

You might also like