CAPÍTULO I: PROBLEMA DE INVESTIGACIÓN
2.2. Antecedentes
2.2.2. Antecedentes Nacionales
Purpose: Initializes a table on the teach pendant
Syntax : INIT_TBL(dict_name, ele_number, num_rows, num_columns, col_data, inact_array, change_array, value_array, vptr_array, table_data, status)
Input/Output Parameters: [in] dict_name :STRING [in] ele_number :INTEGER [in] num_rows :INTEGER [in] num_columns :INTEGER
[in] col_data :ARRAY OF COL_DESC_T [in] inact_array :ARRAY OF BOOLEAN
[in] change_array :ARRAY OF ARRAY OF BOOLEAN [in] value_array :ARRAY OF STRING
[out] vptr_array :ARRAY OF ARRAY OF INTEGER [in,out] table_data :XWORK_T
[out] status :INTEGER
%ENVIRONMENT Group :UIF Details:
INIT_TBL must be called before using the ACT_TBL built-in.INIT_TBL does not need to be called if using the DISCTRL_TBL built-in.
The INIT_TBL and ACT_TBL built-in routines should only be used instead of
DISCTRL_TBL is special processing needs to be done with each keystroke or if function key processing needs to be done without exiting the table menu.
PROGRAM init_queue_x %environment PBQMGR VAR
job_queue FROM globals: QUEUE_TYPE BEGIN
INIT_QUEUE(job_queue) END init_queue_x
dict_name is the four-character name of the dictionary containing the table header. ele_number is the element number of the table header.
num_rows is the number of rows in the table.
num_columns is the number of columns in the table.
col_data is an array of column descriptor structures, one for each column in the table. It contains the following fields:
item_type : Data type of values in this column. The following data type constants are defined:
TPX_INT_ITEM -- Integer type TPX_REL_ITEM -- Real type
TPX_FKY_ITEM -- Function key enumeration type TPX_SUB_ITEM -- Subwindow enumeration type TPX_KST_ITEM -- KAREL string type
TPX_KSL_ITEM -- KAREL string label type (can select, not edit) TPX_KBL_ITEM -- KAREL boolean type
TPX_BYT_ITEM -- Byte type TPX_SHT_ITEM -- Short type
TPX_PBL_ITEM -- Port boolean type TPX_PIN_ITEM -- Port integer type
start_col : Starting character column (1..40) of the display field for this data column.
field_width : Width of the display field for this data column.
num_ele : Dictionary element used to display values for certain data types. The format of the dictionary elements for these data types are as follows:
TPX_FKY_ITEM: The enumerated values are placed on function key labels. There can be up to 2 pages of function key labels, for a maximum of 10 labels. Each label is a string of up to 8 characters. However, the last
character of a label which is followed by another label should be left blank or the two labels will run together.
A single dictionary element defines all of the label values. Each value must be put on a separate line using &new_line. The values are assigned to the function keys F1..F5, F6..F10 and the numeric values 1..10 in sequence. Unlabeled function keys should be left blank. If there are any labels on the second function key page, F6..F10, the labels for keys 5 and 10 must have the character ``>'' in column 8. If there are no labels on keys F6..F10, lines do not have to be specified for any key label after the last non-blank label. Example:
-- TPX_SUB_ITEM: The enumerated values are selected from a subwindow on the display device. There can be up to 5 subwindow pages, for a
maximum of 35 values. Each value is a string of up to 16 characters. A sequence of consecutive dictionary elements, starting with enum_dict,
define the values. Each value must be put in a separate element, and must not end with &new_line. The character are assigned the numeric values 1..35 in sequence. The last dictionary element must be "\a".
Example:
TPX_KBL_ITEM, TPX_PBL_ITEM: The ``true'' and ``false'' values are placed on function key labels F4 and F5, in that order. Each label is a string of up to 8 characters. However, the last character of the ``true'' label should be left blank or the two labels will run together.
A single dictionary element the label values. Each value must be put on a separate line using &new_line, with the ``false'' value first.
Example: $ example_fkey_label_c "" &new_line "F2" &new_line "F3" &new_line "F4" &new_line "F5 >" &new_line "F6" &new_line "F7" &new_line "" &new_line "" &new_line " >" $ example_sub_win_enum_c "Red" $ "Blue" $ "Green" $ "Yellow" $ "\a"
enum_dict : Dictionary name used to display data types TPX_FKY_ITEM, TPX_SUB_ITEM, TPX_KBL_ITEM, or TPX_PBL_ITEM
format_spec : Format string is used to print out the data value. The format string contains a format specifier. The format string can also contain any desired characters before or after the format specifier. The format specifier itself begins with a % and ends with a conversion character. Between the % and the
conversion character there may be, in order:
Flags (in any order), which modify the specification: - : specifies left adjustment of this field.
+ : specifies that the number will always be printed with a sign. space : if the first character is not a sign, a space will be prefixed. 0 : specifies padding a numeric field width with leading zeroes.
A number that specifies the minimum field width. The converted argument will be printed in a field at least this wide. If necessary it will be padded on the left (or right, if left adjustment is called for) to make up the field width. A period, which separates the field width from the precision.
A number, the precision, that specifies the maximum number of characters to be printed from a string, or the number of digits after the decimal point of a floating-point value, or the minimum number of digits for an integer.
The format specifier must contain one of the conversion characters in the following table:
Table A.13. Conversion Characters
$ example_boolean_c "OFF" &new_line "ON"
Character Argument Type; Printed As d INTEGER; decimal number.
o INTEGER; unsigned octal notation (without a leading zero).
x,X INTEGER; unsigned hexadecimal notation (without a leading 0x or 0X), using abcdef or ABCDEF for 10, ..., 15.
u INTEGER; unsigned decimal notation.
s STRING; print characters from the string until end of string or the number of characters given by the precision.
Example: "%d" or "%-10s"
The format specifiers which can be used with the data types specified in the item_type field in col_data are as follows:
TPX_INT_ITEM %d, %o, %x, %X, %u TPX_REL_ITEM %f, %e, %E, %g, %G TPX_FKY_ITEM %s
TPX_SUB_ITEM %s TPX_KST_ITEM %s TPX_KSL_ITEM %s TPX_KBL_ITEM %s
TPX_BYT_ITEM %d, %o, %x, %X, %u, %c TPX_SHT_ITEM %d, %o, %x, %X, %u TPX_PBL_ITEM %s
TPX_PIN_ITEM %d, %o, %x, %X, %u
max_integer : Maximum value if data type is TPX_INT_ITEM, TPX_BYT_ITEM, or TPX_SHT_ITEM.
min_integer : Minimum value if data type is TPX_INT_ITEM, TPX_BYT_ITEM, or TPX_SHT_ITEM.
max_real : Maximum value for reals. min_real : Minimum value for reals.
clear_flag : If data type is TPX_KST_ITEM, 1 causes the field to be cleared before f d's is given by the precision. The default precision is 6; a precision of 0
suppresses the decimal point. e,E
REAL; decimal notation of the form [-]m.dddddde+-xx or [-]m.ddddddE+-xx, where the number of d's is given by the precision. The default precision is 6; a precision of 0
g,G
REAL; %e or %E is used if the exponent is less than -4 or greater than or equal to the precision; otherwise %f is used. Trailing zeros and a trailing decimal pointer are not printed.
lower_case : If data type is TPX_KST_ITEM, 1 allows the characters to be input to the string in upper or lower case and 0 restricts them to upper case.
inact_array is an array of booleans that corresponds to each column in the table. You can set each boolean to TRUE which will make that column inactive. This
means the column cannot be cursored to.
The array size can be less than or greater than the number of items in the table. If inact_array is not used, then an array size of 1 can be used, and the array does
not need to be initialized.
change_array is a two dimensional array of booleans that corresponds to formatted data item in the table.
If the corresponding value is set, then the boolean will be set to TRUE, otherwise it is set to FALSE. You do not need to initialize the array.
The array size can be less than or greater than the number of data items in the table.
If change_array is not used, then an array size of 1 can be used.
value_array is an array of variable names that correspond to the columns of data in the table. Each variable name can be specified as '[prog_name]var_name'.
[prog_name] specifies the name of the program that contains the specified
variable. If [prog_name] is not specified, then the current program being executed is used.
var_name must refer to a static, global program variable.
var_name can contain node numbers, field names, and/or subscripts.
Each of these named variables must be a KAREL array of length num_rows . Its data type and values should be consistent with the value of the item_type field in col_data for the corresponding column, as follows:
TPX_INT_ITEM: ARRAY OF INTEGER containing the desired values. TPX_REL_ITEM: ARRAY OF REAL containing the desired values.
TPX_FKY_ITEM: ARRAY OF INTEGER with values referring to items in the dictionary element specified in the enum_ele field in col_data. There can be at most 2 function key pages, or 10 possible function key enumeration values.
TPX_SUB_ITEM: ARRAY OF INTEGER with values referring to items in the dictionary element specified in the enum_ele field in col_data . There can be at most 28 subwindow enumeration values.
TPX_KST_ITEM: ARRAY OF STRING containing the desired values. TPX_KST_ITEM: ARRAY OF STRING containing the desired values.
TPX_KSL_ITEM: ARRAY OF STRING containing the desired values. These values cannot be edited by the user. If one is selected, ACT_TBL will return. TPX_KBL_ITEM: ARRAY OF BOOLEAN containing the desired values. The dictionary element specified by the enum_ele field in col_data should have exactly two elements, with the false item first and the true item second. TPX_BYT_ITEM: ARRAY OF BYTE containing the desired values. "--" TPX_SHT_ITEM: ARRAY OF SHORT containing the desired values. "--" TPX_PBL_ITEM: ARRAY OF STRING containing the names of the ports, for example ``DIN[5]''. "--" TPX_PIN_ITEM: ARRAY OF STRING containing the names of the ports, for example ``GOUT[3]''.
TPX_BYT_ITEM: ARRAY OF BYTE containing the desired values. TPX_SHT_ITEM: ARRAY OF SHORT containing the desired values.
TPX_PBL_ITEM: ARRAY OF STRING containing the names of the ports, for example ``DIN[5]''.
TPX_PIN_ITEM: ARRAY OF STRING containing the names of the ports, for example ``GOUT[3]''.
vptr_array is an array of integers that corresponds to each variable name in value_array. Do not change this data; it is used internally.
table_data is used to display and control the table. Do not change this data; it is used internally.
status explains the status of the attempted operation. If not equal to 0, then an error occurred.
Example: In this example, TPXTABEG.TX is loaded as `XTAB' on the controller. TPEXTBL calls INIT_TBL to initialize a table with five columns and four rows. It calls ACT_TBL in a loop to read and process each key pressed.
--- TPXTABEG.TX
--- $title
&reverse "DATA Test Schedule" &standard &new_line "E1: " &new_line " W(mm) TEST C(%%) G(123456) COLOR" ^1 ?2 $function_keys "f1" &new_line "f2" &new_line "f3" &new_line "f4" &new_line " HELP >" &new_line "f6" &new_line "f7" &new_line "f8" &new_line "f9" &new_line "f10 >"
$help_text "Help text goes here... "$enum1 "" &new_line "" &new_line "TRUE" &new_line "FALSE" &new_line "" $enum2 "Red" $ "Blue" $ "Green" $ "Yellow" $ "Brown" $ "Pink" $ "Mauve" $ "Black" $ "..." --- TPEXTBL.KL --- PROGRAM tpextbl %ENVIRONMENT uif %INCLUDE FROM:\klevccdf %INCLUDE FROM:\klevkeysVAR dict_name: STRING[6] ele_number: INTEGER num_rows: INTEGER num_columns: INTEGER
col_data: ARRAY[5] OF COL_DESC_T inact_array: ARRAY[5] OF BOOLEAN change_array: ARRAY[4,5] OF BOOLEAN
vptr_array: ARRAY[4,5] OF INTEGER table_data: XWORK_T status: INTEGER action: INTEGER def_item: INTEGER term_char: INTEGER attach_sw: BOOLEAN save_action: INTEGER done: BOOLEAN
value1: ARRAY[4] OF INTEGER value2: ARRAY[4] OF INTEGER value3: ARRAY[4] OF REAL
value4: ARRAY[4] OF STRING[10] value5: ARRAY[4] OF INTEGER BEGIN def_item = 1 value_array[1] = 'value1' value_array[2] = 'value2' value_array[3] = 'value3' value_array[4] = 'value4' value_array[5] = 'value5' value1[1] = 21 value1[2] = 16 value1[3] = 1 value1[4] = 4 value2[1] = 3 value2[2] = 2 value2[3] = 3 value2[4] = 2 value3[1] = -13 value3[2] = 4.1 value3[3] = 23.9 value3[4] = -41 value4[1] = 'XXX---' value4[2] = '--X-X-' value4[3] = 'XXX-XX' value4[4] = '-X-X--' value5[1] = 1 value5[2] = 1 value5[3] = 2 value5[4] = 3 inact_array[1] = FALSE inact_array[2] = FALSE inact_array[3] = FALSE inact_array[4] = FALSE inact_array[5] = FALSE col_data[1].item_type = TPX_INT_ITEM col_data[1].start_col = 6 col_data[1].field_width = 4 col_data[1].format_spec = '%3d' col_data[1].max_integer = 99 col_data[1].min_integer = -99 col_data[2].item_type = TPX_FKY_ITEM col_data[2].start_col = 12
col_data[2].format_spec = '%s'
col_data[2].enum_ele = 3 -- enum1 element number col_data[2].enum_dict = 'XTAB' col_data[3].item_type = TPX_REL_ITEM col_data[3].start_col = 18 col_data[3].field_width = 5 col_data[3].format_spec = '%3.1f' col_data[4].item_type = TPX_KST_ITEM col_data[4].start_col = 26 col_data[4].field_width = 6 col_data[4].format_spec = '%s' col_data[5].item_type = TPX_SUB_ITEM col_data[5].start_col = 34 col_data[5].field_width = 6 col_data[5].format_spec = '%s'
col_data[5].enum_ele = 4 -- enum2 element number col_data[5].enum_dict = 'XTAB'
dict_name = 'XTAB'
ele_number = 0 -- title element number num_rows = 4
num_columns = 5 def_item = 1 attach_sw = TRUE
INIT_TBL(dict_name, ele_number, num_rows, num_columns, col_data, inact_array, change_array, value_array, vptr_array, table_data, status)
IF status <> 0 THEN
WRITE('INIT_TBL status = ', status, CR); ELSE
def_item = 1
-- Initial display of table
ACT_TBL(ky_disp_updt, def_item, table_data, term_char, attach_sw, status)
IF status <> 0 THEN
WRITE(CR, 'ACT_TBL status = ', status) ENDIF
ENDIF
IF status = 0 THEN
-- Loop until a termination key is selected. done = FALSE
action = ky_reissue -- read new key WHILE NOT done DO
-- Read new key, act on it, and return it
ACT_TBL(action, def_item, table_data, term_char, attach_sw, status)save_action = action action = ky_reissue -- read new key
-- Debug only
WRITE TPERROR (CHR(cc_home) + CHR(cc_clear_win)) -- Process termination keys.
SELECT (term_char) OF
CASE (ky_select, ky_new_menu): done = TRUE;
CASE (ky_f1): -- Perform F1