Mobile Channels Script Files

Mobile Channels employs two types of scripts: channel scripts and item scripts. In the CDF, a CHANNELSCRIPT tag identifies a script for a channel and an ITEMSCRIPT tag identifies a script for an item. All Mobile Channels script files end with an .mcs extension.

Scripts are invoked in a data-driven manner. When it is time to display a particular data file, the reference is made to the data file and the appropriate item script is located to display it. Likewise, when it is time to show channel content, such as a listing of subchannels or data items, the reference to the channel is made and the appropriate channel script is located to display it. For more information on how scripts are associated with the data or channels, see Item Script Selection and Channel Script Selection.

The following code example shows a CDF file referenced later in this chapter.

<!-- Declare item scripts ––> 
<ITEM HREF="http://www.microsoft.com/test/script1.mcs" ID="IS1">
    <USAGE VALUE="None"/>
</ITEM>
<ITEM HREF="http://www.microsoft.com/test/script2.mcs" ID="IS2">
    <USAGE VALUE="None"/>
</ITEM>

<!-- Declare channel scripts ––>
<ITEM HREF="http://www.microsoft.com/test/script3.mcs" ID="CS1">
    <USAGE VALUE="None"/>
</ITEM>
<ITEM HREF="http://www.microsoft.com/test/script4.mcs" ID="CS2">
    <USAGE VALUE="None"/>
</ITEM>

<CHANNEL HREF = "http://www.microsoft.com/test/test.cdf" ID="test">
   <TITLE>Test Channel</TITLE>
   <!-- IS1 is the general item script to use within the channel ––>
   <ITEMSCRIPT VALUE="IS1"/>

   <!—-CS1 is the general channel script to use within the channel ––>
   <CHANSCRIPT VALUE="CS1"/>
    . . .
   <CHANNEL ID="C1">
      <TITLE>Test Subchannel 1</TITLE>

      <!—- This channel is rendered by the general channel script CS1––>
      . . . 
      <ITEM HREF="http://www.microsoft.com/test/item-a.mcd" ID="ITA">
          <!—- This item is rendered by the item-specific IS2 script––>
          <ITEMSCRIPT VALUE="IS2"/>
          <USAGE VALUE="MOBILECHANNEL"/>
      </ITEM>
      . . .
   </CHANNEL>
   <CHANNEL ID="C2">
      <TITLE>Test Subchannel 2</TITLE>

      <!—-This channel is rendered by the channel-specific script CS2––>
      <CHANSCRIPT VALUE="CS2" />
      <ITEM HREF="http://www.microsoft.com/test/item-b.mcd" ID="ITB">
          <!-—This item is rendered by the general IS1 item script––>

          <USAGE VALUE="MobileChannel"/>
      </ITEM>
   </CHANNEL>
</CHANNEL>

This section covers the following topics: