Extracts a segment from the end of a character string.
Syntax
$right(source,length)
Parameters
| source | a character string, or an expression that evaluates to a character string |
| length | a number, or an expression that evaluates to a number |
Return Value
Character string, consisting of length characters from source, starting length character positions from the end of source.
Comments
Use $right to produce a string consisting of length characters from source, starting length character positions from the end of source.
If source is not of a character data type, it is converted to a character data type before the function is applied.
If length is zero or negative, the result is the null string.
If length is longer than source, the result is source.
Example
$right("abcdefgh",5)Evaluates to “defgh”.
$right(1234,2)
Evaluates to “34”.
$right(1234567890,8)
Evaluates to “34567890”.
See Also
$concat
$delete
$insert
$left
$position
$replace
$substring
$translate
About Character Literals
About Functional Expressions
Conversion Between Data Types
Returns the unique values from a series of successive values.
Syntax
$distinct(expression)
Parameters
Return Value
This function returns the unique values from a series of successive values. For each instance of its argument, $distinct returns a value that depends on the immediately previous value of the argument. If the previous and current values of the argument are equal, $distinct returns $Null. Otherwise, $distinct returns the current value of the argument.
Comments
It is important to sort the argument’s source values before using $distinct, because the value returned by the expression depends on the order in which the source values are processed.
Example
find Emps sorted by LastName
list all format LastName Salary
Prints the last names and salaries of all employees.
find Emps sorted by LastName
list all format $distinct(LastName) Salary
Prints the last names and salaries only of the employees who appear first in the list with a particular name.
find Emps sorted by LastName
list all where $distinct(LastName) is not $null format LastName
Prints a list of the last names of employees without repeating identical names.
report from Emps sorted by DeptNo LastName
break 1 DeptNo
footing
"No. of distinct last names in " deptno
"is" $count($distinct(LastName))
endreport
When used in a BREAK heading or footing, $distinct is reset for each break group. As a result, the first record in each break group is considered to be new, even if the value of the argument to $distinct is the same as the last value in the previous group. In the above report, even if the last employee in one department is named Smith and the first employee in the next is also Smith, the values are still considered to be distinct.
See Also
Functional Expressions
INTERSECT
MINUS
UNION
Extracts a segment from the front of a character string.
Syntax
$left(source,length)
Parameters
| source | a character string or an expression that evaluates to a character string |
| length | a number or an expression that evaluates to a number |
Return Value
Character string, consisting of a string containing length characters from source, starting in the first position.
Comments
Use $left to produce a string consisting of length characters from source, starting in the first position.
If source is not of a character data type, it is converted to a character data type before processing.
If length is zero or negative, the result is the null string. If length is longer than source, the result is source.
Example
$left("abcdefgh",5)Evaluates to “abcde”.
$left(9999,1)
Evaluates to ” “, because numbers are converted to character strings containing seventeen characters before being processed by $left.
$left(1234567890,10)
Evaluates to ” 123″. Number literals convert to character strings containing seventeen characters before being processed by $left.
See Also
$concat
$delete
$insert
$position
$replace
$right
$substring
$toalpha
$tocharacter
$translate
Applies a mask pattern to the specified data item.
For a more detailed explanation of mask patterns and their relation to data types, see Masking.
Syntax
$mask(item,pattern)
Parameters
| item | - A value of any type or an expression that yields a value of any type; or
- An field of any data type.
|
| pattern | - The mask pattern to apply to item.
- alphanumeric;
- a constant, a variable, a parameter, or a field.
|
Return Value
Character string, containing the masked value.
Comments
- Mask patterns consist of special characters and fixed text characters;
- Fixed text characters are always output as is;
- The set of special characters available for use to mask a particular data value is determined by the data type of value being masked (character string, date, or number );
- Most special characters are typically replaced by characters from item, but they can also output characters in their own right (e.g., the floating currency symbol: $, which can be customized);
- The Language Customizer utility (ZIMLANG) can be used to redefine how certain special characters are displayed or output.
For example, in numeric masks, the currency symbol $ normally outputs a dollar sign, but it can be configured to output other symbols, such as the pound sign £ or yen sign ¥.
Examples
list all Employees format FirstName LastName
($mask(DeptNum,”?epartment Number ??”))
Displays values of DeptNum, such as “D09”, as “Department Number 09”, instead of “D09”.
list all Employees format FirstName LastName
($mask(Salary,”$$$$$$9.99″))
Displays all values of Salary with a floating dollar sign.
$mask ($date, “MM-DD-YY”)
Evaluates to “08-18-98” if $Date is 19980818.
Converts an expression to the character data type and sets the length of the result.
Syntax
$tocharacter(expression,length)
Parameters
| expression | Any value, or an expression that yields any value. |
| length | A number that specifies the number of characters in the resulting character string. Length can be a constant, a variable, a form field, or a parameter. |
Return Value
Character (char), length bytes long.
Comments
Use $tocharacter to convert expression to the CHAR data type in an area length bytes long. If length is negative, the result string is set to the maximum possible length.
String comparisons involving this function are case-sensitive.
If expression is a number, the number is converted to character string form in an area length bytes long. If the given area is not large enough to hold the converted value, an error results.
Example
Assume LastName is “Smith “.
$tocharacter(LastName,3)
Evaluates to “Smi”.
$tocharacter(LastName,12)
Evaluates to “Smith “.
$tocharacter(50,2)
Evaluates to “50”.
$tocharacter(200+300,20)
Evaluates to ” 500″ (17 leading spaces).
$tocharacter(500,-2)
Evaluates to ” 500″ (14 leading spaces).
list all Emps format $tocharacter(FirstName,6), $tocharacter(LastName,9)
$tocharacter changes the width of values being output with a LIST command.
Locates the first occurrence of a pattern in a character string.
Syntax
$position(source,pattern)
Parameters
| source | a character string, or an expression that evaluates to a character string |
| pattern | a character string, or an expression that evaluates to a character string |
Return Value
Number, being the position of the first character in source that matches the first character of pattern, when pattern is found in source.
Comments
$position returns a number that identifies the start position of pattern in source. If pattern is not found in source, $position returns 0.
If either source or pattern is not of a character data type, it is converted to a character string before the operation begins. If source is of data type ALPHA or VARALPHA, the operation is case-insensitive; otherwise, the operation is case-sensitive.
Example
$position(var1,"ab")
Evaluates to 4 if var1 is “defabc”.
$position("abcdef","zz")Evaluates to 0.
find all Customers where $position(Comments, "overdrawn") > 0
Determines if the word overdrawn appears in the Comments field for any one of your Customers.
See Also
$concat
$delete
$insert
$left
$replace
$right
$substring
$translate
About Character Literals
About Functional Expressions
Inserts a character string into another character string.
Syntax
$insert(source,position,string)
Parameters
| source | a character string, or expression that evaluates to a character string |
| position | a number or an expression that evaluates to a number |
| string | a character string, or expression that evaluates to a character string |
Return Value
Character string consisting of source, with string embedded starting at the specified position.
Comments
Use $insert to produce a string consisting of source, with string embedded starting at position.
In a string, the position of the first character is always 1. If position is beyond the end of source, then string is appended to source. If position is zero or negative, then source is left unchanged.
Example
$insert("12345",3,"abc")Evaluates to “12abc345”.
$insert("abc",1,"de")Evaluates to “deabc”.
$insert("abc",4,"def")Evaluates to “abcdef”.
$insert($delete("abcdef,2,2),2,"123")Evaluates to “a123def”.
See Also
$delete
$fill
$left
$position
$replace
$right
$squeeze
$substring
$translate
Converts an expression to the alpha data type and sets the length of the result.
Syntax
$toalpha(expression,length)
Parameters
| expression | Any value, or an expression that yields any value. |
| length | A number. Can be a constant, a variable, a parameter, a menu item, or a form field. |
Return Value
Character string (alpha), length bytes long.
Comments
Use $toalpha to convert expression to the alpha data type in an area length bytes long. If length is negative, the result string is set to the maximum possible length. If length is zero, the result is the null string.
String comparisons involving this function are case-insensitive.
If expression is a number, the number is converted to character string form in an area length bytes long. If the given area is not large enough to hold the converted value, an error results.
Example
Assume that LastName is “Smith “.
$toalpha(LastName,3)
Evaluates to “Smi”.
$toalpha(LastName,12)
Evaluates to “Smith “.
$toalpha(50,2)
Evaluates to “50”.
$toalpha(20+30,19)
Evaluates to ” 50″ (17 leading spaces).
$toalpha(200+300,20)
Evaluates to ” 500″ (17 leading spaces).
$toalpha(500,-2)
Evaluates to ” 500″ (14 leading spaces).
list all Emps format $toalpha(FirstName,6), $toalpha(LastName,9)
Alters the width of values being output with a LIST command.
See Also
$left
$substring
$tochr
$tonumber
$toord
About Character Literals
About Functional Expressions
Conversion Between Data Types
Deletes a portion of a character string.
Syntax
$delete(source,position,length)
Parameters
| source | a character string or an expression that evaluates to a character string |
| position | a number or an expression that evaluates to a number |
| length | a number or an expression that evaluates to a number |
Return Value
Character string, consisting of source, less those characters starting at position, for a length of length.
Comments
In a string, the position of the first character is always 1. If position is beyond the end of source, or if position is zero or negative, then no characters are deleted from source.
If length is zero or negative, then no characters are deleted from source.
If there are fewer than length characters from position to the end of source, then all characters from position to the end of source are deleted.
Example
$delete("abcdef",2,2)Evaluates to “adef”.
$delete("613-555-1234",1,4)Evaluates to “555-1234”.
See Also
$concat
$fill
$insert
$left
$position
$replace
$right
$squeeze
$substring
About Character Literals
About Data Types
About Functional Expressions
Checks whether a given Zim object exists in a Zim directory.
Syntax
$exist$([Zim directory name | Object Owner], object name, object type)
Parameters
| Zim directory name or Object Owner | A character string or an expression that evaluates to a character string, naming the ZIM directory or the object owner to which the object would belong |
| object name | A character string or an expression that evaluates to a character string specifying the object name to be checked in the Zim directory name or within the object owner for its existence |
| object type | A number or an expression that evaluates to a number determining the type of the object name |
Return Value
It returns a $True value if the object name is defined in the Zim directory and is of the specified object type.
It returns a $False value if the object name is not defined in the Zim directory or is not of the specified object type or the Zim directory name is already accessed.
If the object type is 0 (zero), the function will return the object type of the object for subsequent reading of the status of this object (see example).
If the object type is non-zero and the Zim directory name is empty (“”), then the return value is the owning directory name of that object.
Comments
The types of the object are described as the following table:
| Object Type | Meaning |
| 0 | Returns the Object Type |
| 1 | A Null Object |
| 2 | Shadow Directory |
| 3 | Directory |
| 4 | Entity Set |
| 5 | Field |
| 6 | Relationship with no Fields |
| 7 | Relationship with Fields |
| 8 | Set |
| 9 | Document |
| 10 | List |
| 11 | Form |
| 12 | Role |
| 13 | Variable |
| 14 | Display |
| 15 | Virtual Field |
| 16 | CSet |
| 17 | Window |
| 18 | Constant |
| 19 | Menu |
Examples
Check whether the directory “Accounting” is defined in Zim:
$exist$("ZIM", "Accounting", 2)Investigate the type of the object “Customers” in directory Zim and then test whether it exists or not:
let Var = $exist$("ZIM", "Customers", 0)
out $exist$("ZIM", "Customers", Var)