Mobile Data StudioObject Model › Telegram

The Telegram class represents a telegram that can be sent from a mobile device to the server, or vice-versa, without finishing and leaving the Session.

This allows live communication, such as requesting and receiving additional data from server-side databases, which can then be presented on the mobile device, or sending status updates from the mobile device to the server as a session is being filled out. See OnTelegram() in Data Script.

Telegrams are a collection of point values, plus the special TelegramName value and the UnitID property.

To retrieve data from a telegram, use the indexer syntax with the point ID name of the point whose value you wish to retrieve:

retrievedValue = nameOfTelegramVariable("PointIDName")

You can also modify telegram data by assigning a new value:

nameOfTelegramVariable("PointIDName") = "newValue"

Enumerable

This class can be enumerated with a For Each loop.

Each enumerated item is a Variant. The "key" (the point ID name) is not returned.

Indexable

This class can be indexed, with either an Integer or a String index:

  • An Integer index must be between 1 and the Count property.
  • A String index is a point ID name of the value to retrieve.

This is a read/write indexer, so values can be both retrieved and stored.

Values are Variant, which may be Boolean, Integer, String, date, or binary (such as a file).

For working with embedded files, see Database.LoadFromFile and Database.SaveToFile.

Properties

Application

Returns the root Application.

Count

Returns the number of values stored in the telegram as an Integer.

Key()

This is a named indexer property, which takes one Integer parameter that must be between 1 and the Count property.

Returns a String that is the point ID name of that value.

Project

Returns the Project this telegram belongs to.

UnitID

A String value indicating which mobile device created the telegram, or, to which mobile device the telegram should be dispatched, depending on the context. Read/write.

Value()

This is a named indexer property, which takes one Integer parameter that must be between 1 and the Count property. Returns a Variant that is the indexed value.

Methods

Clone

Returns a new Telegram object that is a clone of this one.

Takes no parameters.

SendToClient

Takes one parameter:

  • UnitID - a String which is the UnitID of the mobile device the telegram should be sent to.

Returns a Boolean: True if the mobile device was connected and the telegram was sent to it, or False if it was not.

Note that a True return value does not mean that the mobile device successfully received the telegram, only that it was sent. Telegrams are not automatically acknowledged.