Home Search

DriveWorks Pro 21
Functions

Send Feedback

Functions

The following functions have been added to DriveWorks 12.

DbQuery

Runs a query against a table in a database, returning the result as a headered table.

Syntax

DbQuery( ["Connection String"], ["SQL Command"], ["User Name"], ["Password"])

Connection String is the string that will connect to the required database:

DBQuery supports both DSN and direct SQL connection strings.

If using ODBC, a valid data source name is required, for example:

ODBC Connection String
"SystemDSNName"

If using SQL Server, a valid SQL connection string is required, for example:

SQL Connection String
"Server= ServerName;Database= DatabaseName"

SQL Command is a valid SQL Query command to execute, for example:

SQL SELECT Command
"SELECT FROM Country WHERE Currency = 'Dollar'"

User Name (Optional) is the user name for the database

Password (Optional) is the password for the database

Examples

RuleMeaning
DbQuery("Server=MYSERVER;Database=Customers;",@"SELECT DISTINCT ([Country]) FROM [Customers] ORDER BY [Country] ASC")Will connect to the SQL Server MYSERVER and the database Customers. A headered table of country names, excluding duplicates will be retrieved, in ascending order. The retrieved table will be: {"Country";"France";"Germany";"Italy";"Spain";"Netherlands"}

Example Outcomes

ServerDatabase NameQueryOutcome
MYSERVERCustomersSELECT ([CustomerName]) FROM [Customers] WHERE [Country] = 'Germany' ORDER BY [CustomerName] ASCWill connect to the SQL Server MYSERVER and the database Customers. A headered list of customers from Germany will be retrieved, in ascending order. The retrieved list will be: {"CustomerName";"Boston Bulls";"English Stars";"Munich Marshalls";"Spectacular Players";"TT Tigers"}
MYSERVERCustomersSELECT ([ContactName]) FROM [Customers] WHERE [CustomerName] = 'Cambridge Cats' ORDER BY [ContactName] ASCWill connect to the SQL Server MYSERVER and the database Customers. A headered list of contact names will be retrieved, for the Cambridge Cats customer, in ascending order. The retrieved list will be: {"ContactName";"Howard Flight";"Mark Tami"}

Example Data

Customers Table

CustomerName

ContactNameCountry
Amazon WarriorsFrank DoranFrance
TT TigersMalcolm SavidgeGermany
Super JetsAnne BeggItaly
Munich MarshallsHelen LiddellGermany
Super LeagueGerald HowarthSpain
Shelley GiantsRichard ShepherdFrance
Boston BullsGraham BradyGermany
Cambridge CatsMark TamiFrance
Ohio RockersJudy MallaberNetherlands
Notts StagsMichael WeirFrance
Ruling ClassAlan ReidFrance
Cambridge CatsHoward FlightFrance
Lymm LazersGeoff HoonFrance
Spectacular PlayersDamian GreenGermany
English StarsDavid HeyesGermany

EmailGetDomainName

Gets the domain name portion of an email address.

Syntax

EmailGetDomainName(Email As String)

Where:

Email must be a valid email address.

Examples

RuleMeaning
EmailGetDomainName("fredbloggs@hotmail.com")Will return the domain name from the given email address i.e. "hotmail.com".

EmailGetUserName

Gets the user name portion of an email address.

Syntax

EmailGetUserName(Email As String)

Where:

Email must be a valid email address.

Examples

RuleMeaning
EmailGetUserName("fredbloggs@hotmail.com")Will return the user name from the given email address i.e. "fredbloggs".

FsGetFullPathGroupContent

Resolves a file path relative to the group content folder. Also supports prefixes specified in the FsGetFullPath function.

Syntax

FsGetFullPathGroupContent(Group Content As String)

Where:

Group Content is the file path to get the full path for.

Examples

RuleMeaning
FsGetFullPathGroupContent("Images")Will return the full path to the images folder located within the Group Content folder i.e. "D:\DriveWorks\Group Content\Images".

IfEmpty

Checks to see if its first argument is an empty value. If the value isn't an empty value it is returned as-is, otherwise a secondary value is returned.

Syntax

IfEmpty(Primary Value As String, Alternative Value As String)

Where:

Primary Value is the value that should be tested.

Alternative Value is the value which will be returned if the first value is empty.

Examples

RuleMeaning
IfEmpty(ColorReturn,"Red")Will return "Red" when the value coming from the control Color is empty.

IfError

Checks to see if its first argument is an error. If the value isn't an error it is returned as-is, otherwise a secondary value is returned.

Syntax

IfError(Primary Value As String, Error Replacement Value As String)

Where:

Primary Value is the value to check for an error.

Error Replacement Value is the value to use if the primary value is an error.

Examples

RuleMeaning
IfError(DWVariableLength,2475)Will return 2475 when the value coming from the variable Length is an error.

IfNonBoolean

Checks to see if its first argument is a boolean. If the value is a boolean it is returned as-is, otherwise a secondary value is returned.

Syntax

IfNonBoolean(Primary Value As Boolean, Alternative Value As String)

Where:

Primary Value is the value whose type should be tested.

Alternative Value is the value which will be returned if the type of the first value fails the type test.

Examples

RuleMeaning
IfNonBoolean(OptionRequiredReturn,FALSE)Will return FALSE when the value coming from the control OptionRequired is not a boolean.

IfNonNumber

Checks to see if its first argument is a number. If the value is a number it is returned as-is, otherwise a secondary value is returned.

Syntax

IfNonNumber(Primary Value As String, Alternative Value As String)

Where:

Primary Value is the value whose type should be tested.

Alternative Value is the value which will be returned if the type of the first value fails the type test.

Examples

RuleMeaning
IfNonNumber(DWVariableLength,0)Will return 0 when the value coming from the variable Length is not a number.

IsBoolean

Returns TRUE if the given value is a boolean and FALSE if not.

Syntax

IsBoolean(Value As Boolean)

Where:

Value is the value to check.

Examples

RuleMeaning
IsBoolean(OptionRequiredReturn)Will return TRUE when the value coming from the control OptionRequired is TRUE or FALSE otherwise it will return FALSE.

IsEmpty

Returns TRUE if the given value is either an empty value or a zero-length piece of text.

Syntax

IsEmpty(Value As String)

Where:

Value is the value to check.

Examples

RuleMeaning
IsEmpty(ColorReturn)Will return TRUE when the value coming from the control Color is empty.

IsNonBoolean

Returns TRUE if the given value is not a boolean and FALSE if it is.

Syntax

IsNonBoolean(Value As String)

Where:

Value is the value to check.

Examples

RuleMeaning
IsNonBoolean(OptionRequiredReturn)Will return TRUE when the value coming from the control OptionRequired is not a Boolean value.