AppendWebData (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
No edit summary
m (minor formatting)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:Stringlist:AppendWebData subtitle}}
{{Template:Stringlist:AppendWebData subtitle}}
This method adds lines from a web form [http://en.wikipedia.org/wiki/PUT_(HTTP) PUT] or [http://en.wikipedia.org/wiki/POST_(HTTP) POST] to the end of a <var>Stringlist</var>.
This method adds lines from a web form [http://en.wikipedia.org/wiki/PUT_(HTTP) PUT] or [http://en.wikipedia.org/wiki/POST_(HTTP) POST] to the end of a <var>Stringlist</var>.
==Syntax==
==Syntax==
{{Template:Stringlist:AppendWebData syntax}}
{{Template:Stringlist:AppendWebData syntax}}
===Syntax terms===
===Syntax terms===
<table class="syntaxTable">
<table>
<tr><th>sl</th>
<tr><th>sl</th>
<td>Stringlist object</td></tr>
<td>A <var>Stringlist</var> object.</td></tr>
 
<tr><th><var>formFieldName</var></th>
<tr><th><var>formFieldName</var></th>
<td>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 <var>formFieldOccurrence</var> parameter will be used. When processing an HTTP PUT, <var>formFieldName</var> should not be specified.</td></tr>
<td>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 <var>formFieldOccurrence</var> parameter will be used.  
<p>
When processing an HTTP PUT, <var>formFieldName</var> should not be specified.</p></td></tr>
 
<tr><th><var>formFieldOccurrence</var></th>
<tr><th><var>formFieldOccurrence</var></th>
<td>This name required parameter indicates the form field number if no <var>formFieldName</var> 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 either 1 or not specified.</td></tr>
<td>This name required parameter indicates the form field number if no <var>formFieldName</var> is specified, or the occurrence number of the field with the specified name, otherwise. This default value of this argument is 1.  
<p>
When processing an HTTP PUT, this value must be 1 or not specified.</p></td></tr>
 
<tr><th><var>options</var></th>
<tr><th><var>options</var></th>
<td>This name required parameter indicates how the data should be converted before being placed on the stringlist. This parameter is optional and defaults to <code>'TEXT'</code>. Valid values are:
<td>This name required parameter indicates how the data should be converted before being placed on the <var>Stringlist</var>. This parameter is optional and defaults to <code>'TEXT'</code>. Valid values are:
 
<table class="syntaxTable">
<table class="syntaxTable">
<tr><th><var>BINARY</var></th>
<tr><th><var>BINARY</var></th>
<td><var class="product">[[Janus Web Server]]</var> performs no ASCII to EBCDIC translation on the contents and converts the data to the special <var class="product">Janus Web Server</var> format binary stringlistlist.</td></tr>
<td><var class="product">[[Janus Web Server]]</var> performs no ASCII to EBCDIC translation on the contents and converts the data to the special <var class="product">Janus Web Server</var> format binary <var>Stringlist</var>.</td></tr>
 
<tr><th><var>BASE64</var></th>
<tr><th><var>BASE64</var></th>
<td><var class="product">Janus Web Server</var> performs no ASCII to EBCDIC translation on the contents and converts the data to the special <var class="product">Janus Web Server</var> format base64 encoded stringlist.</td></tr>
<td><var class="product">Janus Web Server</var> performs no ASCII to EBCDIC translation on the contents and converts the data to the special <var class="product">Janus Web Server</var> format base64 encoded <var>Stringlist</var>.</td></tr>
 
<tr><th><var>TEXT</var></th>
<tr><th><var>TEXT</var></th>
<td><var class="product">Janus Web Server</var> 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.</td></tr>
<td><var class="product">Janus Web Server</var> 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.</td></tr>
Line 23: Line 35:
</td></tr>
</td></tr>
</table>
</table>
==Usage notes==
==Usage notes==
<ul>
<ul>
<li>This method is a object-oriented alternative to the [[$Web_List_Recv]] function.</li>
<li>This method is a object-oriented alternative to the <var>[[$Web List Receive or $Web List Recv|$Web_List_Recv]]</var> function.</li>
<li>The stringlist created when <code>'BINARY'</code> or <code>'BASE64'</code> is specified for <var>options</var> can be converted to a longstring with the [[BinaryProcedureDecode (Stringlist function)|BinaryProcedureDecode function]].</li>  
 
<li>The stringlist created when <code>'BINARY'</code> or <code>'BASE64'</code> is specified for <var>options</var> can be converted to a longstring with the <var>[[BinaryProcedureDecode (Stringlist function)|BinaryProcedureDecode]]</var> function.</li>  
 
<li>For POST data, the post must have been done using <var>multipart/form-data</var> encoding. This is indicated by specifying <code>enctype=multipart/form-data</code> on the <code>&lt;form&gt;</code> element if the post is done from an HTML form. For more information see [http://www.w3.org/TR/html401/interact/forms.html Forms in HTML Documents].</li>
<li>For POST data, the post must have been done using <var>multipart/form-data</var> encoding. This is indicated by specifying <code>enctype=multipart/form-data</code> on the <code>&lt;form&gt;</code> element if the post is done from an HTML form. For more information see [http://www.w3.org/TR/html401/interact/forms.html Forms in HTML Documents].</li>
</ul>
</ul>


==Examples==
==Examples==
The following example takes the lines from a file uploaded via a form POST and stores the individual lines into a <var class="product>Model 204</var> record. Note that generally upload file content would be better stored in [[Field_design#BLOB, CLOB, and MINLOBE attributes|LOB fields]].
The following example takes the lines from a file uploaded via a form POST and stores the individual lines into a <var class="product">Model&nbsp;204</var> record. Note that generally upload file content would be better stored in [[Field_design#BLOB, CLOB, and MINLOBE attributes|LOB fields]].
<p class="code">%stringlist  is object stringlist
<p class="code">%stringlist  is object stringlist
...
...

Latest revision as of 17:16, 2 May 2016

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