Encoding and Decoding: Binary and XML
209
NetLinx Programming Language Reference Guide
Encoding and Decoding: Binary and XML
There are six special functions used to encode and decode variables in NetLinx. This encoding process
takes a NetLinx variable, no matter how complex, and converts it into a string. The decode process will
take this string and copy the contents back into a variable.
These functions can be used to take the contents of NetLinx variables and convert them to string. Once
the variable exists in string form, it can then be sent across an RS-232 connection, sent over and IP
socket or saved to the NetLinx master's file system (disc on chip). Once the string is retrieved, either
from a data event or by reading the information from the NetLinx master's file system, the data can be
converted back to a variable.
There are two version of this encoding and decoding: Binary and XML. The binary conversion routines
are:
STRING_TO_VARIABLE
,
VARIABLE_TO_STRING
and
LENGTH_ VARIABLE_TO_STRING
.
The XML routines are
XML_TO_VARIABLE
,
VARIABLE_TO_XML
and
LENGTH_ VARIABLE_TO_XML
. Both sets of routines accomplish the same function but the encoded
string differs in protocol. The binary conversion routines uses a compact binary representation of the
variable while the XML represents the variable as a ASCII text only XML document.
The binary routines are ideal when sending data from one NetLinx system to another NetLinx system
over RS-232 or IP since the variable will be as compact as possible. It is also ideal for saving a file to the
NetLinx master's file system if you do not intend to edit the file later. The binary routines encode and
decode a variable sequentially meaning that the order and type of the variables must match on both the
encoding and decoding side.
The XML routines are ideal when sending data from one NetLinx system to another type of system over
RS232 or IP, since XML is more universally accepted by other types of computer systems. XML is also
ideal for saving a file to the NetLinx master's file system if you intend to edit the file later since it is
entirely ASCII text. It should be noted that while the XML is more universal, is not very compact. The
XML routines encode and decode a variable non-sequentially, meaning that the order and type of
variables do not need to match on both the encoding and decoding side.
Below are some examples of how to use these encoding routines:
PROGRAM_NAME='ConversionExample'
(*{{PS_SOURCE_INFO(PROGRAM STATS) *)
(***********************************************************)
(* FILE CREATED ON: 05/22/2001 AT: 11:09:27 *)
(***********************************************************)
(* FILE_LAST_MODIFIED_ON: 05/22/2001 AT: 11:26:44 *)
(***********************************************************)
(* ORPHAN_FILE_PLATFORM: 1 *)
(***********************************************************)
(*!!FILE REVISION: *)
(* REVISION DATE: 05/22/2001 *)
(* *)
(* COMMENTS: *)
(* *)
(***********************************************************)
(*}}PS_SOURCE_INFO *)
Summary of Contents for NETLINX PROGRAMMING LANGUAGE
Page 15: ...Table of Contents xiii NetLinx Programming Language Reference Guide...
Page 16: ...xiv NetLinx Programming Language Reference Guide Table of Contents...
Page 18: ...Introduction 2 NetLinx Programming Language Reference Guide...
Page 76: ...Language Elements 60 NetLinx Programming Language Reference Guide...
Page 106: ...Combining Devices Levels and Channels 90 NetLinx Programming Language Reference Guide...
Page 112: ...Master To Master M2M 96 NetLinx Programming Language Reference Guide...
Page 182: ...Reserved Identifiers 166 NetLinx Programming Language Reference Guide...
Page 204: ...NetLinx UniCode Functions 188 NetLinx Programming Language Reference Guide...
Page 244: ...Appendix B Glossary 228 NetLinx Programming Language Reference Guide...
Page 245: ...Appendix B Glossary 229 NetLinx Programming Language Reference Guide...