GET_FLDBUF() operator returns the contents of a field or fields in the current form.
field |
the name of the current form field |
program record |
the name of a program record of CHAR and VARCHAR variables in which values from the specified fields can be stored |
screen-array |
the name of a screen array that was declared in the INSTRUCTIONS section of the form specification file |
screen-record |
the name of a screen record that was defined, either explicitly or by implication, in the form specification file |
table-reference |
the unqualified name, alias, synonym, or the FORMONLY keyword that has been declared in the TABLES section of the form specification file |
variable |
one of the comma-separated list of character variables. These variables must be the same, and in the same order, as those specified in the field clause |
GET_FLDBUF() operates on a list of one or more fields. For example, you can use this LET statement to assign the value in the cont_name field to the variable l_cont_name:
LET l_cont_name = GET_FLDBUF(cont_name)
To specify a list of several field names as operands of GET_FLDBUF(), you must use the CALL statement with the RETURNING clause. Put commas between each item in the list of field names and variables:
CALL GET_FLDBUF(cont_id, cont_comp, cont_name)
RETURNING l_cont_id, l_cont_comp, l_cont_name
This statement returns a set of character values which correspond to the contents of the sc_cont screen record and assigns these values to the p_contact program record:
CALL GET_FLDBUF(sc_cont.*) RETURNING p_contact.*
Here the first asterisk (*) works as a wild card that includes all the fields in the sc_cont screen-record; and the second asterisk specifies all the members of the p_contact program record.
You can use GET_FLDBUF() to assist a user when entering a value in a field.
For example, if you have an input field for last names, you can include an ON KEY clause that allows a user to enter the first few characters of the desired last name. If the user calls the ON KEY clause, 4GL displays a list of last names that begin with the entered characters. The user can then choose a last name from the list.
4gl code
MAIN
DEFINE x CHAR(20)
DEFINE y CHAR(20)
LET x = "Sample input data"
OPEN WINDOW w_test
AT 2, 2
WITH FORM "get_fldbuf_operator"
OPTIONS INPUT WRAP
INPUT x WITHOUT DEFAULTS FROM f1
BEFORE INPUT
DISPLAY x TO f2
ON KEY (F2)
LET y = get_fldbuf(f1)
DISPLAY y TO f3
DISPLAY x TO f2
END INPUT
END MAIN
.per form
DATABASE formonly
SCREEN
{
Input Field: Input Variable:
[f1 ] [f2 ]
Field buffer:
[f3 ]
Press (F2) to copy the field buffer.
\gp-----------------------------------------------------------q \g
\g| \gThe get_fldbuf allows you to get the input field contents \g| \g
\g| \gwithout data being written to the input variable \g| \g
\gb-----------------------------------------------------------d \g
}
ATTRIBUTES
f1=formonly.f1,comments="F2 copies the field buffer";
f2=formonly.f2;
f3=formonly.f3;
INSTRUCTIONS
DELIMITERS "[]"
If you assign the character string returned by GET_FLDBUF() to a variable that is not defined as a character data type, 4GL tries to convert this string to the necessary data type. However, this conversion is impossible in two cases:
GET_FLDBUF() is valid only in CONSTRUCT, INPUT, and INPUT ARRAY statements.
When 4GL finds this operator in an INPUT ARRAY statement, it assumes that the current row is being referenced. You cannot use a subscript within brackets to refer to a different row of the screen array.
This example uses GET_FLDBUF() and FIELD_TOUCHED() in an AFTER FIELD clause in the CONSTRUCT statement:
CONSTRUCT BY NAME where clause ON contact.*
...
AFTER FIELD cont_comp
IF FIELD_TOUCHED(cont_comp) THEN LET myint = GET_FLDBUF(cont_comp)
SELECT COUNT(*)
INTO I
FROM company
WHERE company.comp_id = myint
IF SQLCODE = NOTFOUND THEN
ERROR "Company id is not valid"
NEXT FIELD cont_comp
END IF
END IF