EDOBE XDOM TAKE 6 IR - PRODUCTSHEET Especificaciones Pagina 177

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 304
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 176
CHAPTER 5: Interapplication Communication with Scripts Communicating through messages 177
Passing simple types
When your message objects onResult callback receives a response, it must interpret the string it finds in
the
body of the response message to obtain a result of the correct type. Results of various types can be
identified and processed as follows:
Passing complex types
When returning complex types (arrays and objects), the script that you send must construct a result string,
using the
toSource method to serialize the array or object. In this case, the sender must reconstitute the
array or object by using the
eval method on the result string in the response body.
Passing an array with toSource and eval
For example, the following code sends a script that returns an array in this way. The
onResult callback that
receives the response uses
eval to reconstruct the array.
// Code for send message and handling response
// in the sending application (any message-enabled application)
var idx = 0;
var resArr = new Array;
var bt = new BridgeTalk;
bt.target = "bridge-3.0";
// the script passed to the target application
// needs to return the array using "toSource"
bt.body = "var arr = [10, "this string", 324];
arr.toSource();"
bt.onResult = function(resObj) {
// use eval to reconstruct the array
arr = eval(resObj.body);
Number JavaScript allows you to access a string that contains a number directly as a number, without
doing any type conversion. However, be careful when using the plus operator (
+), which
works with either strings or numbers. If one of the operands is a string, both operands are
converted to strings and concatenated.
String No conversion is required.
Boolean The result string is either “true” or “false.You can convert it to a true boolean by evaluating it
with the
eval method.
Date The result string contains the date in the form:
"dow mmm dd yyyy hh:mm:ss GMT-nnnn".
For example “Wed Jun 23 2004 00:00:00 GMT-0700”.
Array The result string contains a comma delimited list of the elements of the array. For example, If
the result array is
[12, "test", 432], the messaging framework flattens this into the string
"12,test,432".
As an alternative to simply returning the array, the message target can use the
toSource
method to return the code used to create the array. In this case, the sender must reconstitute
the array by using the
eval method on the result string in the response body. See discussion
below.
Vista de pagina 176
1 2 ... 172 173 174 175 176 177 178 179 180 181 182 ... 303 304

Comentarios a estos manuales

Sin comentarios