This command is used to 'create' a field that will be used only within the current program (or subsequent programs that are called from this program). This is not a field that is part of a record in a standard TAS Professional file.
DEFINE sac1,sac2,...sacx Required - The name or names of the field(s) being defined. Must conform to standard field name requirements. You may define a maximum of 10 fields in one DEFINE command. Each of the fields will have the same specifications.
TYPE sac | The type of the field being added. Must conform to standard field type requirements. If you don't specify a field type, the default value is N. The field name types are listed here. |
SIZE snc | The display size of the field being added. Must conform to standard field display size requirements. If this is not included, then the default size value for the type of field is used. |
NOTE: If the field is type A or V you must supply a value. V (overlay) type fields are treated internally as A type fields so you must supply a size for these also. Internally, the overlay field will start with the next field in the list and continue for the number of characters specified. See further information about the overlay field in COMMENTS below.
DEC snc | If the field is of type N you can specify the number of decimal characters. If this isn't included the default value is 0. This could affect the displayed value of the field or the ability to ENTER the correct value. Therefore you should take great care to make sure the proper value is used. The available range is 0 through 8. |
ARRAY snc | The number of array elements for this field. Default value is 0. |
UP | If this is a type A field you may specify whether all characters entered to it are to be automatically forced into upper case. To accomplish this include this option. |
RESET | If this option is part of this command the program will try to match the fieldname up with the identical name in the previous program, if any. If it matches it will be reset to the specifications for the field in the previous program. This means that you can use that data in the new program just as though it was there normally. When you're done, and you return to the previous program any changes made to that data are still there. This is an alternative to using the WITH option in the CHAIN command and the PARAM command in the subsequent program. If the field cannot be found in the previous program, or there is no previous program, the field is treated like a normal field within that program. It is initialized and can be used, if desired. |
This feature allows you to base certain options in subsequent programs on whether or not the data is there to use it and still not have to worry about what it's going to do if you come at the program a different way. This option is used in all TAS Professional programs to pass color values from program to program so that the TASCOLOR.OVL file needs to be read only once.
If you know you're not going to use a field unless it is 'reset' to a field in the previous program you can define it as any type and size you want. For example, if you want to access a very large array in a previous program and won't use the field at all if it isn't there you should define the field as an A type size 1. If it is blank (or SIZE(fld_name,'d')=1) you will know that you didn't reach this program from a previous one, or at least from the one that was passing the data. Of course, there are other ways to find that out, including passing info about the previous field with the PARAM command. Using this approach, you can avoid taking data space in the current program that will go unused since you are accessing data in the previous program instead. It doesn't matter what type or size you specify for the subsequent field. It will always be changed to the specs of the original field if the RESET option is active.
LOCAL | If this option is included in the command then the program adds the procedure number to the field information. Through the use of this option and the PROC/ENDP compiler directives you can have multiple routines with the same field names and not worry about whether or not you overwriting some other data belonging to another field. The scope of a LOCAL field is limited to the boundaries of the routine in which it appears. |
The key to this whole process is to make sure the routine this field applies to has the PROC directive at the beginning (before the field is defined) and the ENDP directive at the very end (after the last RET command that applies to this routine).
INIT c1,c2,c3,. . ., cx This option will initialize the defined field to these values. Specify on the command line what values you want the defined field to be set to when the program is run. The values must be constants; other fields and expressions are not allowed. You can initialize A, N, B, I, R, D, and T type fields. Please note that P and F type fields cannot be initialized using this option. IF YOU USE THIS OPTION, IT SHOULD BE THE LAST THING ON THE COMMAND LINE. The option must appear after the type, size, and number of array elements have been specified. If you are defining an array field, you may initialize each element separately. Do this by using a list of constants, with each constant being the correct type. The program will initialize the array field starting with element 1 and going until it runs out of values. If you put more values on the line than array elements, you will get an error during compilation. These values are actually set at the time the program is started, so you can put your DEFINEs anywhere in your program, and the values will not be reset just by running over the original DEFINE command.
NOTE: 'A' type constants should be specified without surrounding quotes. 'D' and 'T' type constants do need quotes. For example:
//The following shows a non-array A type field with an INIT value
DEFINE TEST type A size 10 init ABCDEFG
//This is a D type array field with an INIT value
DEFINE DATE_FLD type D size 8 array 2 init '01/01/94' , '02/01/94'
No other field types need surrounding quotes.
VALUE f/c/e | This option may be used with any valid type. This option was created especially for the TTASDataGrid columns, however, it can be used anywhere. When you specify the FieldName for the column you cannot use an expression. By using this option you can use any legal expression instead of a regular field. For example, you might use this as follows: |
DEFINE xyz TYPE A SIZE 20 VALUE x+y+z
The expression can also include functions, either built in to TAS Professional or UDF type. See Wlistf for Example
NOTE: This would also be used in older TAS Professional program (DOS version) where you may have specified an expression as a display or print only value in a screen/report form. In those case you would replace the expression in the screen/report format with a defined field. Then, in the VALUE option of that field you would put the expression that was a part of the format.
DUP sac | Use this option to define this field to the same specs as a field in the Data Dictionary (FILEDICT). You would use the field name as the sac value. For example: |
DEFINE xyz DUP dict_buff_name
In this case the field 'xyz' would be defined to be type a, size 8, without any further options in the DEFINE command. Note that you don't put any quote marks around the DUP field name. Also, you cannot use a function or expression, it must be the actual field name that exists in FILEDICT.
COMMENTS
Generally, if multiple fields are defined using the same command the fields will follow sequentially in memory. However, this is not always the case. When the field is encountered in the program the first time it is put in the program's field list. If you are using defined field overlays and you want to make sure that all the fields in the block are together you should define them at the beginning of the program before any reference is made to any of the fields in the block.
DEFINE commands are not actually executed anywhere in the program. There are used simply for creating fields that will be used within that program.
If a field is not a part of the regular file dictionary or the define field dictionary it must be explicitly defined using this command somewhere in the program.
NOTE: You can also enter fields into the Defined Field file (FILEDFLD.DBF). Use the Maintain Defined Fields program to add, change and delete fields from this file. Once a field has been entered into this file it can be used in any program, just as though it were defined in that program.
EXAMPLE
DEFINE TODAYS_DATE Type D Size 8 Local
DEFINE TOTAL Type N Size 10 Dec 2
DEFINE NEWTOT Type N Size 10 Dec 2 Value Find_fld()
DEFINE xyz DUP dict_buff_name
DEFINE TOTAL_A Type N Size 10 Dec 2 RESET
SEE ALSO
Page url: http://www.cassoftware.com/tas/manual/definefield.htm