version 6.0
DR INSERT EXPRESSION (area; scope; first; last; expression{; format})
| Parameter | Type | Description | |
| area | Longint | 4D Draw area | |
| scope | Longint | -1 = All, 0 = Selected, >0 = Object ID | |
| first | Integer | Position of first character minus 1 | |
| last | Integer | Position of last character | |
| expression | String | Expression | |
| format | String | Format of expression |
Description
The command DR INSERT EXPRESSION inserts a reference to expression into the text object in area described by scope.
If scope equals -1, DR INSERT EXPRESSION inserts the reference into the first object of the document.
If scope equals 0, the command inserts the reference into the first selected object.
If scope is greater than 0, it must be equal to a specific text object's ID; the command inserts the reference within that text object. If the object does not exist, DR INSERT EXPRESSION does nothing, and DR Error returns error number 2.
If the object described by scope is not a text object, DR INSERT EXPRESSION does nothing, and DR Error returns error number 47.
first and last determine where the reference is inserted. first is one less than the first character position to be replaced and last is the last character position to be replaced. If first equals last, the command does not replace characters, and inserts the reference between first and first +1. If last is greater than the number of characters in the text object, DR INSERT EXPRESSION replaces characters from first to the end.
expression is the text equivalent of any valid 4th Dimension expression that returns a value. expression can be a reference to any of the following: a field, a variable, a 4th Dimension function, a user-defined function (project method), an external function, or a statement.
The following table gives examples for each expression type.
| Example | Type |
| [Drawings]Object | Field |
| vCriteria | Variable |
| Current date | 4th Dimension function |
| GetNum | User defined function (project method) |
| DR Count | 4D Draw function |
| 3 * "Hello" | Statement |
The optional format parameter is the display format for the reference. This parameter is equivalent to choosing a format from the Format dialog box. Formats are referred to either by number or name; they are numbered in the order in which they appear in the list of the Format dialog box.
If format is a one or two digit string, then a format from the list is applied to expression. If format is not a one or two digit string, then it is compared against the text values of each format in the list. If it matches one of the values in the list, that format is applied. This means that you can refer to the first date format as either "19" or "Short".
If format is not in the list of formats, it is interpreted as a custom numeric format. If format is inappropriate for the resulting value of the reference, it is ignored. For instance, if you use a date format on a number, the number appears unformatted.
Example
The following example creates a new text object, fills it with a reference to the 4th Dimension function Current date and formats it using the Long date format.
$ID := DR Draw text (Area;0.5;0.5;3.5;1;"Todays date is: ") DR INSERT EXPRESSION (Area;$ID;32000;32000;"Current date";"Long")
See Also