BinaryProcedureEncode (Stringlist subroutine): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
 
mNo edit summary
Line 1: Line 1:
<span style="font-size:120%"><b>Convert from String to Binary Format</b></span>
{{Template:Stringlist:BinaryProcedureEncode subtitle}}


This method is used to append data in the format used by ''[[Janus Web Server]]'' to store binary data in procedures to a Stringlist.
This method is used to append data in the format used by ''[[Janus Web Server]]'' to store binary data in procedures to a Stringlist.
Line 5: Line 5:
BinaryProcedureEncode is a member of the [[Stringlist class]].
BinaryProcedureEncode is a member of the [[Stringlist class]].


==BinaryProcedureEncode Syntax==
==Syntax==
<pre>
{{Template:Stringlist:BinaryProcedureEncode syntax}}
%sl:BinaryProcedureEncode(string, [base64Flag])
===Syntax terms===
</pre>
 
===Syntax Terms===
<dl>
<dl>
<dt>%sl<dd>A Stringlist object.<dt>string<dd>The string to be converted to binary procedure format.<dt>base64Flag<dd>A boolean value: if <tt>.True</tt>, the data is to be base64 encoded in the Stringlist, not binary encoded. This is an optional argument, and it defaults to <tt>.True</tt>, which results in base64 encoding. </dl>
<dt>%sl<dd>A Stringlist object.<dt>string<dd>The string to be converted to binary procedure format.<dt>base64Flag<dd>A boolean value: if <tt>.True</tt>, the data is to be base64 encoded in the Stringlist, not binary encoded. This is an optional argument, and it defaults to <tt>.True</tt>, which results in base64 encoding. </dl>


==Usage Notes==
==Usage notes==
<ul><li>All errors in BinaryProcedureEncode result in request cancellation.<li>This method (along with BinaryProcedureDecode) facilitates converting data in a longstring into the format used for storing binary data in procedures by ''[[Janus Web Server]]''. This format is necessary if binary data is to be stored in ''Model 204'' procedure files because standard procedure formats are not amenable to storing binary data.<li>All data in the binary procedure encoding is wrapped in container data that makes it convenient to store the data in a procedure. By default, the data is also stored in base64 encoding, which represents the data as common displayable characters, making it even more convenient to work with. The convenience of base64 encoding does have a cost, however: it takes four bytes of encoded data to represent three bytes of binary data. In addition, on storage and retrieval, the data must be converted from binary format to base64 encoding and vice versa, which will require some CPU (though probably not a dramatic amount). If the benefits of base64 encoding are determined to not be worth the costs, the second parameter of BinaryProcedureEncode can be set to <tt>.False</tt> to cause the data not to be base64 encoded.<blockquote>The BinaryProcedureDecode method and all other facilities that read the binary procedure encoding format will automatically determine whether the data is base64 encoded or not and do the appropriate decoding.</blockquote><li>The BinaryProcedureEncode method is available in ''[[Sirius Mods]]'' Version 6.7 and later.</ul>
<ul><li>All errors in BinaryProcedureEncode result in request cancellation.<li>This method (along with BinaryProcedureDecode) facilitates converting data in a longstring into the format used for storing binary data in procedures by ''[[Janus Web Server]]''. This format is necessary if binary data is to be stored in ''Model 204'' procedure files because standard procedure formats are not amenable to storing binary data.<li>All data in the binary procedure encoding is wrapped in container data that makes it convenient to store the data in a procedure. By default, the data is also stored in base64 encoding, which represents the data as common displayable characters, making it even more convenient to work with. The convenience of base64 encoding does have a cost, however: it takes four bytes of encoded data to represent three bytes of binary data. In addition, on storage and retrieval, the data must be converted from binary format to base64 encoding and vice versa, which will require some CPU (though probably not a dramatic amount). If the benefits of base64 encoding are determined to not be worth the costs, the second parameter of BinaryProcedureEncode can be set to <tt>.False</tt> to cause the data not to be base64 encoded.<blockquote>The BinaryProcedureDecode method and all other facilities that read the binary procedure encoding format will automatically determine whether the data is base64 encoded or not and do the appropriate decoding.</blockquote><li>The BinaryProcedureEncode method is available in ''[[Sirius Mods]]'' Version 6.7 and later.</ul>



Revision as of 17:36, 31 December 2010

Convert from binary procedure format to string (Stringlist class)


This method is used to append data in the format used by Janus Web Server to store binary data in procedures to a Stringlist.

BinaryProcedureEncode is a member of the Stringlist class.

Syntax

sl:BinaryProcedureEncode( string, [base64Flag])

Syntax terms

%sl
A Stringlist object.
string
The string to be converted to binary procedure format.
base64Flag
A boolean value: if .True, the data is to be base64 encoded in the Stringlist, not binary encoded. This is an optional argument, and it defaults to .True, which results in base64 encoding.

Usage notes

  • All errors in BinaryProcedureEncode result in request cancellation.
  • This method (along with BinaryProcedureDecode) facilitates converting data in a longstring into the format used for storing binary data in procedures by Janus Web Server. This format is necessary if binary data is to be stored in Model 204 procedure files because standard procedure formats are not amenable to storing binary data.
  • All data in the binary procedure encoding is wrapped in container data that makes it convenient to store the data in a procedure. By default, the data is also stored in base64 encoding, which represents the data as common displayable characters, making it even more convenient to work with. The convenience of base64 encoding does have a cost, however: it takes four bytes of encoded data to represent three bytes of binary data. In addition, on storage and retrieval, the data must be converted from binary format to base64 encoding and vice versa, which will require some CPU (though probably not a dramatic amount). If the benefits of base64 encoding are determined to not be worth the costs, the second parameter of BinaryProcedureEncode can be set to .False to cause the data not to be base64 encoded.

    The BinaryProcedureDecode method and all other facilities that read the binary procedure encoding format will automatically determine whether the data is base64 encoded or not and do the appropriate decoding.

  • The BinaryProcedureEncode method is available in Sirius Mods Version 6.7 and later.

Examples

The BinaryProcedureEncode method takes data from a longstring and places it on a Stringlist, from which it could then be stored in a procedure. In the following example, a GIF (graphical image) is retrieved from another web server using a Janus Sockets HTTP helper request and then moved onto a Stringlist with the special binary procedure encoding:

%req is object httpRequest
%resp is object httpResponse
%gif is longstring
%procData is object stringList
...
%resp = %req:get
%gif = %resp:content(1)
%procData = new
%procData:add('IN FILE WHATEVER PROCEDURE MUMBLE.GIF')
%procData:binaryProcedureEncode(%gif)
%procData:add('END PROCEDURE')

The actual saving of the data to a procedure is not shown, though the example Stringlist could easily be passed to a Daemon object Run method (Run (Daemon function) to create the procedure.