Retreiving the value of all web page parameters¶
read_web_values() |
Retreiving the value of all web page parameters |
SYNTAX
read_web_values(record_id)
Read all parameters sent by the web page, and store their values in the temporary record structure specified in record_id.
A temporary record structure is declared by !record, its field list either being explicitly defined within the structure, or copied from that of a file or record already declared. The fields in the record_id specified for this function must have the same names as the parameters on the web page whose values are required. Each value is automatically converted to the type of the corresponding field.
A web page can contain radio buttons, checkboxes, and other control types that have multiple values. In such cases, the corresponding field in record_id should be a single-dimension array, with enough elements to receive all values.
The function returns the number of values stored.
Note
The get_web_value() function stores the values of a single, specified parameter.
To save a web parameter received file the method get_web_file() must be used.
New in version 6.2.0: See the new features.
The nested record and record array features are supported, when reading web parameters a subrecord and indexes can be specified (see example below)
New in version 6.3.0: See the new features.
The character conversion honors the value set in sys.CharSetEncodeFrom and sys.CharSetEncodeTo, so that the string received is supposed to be sys.CharSetEncodeTo encoded while the result is converted into the sys.CharSetEncodeFrom encoding.
EXAMPLES
!record Params {
STOCK,,a40
}
run report rep1
exit
!report rep1 {
!init {
if (get_web_session(session) < -1 ) {
web_redirect(SREP_NAME + "?login"
exit
}
if (read_web_values(Params) != 1 ) {
web_redirect(SREP_NAME + "?login"
exit
}
read stock key=Params.STOCK traps=NOT_FOUND
}
...
NOT_FOUND:
print "<HEAD><TITLE>ERROR PRODUCT '" + STOCK / "' NOT FOUND</TITLE></HEAD>"
print "<BODY><H1>ERROR PRODUCT '" + STOCK / "' NOT FOUND</BODY></HTML>"
exit
Since Sculptor version 6.2.0 when reading web parameters the names can
specify a subrecord and subscripts, like in domain/get.q?subRec[1].nestedFld=1
(in fact the
subRec.nestedFld should be web encoded and the “.” must be translated to %2E). This can be accessed
from nph-srep:
!record request {
!record subRec[3] {
nestedFld,,i4
}
}
/* Get the input parameters */
read_web_values(request)
RELATED TOPICS |