DEFINE

From CometWiki

(Difference between revisions)
Jump to: navigation, search
(New page: '''DEFINE''' '''Syntax:''' DEFINE field-name=expression;length[.precision][,display-length][;title] '''Placement:''' Place the DEFINE command either before or after the REPORT command...)
Line 1: Line 1:
-
'''DEFINE'''  
+
'''DEFINE''' <br>
-
'''Syntax:'''  DEFINE field-name=expression;length[.precision][,display-length][;title]   
+
'''Syntax:'''<br>  
-
'''Placement:'''  Place the DEFINE command either before or after the REPORT command.   
+
DEFINE field-name=expression;length[.precision][,display-length][;title]   
-
'''Discussion:'''  DEFINE allows you to set up a new field name for The Reporter that doesn't already exist (i.e, a virtual field) and assign it to a numeric or string expression based on the fields available to you in The Reporter. The field name can be up to 15 characters long and must be described by the expression that follows the equal sign. The name can contain periods, letters or numbers, but it cannot contain any other characters.  
+
'''Placement:'''<br>  
-
You must define fields for the report before you use the field names with the following commands:
+
Place the DEFINE command either before or after the REPORT command.   
 +
'''Discussion:'''<br>  
 +
DEFINE allows you to set up a new field name for The Reporter that doesn't already exist (i.e, a virtual field) and assign it to a numeric or string expression based on the fields available to you in The Reporter. <br>
 +
The field name can be up to 15 characters long and must be described by the expression that follows the equal sign. <br>
 +
The name can contain periods, letters or numbers, but it cannot contain any other characters.<br>
 +
You must define fields for the report before you use the field names with the following commands:<br>
 +
 
* '''[[BREAK]]'''
* '''[[BREAK]]'''
* '''[[PRINT]]'''
* '''[[PRINT]]'''
Line 9: Line 15:
* '''[[TOTAL]]'''  
* '''[[TOTAL]]'''  
-
The expression can be constants, fields, operators, or functions that work alone or are combined to yield a string or numeric value. All MTB operators and functions are supported. Hex constants are also supported.  
+
The expression can be constants, fields, operators, or functions that work alone or are combined to yield a string or numeric value. <br>
 +
All MTB operators and functions are supported. Hex constants are also supported.  
-
The length.precision parameter gives the field's length in characters (or digits) and the decimal place precision. The number to the left of the period represents the total length of the field, and the number to the right of the period represents the number of decimal places included in the number. Do not specify a precision if the field represents a string.  
+
The length.precision parameter gives the field's length in characters (or digits) and the decimal place precision.<br>
 +
The number to the left of the period represents the total length of the field, and the number to the right of the period represents the number of decimal places included in the number. <br>
 +
Do not specify a precision if the field represents a string.  
-
The display-length parameter overrides the column width calculation and defines the number of characters to display. This can be very useful when defining an HTML hyperlink that will be displayed in a web browser (see Example 2).  
+
The display-length parameter overrides the column width calculation and defines the number of characters to display. <br>
 +
This can be very useful when defining an HTML hyperlink that will be displayed in a web browser (see Example 2).  
-
You can specify a title to print above a new column you are defining. If you do not specify a title, the field-name will be printed above the column.  
+
You can specify a title to print above a new column you are defining<br>.  
 +
If you do not specify a title, the field-name will be printed above the column.  
-
Line continuation  
+
'''Line continuation'''
To continue a DEFINE command to the next line, use an "_" character anywhere it would be allowed by the MTB compiler in your expression, but not before the "=".  
To continue a DEFINE command to the next line, use an "_" character anywhere it would be allowed by the MTB compiler in your expression, but not before the "=".  
   
   
-
History:  The display-length parameter was added in version 01.01.
+
'''History:''' <br>
-
Example 1:  100   INPUT CUSTOMER
+
The display-length parameter was added in version 01.01. <br>
-
200   TITLE PAST.DUE.ACCOUNTS
+
'''Example 1:''' <br>
-
300  DEFINE PAST.DUE = AR.OVER.60 + AR.OVER.90;8.2;PAST DUE
+
   100    INPUT CUSTOMER
-
400  SELECTING IF PAST.DUE GT 0
+
   200    TITLE PAST.DUE.ACCOUNTS
-
500  SORT ON STATE;CUST.NAME
+
  300  DEFINE PAST.DUE = AR.OVER.60 + AR.OVER.90;8.2;PAST DUE
-
600  REPORT
+
  400  SELECTING IF PAST.DUE GT 0
-
700  USING CUST.TO.HIST
+
  500  SORT ON STATE;CUST.NAME
-
800  PRINT CUST.NAME;CUST.NUMBER;STATE;PREVIOUS.YTD;PAST.DUE
+
  600  REPORT
-
900  BREAK ON STATE
+
  700  USING CUST.TO.HIST
-
1000  TOTAL PAST.DUE;PREVIOUS.YTD
+
  800  PRINT CUST.NAME;CUST.NUMBER;STATE;PREVIOUS.YTD;PAST.DUE
-
1100  END
+
  900  BREAK ON STATE
 +
1000  TOTAL PAST.DUE;PREVIOUS.YTD
 +
1100  END
In this example, the DEFINE command on line 300 creates a new field named PAST.DUE, which is the sum of two existing fields (AR.OVER.60 and AR.OVER.90). The field length/precision is 8.2, and the field title is PAST DUE.   
In this example, the DEFINE command on line 300 creates a new field named PAST.DUE, which is the sum of two existing fields (AR.OVER.60 and AR.OVER.90). The field length/precision is 8.2, and the field title is PAST DUE.   

Revision as of 08:56, 6 June 2009

DEFINE
Syntax:
DEFINE field-name=expression;length[.precision][,display-length][;title] Placement:
Place the DEFINE command either before or after the REPORT command. Discussion:
DEFINE allows you to set up a new field name for The Reporter that doesn't already exist (i.e, a virtual field) and assign it to a numeric or string expression based on the fields available to you in The Reporter.
The field name can be up to 15 characters long and must be described by the expression that follows the equal sign.
The name can contain periods, letters or numbers, but it cannot contain any other characters.
You must define fields for the report before you use the field names with the following commands:

The expression can be constants, fields, operators, or functions that work alone or are combined to yield a string or numeric value.
All MTB operators and functions are supported. Hex constants are also supported.

The length.precision parameter gives the field's length in characters (or digits) and the decimal place precision.
The number to the left of the period represents the total length of the field, and the number to the right of the period represents the number of decimal places included in the number.
Do not specify a precision if the field represents a string.

The display-length parameter overrides the column width calculation and defines the number of characters to display.
This can be very useful when defining an HTML hyperlink that will be displayed in a web browser (see Example 2).

You can specify a title to print above a new column you are defining
. If you do not specify a title, the field-name will be printed above the column.

Line continuation

To continue a DEFINE command to the next line, use an "_" character anywhere it would be allowed by the MTB compiler in your expression, but not before the "=".

History:
The display-length parameter was added in version 01.01.
Example 1:

 100    INPUT CUSTOMER
 200    TITLE PAST.DUE.ACCOUNTS
 300   DEFINE PAST.DUE = AR.OVER.60 + AR.OVER.90;8.2;PAST DUE
 400   SELECTING IF PAST.DUE GT 0
 500   SORT ON STATE;CUST.NAME
 600   REPORT
 700   USING CUST.TO.HIST
 800   PRINT CUST.NAME;CUST.NUMBER;STATE;PREVIOUS.YTD;PAST.DUE
 900   BREAK ON STATE
1000  TOTAL PAST.DUE;PREVIOUS.YTD
1100  END

In this example, the DEFINE command on line 300 creates a new field named PAST.DUE, which is the sum of two existing fields (AR.OVER.60 and AR.OVER.90). The field length/precision is 8.2, and the field title is PAST DUE. Example 2: There are HTML commands which require long MTB strings of data but which are then reduced considerably by the browser. An example of this is <a href> tag, which doesn't actually display the hyperlink address, just the text associated with it. For example:

DEFINE X='<a href="http://...">'+"CLICK HERE</a>";40,10

In this example, the length of 40 represents the length of the MTB variable, X, and the override length of 10 represents the number of spaces required to display "CLICK HERE" in the browser. Without the length override, the Reporter would force the column width to be wide enough to accommodate the entire X string.

Personal tools