$dirpath

Returns information about the currently accessed application directories.

Syntax

$dirpath()

Return Value

Character string.

Comments

$dirpath returns a character string consisting of the names of all currently accessed application directories and their access types (U for update, R for read). Information about each directory is enclosed in semicolons (;). The directory name appears first, followed by the access type in parentheses.
Directories appear in the order that they were accessed; that is, the most recently accessed directories appear first.

Example

access dir1
access dir2 updatev

output $dirpath()

Prints the string; dir2(U);dir1(R);ZIM(U);_$ZimServices(R);_$session$_(U);

let vDirPath = $dirpath()

let vPos = $position($toalpha(vDirPath, -1), ";Dir1(")

if vPos > 0

output "Directory Dir1 is accessed ";

if $substring(vDirPath,vPos+6,1)="U"

output "update."

else

output "read."

endif

else

output "Directory Dir1 is NOT accessed."

endif

Uses $position to test if a particular directory is accessed.

See Also

ACCESS

RELEASE

$addminutes

Calculates a time value by adding minutes to (or subtracting minutes from) a specified time value.

Syntax

$addminutes(time,number)

where

timean 8-digit number or an expression that evaluates to an 8-digit number, that expresses a valid time value in the format HHMMSSTT
numbera number or an expression that evaluates to a number

Return Value

Number, representing a time value.

Comments

Use $addminutes to perform arithmetic with time values. The $addminutes function calculates a time value by adding a number representing minutes to a time value. If number is negative, the effect is to subtract the minutes from the time.

Example

If $Time has the value 22503075, then

$addminutes($time,5)

Evaluates to 22553075.

$addminutes($time,10)

Evaluates to 23003075.

$addminutes($time,-5)

Evaluates to 22453075.

$addminutes($time,65)

Evaluates to 23553075.

$addseconds

Calculates a time value by adding seconds to (or subtracting seconds from) a specified time value.

Syntax

$addseconds(time,number)

Parameters

timean 8-digit number, or an expression that evaluates to an 8-digit number, that expresses a valid time value in the format HHMMSSTT
numbera number, or an expression that evaluates to a number

Return Value

Number, representing a time value.

Comments

Use $addseconds to perform arithmetic with time values. The $addseconds function calculates a time value by adding a number representing seconds to a time value. If number is negative, the effect is to subtract the seconds from the time.

Example

If $Time has the value 22503075, then

$addseconds($time,5)

evaluates to 22503575.

$addseconds($time,35)

evaluates to 22510575.

$addseconds($time,-5)

evaluates to 22502575.

$addseconds($time,65)

evaluates to 22513575.

$addseconds(22595900,1)

evaluates to 23000000.

See Also

$addhours
$addminutes
$addticks
$seconds

$count

Counts the number of set members that meet a specified condition, excluding records in which the condition is $Null.

Syntax

$count(expression)

Parameters

expressionis any expression

Return Value

Number, with no decimal places.

Comments

Expression is often a WHERE expression that includes only selected set members in the counting operation. If the WHERE expression (expr1 WHERE expr2) is true, then the member containing expr1 is included in the running count; otherwise, expression is considered $Null and is not included in the running count.

Example

compute Employees where DeptName="Sales" 
  evaluate (let EmpsInSales = $count(LastName where LastName = "Smith"))

First finds all employees in the sales department, then counts the number of Smiths among those employees.

add Employees from TestData let EmpNum = ($count("")+1000)

As employee data is added, each new record is counted. New employee records are assigned unique employee numbers in sequence, based on the current value of $count plus 1000.

See Also

$average

$max

$min

$total

About Character Literals

About Functional Expressions

WHERE

$tonumber

Converts a value into its numeric equivalent.

Syntax

$tonumber(expression,decimals)

Parameters

expressionAny value, or an expression that yields any value.
decimalsA number specifying the number of decimal places required in the converted value. Decimals can be negative.

Return Value

Number equivalent of expression.

Comments

Use $tonumber to obtain the numeric equivalent of expression. If decimals is negative, the implicit number of decimal places in expression is used.

Example

$tonumber(1.273,2)

Evaluates to 1.27.

$tonumber(16/6,3)

Evaluates to 2.667.

$tonumber("2345",2)

Evaluates to 2345.00.

$tonumber("Smith",5)

Evaluates to 0.00000 (and produces an error).

$tonumber("1.2"*1.20,-1)

Evaluates to 1.44.

See Also

$money
$round
$toalpha
$tocharacter
About Functional Expressions
Decimals and Rounding
Decimals in Functional Expressions
Number Literals

$min

Returns the minimum value of a set of values.

Syntax

$min(expression)

Parameters

expressionany expression

Return Value

The value of the selected instance of expression.

Comments

Use $min to find the smallest value among members of a set. Instances of expression that are $Null are ignored.

Expression is often a WHERE expression that includes only selected values in the operation. If the WHERE expression (expr1 WHERE expr2) is true, the expr1 value is included in the operation; otherwise, expression is considered $Null and is ignored.

Example

compute Employees where DeptName = "Sales" 
  evaluate (let MaxSal = $max(Salary)) 
      (let MinSal = $min(Salary)) 
      (let MaxSalF = $max(Salary where Sex = "F")) 
      (let MinSalF = $min(Salary where Sex = "F"))

At the end of this operation, MaxSal contains the highest salary paid to any employee in Sales; MinSal contains the lowest salary paid to any employee in Sales; MaxSalF contains the highest salary paid to any female employee in Sales; and, MinSalF contains the lowest salary paid to any female employee in Sales.

See Also

$average

$count

$max

$total

About Functional Expressions

WHERE

$max

Returns the maximum value of a set of values.

Syntax

$max(expression)

Parameters

expressionany expression

Return Value

The value of the selected instance of expression.

Comments

Use $max to find the largest value among members of a set. Instances of expression that are $Null are ignored.

Expression is often a WHERE expression that includes only selected values in the operation. If the WHERE expression (expr1 WHERE expr2) is true, the expr1 value is included in the operation; otherwise, expression is considered $Null and is ignored.

Example

compute Employees where DeptName = "Sales"
evaluate (let MaxSal = $max(Salary))
(let MinSal = $min(Salary))
(let MaxSalF = $max(Salary where Sex = "F"))
(let MinSalF = $min(Salary where Sex = "F"))

At the end of this operation, MaxSal contains the highest salary paid to any employee in Sales; MinSal contains the lowest salary paid to any employee in Sales; MaxSalF contains the highest salary paid to any female employee in Sales; and, MinSalF contains the lowest salary paid to any female employee in Sales.

See Also

$average

$count

$min

$total

About Functional Expressions

WHERE

$average

Returns the average value of a set of values, excluding $Null values.

Syntax

$average(expression)

Parameters

expressionany expression

Return Value

Number, with the number of decimal places implied by expression.

Comments

The function calculates the average of a set of values, excluding $Null values.

Expression is often a WHERE expression that includes only selected values in the averaging operation. If the WHERE expression (expr1 WHERE expr2) is true, the expr1 value is included in the averaging operation; otherwise, expression is considered $Null and is not included in the averaging operation.

Example

compute Employees where DeptName="Sales"
evaluate (let AvgAge = $average($year($date)-$year(BirthDate)))
(let AvgSal = $average(Salary where Sex = "F"))

Finds the average age of all employees, and the average salary of all female employees, in the sales department.

report footing
$average(Salary)
($total(Salary*Salary) / $count(Salary) - $average(Salary) * $average(Salary))

Reports average salary and salary variance.

See Also

$count

$max

$min

$total

How to Use The Report Generator

WHERE

$squeeze

Builds a single character string out of separate strings, inserting a separator string.

Syntax

$squeeze(separator «,string»)

Parameters

separatorA character string, or an expression that evaluates to a character string. Separator is placed between each instance of string.
stringA character string, or an expression that evaluates to a character string. Leading and trailing blanks are trimmed from string. Each string must be separated from the next by a comma.

Return Value

Character string.

Comments

$squeeze combines specified strings into a single string, with separator placed between each string. In the function call, each string must be separated from the next by a comma. Leading and trailing blanks are trimmed from each string.

Example

$squeeze (",",LastName,FirstName,Salutation)

Evaluates to “Smith,John,Mr.” when FirstName is “John “, LastName is “Smith “, and Salutation is “Mr. “.

list all Ents format $squeeze ("",EntName,EntType,AvgSize,DirName)

Compresses the LIST output as much as possible.

Related Information

$concat

$addweeks

Calculates a date value by adding weeks to (or subtracting weeks from) a specified date value.

Syntax

$addweeks(date,number)

Parameters

datea date, or an expression that evaluates to a DATE data type
numbera number, or an expression that evaluates to a number

Return Value

Number, representing a DATE value.

Comments

Use $addweeks to perform arithmetic with date values. The $addweeks function calculates a date value by adding a number representing weeks to a date value. If number is negative, the effect is to subtract the weeks from the date.

The + (add) and – (subtract) operators can be used to achieve the same results.

If date or the result of the $addweeks expression is an invalid date (e.g., 19930231), it is adjusted to produce a valid date (e.g., 19930228).

Example

If $Date has the value 19981225, then

$addweeks($date,1)

Evaluates to 19990101.

$addweeks($date,-2)

Evaluates to 1998.501.

$addweeks(19980201,4)

Evaluates to 19980301.

See Also

$adddays

$addmonths

$addyears

$todate

$weekday

+ (Add/Positive)

– (Subtract/Negative)

About Functional Expressions

Arithmetic with Dates

en_CAEnglish