AppendWebData (Stringlist subroutine)

From m204wiki
Jump to navigation Jump to search

Add Janus Web upload data to a Stringlist (Stringlist class)

[Introduced in Sirius Mods 8.1]

This method adds lines from a web form PUT or POST to the end of a Stringlist.

Syntax

sl:AppendWebData[( [formFieldName= string], [formFieldOccurrence= number], - [options= string])] Throws FormFieldNotFound

Syntax terms

sl A Stringlist object.
formFieldName This name required parameter indicates the name of the form field from which the content is to be extracted. If not specified, all form fields are examined and the form field number indicated by the formFieldOccurrence parameter will be used.

When processing an HTTP PUT, formFieldName should not be specified.

formFieldOccurrence This name required parameter indicates the form field number if no formFieldName is specified, or the occurrence number of the field with the specified name, otherwise. This default value of this argument is 1.

When processing an HTTP PUT, this value must be 1 or not specified.

options This name required parameter indicates how the data should be converted before being placed on the Stringlist. This parameter is optional and defaults to 'TEXT'. Valid values are:
BINARY Janus Web Server performs no ASCII to EBCDIC translation on the contents and converts the data to the special Janus Web Server format binary Stringlist.
BASE64 Janus Web Server performs no ASCII to EBCDIC translation on the contents and converts the data to the special Janus Web Server format base64 encoded Stringlist.
TEXT Janus Web Server translates the data from ASCII to EBCDIC, separating the text into list items at any point where an ASCII carriage return (X'0D') or carriage return and line feed (X'0A') are found.

Usage notes

  • This method is a object-oriented alternative to the $Web_List_Recv function.
  • The stringlist created when 'BINARY' or 'BASE64' is specified for options can be converted to a longstring with the BinaryProcedureDecode function.
  • For POST data, the post must have been done using multipart/form-data encoding. This is indicated by specifying enctype=multipart/form-data on the <form> element if the post is done from an HTML form. For more information see Forms in HTML Documents.

Examples

The following example takes the lines from a file uploaded via a form POST and stores the individual lines into a Model 204 record. Note that generally upload file content would be better stored in LOB fields.

%stringlist is object stringlist ... %ipaddr = $web_IPAddr %time = $web_datens %filename = $web_form_parm('FILE') %stringlist = new %stringlist:appendWebData(formFieldname='FILE', options='TEXT') in file upload store record ipaddr = %ipaddr time = %time filename = %filename then continue for %i from 1 to %stringlist:count add line = %stringlist(%i) end for end store

See also