<?xml version="1.0" encoding="UTF-8"?>
<process xmlns:blue="http://www.e-marson.com/bluelemon">

  <descriptor>
    <name>com/emarson/lemonade/examples/helloWorld/HelloWorldScreen</name>
    <version>1.0</version>
    <description>
      This is the sticks'N'stones process.

      It generates a Bluelemon instruction which shows
      the "Hello World!" screen.
      The instruction generated by this process is just 
      a series of bytes. It must be processed in the 
      Bluelemon Runtime Environment in the MIDlet to
      actually do the operations which are coded here.
    </description>
    <vendor>E-MARSON</vendor>
  </descriptor>

  <path>

    <!-- ASSOCIATIONS --->

    <!-- association to exit from MIDlet --->
    <subprocess name="action for 'Exit'">
      <source>com/emarson/lemonade/templates/ExitFromApplication</source>
      <resultTo>actionForExit</resultTo>
    </subprocess>
    
    <!-- INSTRUCTION --->
    
    <!-- 
      Now let's code the screen we need.
      
      In sticks'N'stones we use actions of type 'general/bluelemon/code'
      to code in Bluelemon. 
      This action will be processed and the result it will produce
      will be stored in 'screen' variable, which we will use later.
    --->
    
    <action name="show screen with 'Hello World' text">
      <type>general/bluelemon/code</type>
      <definition resultTo="helloWorldScreen">

        <!-- in most places this is all very similar to J2ME --->

        <!-- create the form instance --->
        <blue:newInstance module="com/emarson/lemonade/bluelemon/midp1/Form"
                          toVariable="form"/>


        <!-- set its title as 'Hello' --->
        <blue:call object="form" method="initialize">
          <blue:argument type="String" value="Hello"/>
        </blue:call>
        
        <!-- make it write 'Hello World!' --->
        <blue:call object="form" method="appendString">
          <blue:argument type="String" value="Hello World!"/>
        </blue:call>
              
        <!-- add a command to exit from the application --->
        <blue:call manager="UtilsManager" method="getActionCommand"
                   toVariable="command">

          <blue:argument type="String" value="Exit"/>
          <blue:argument type="byte" value="ActionCommand.EXIT"/>
          <blue:argument type="byte" value="0"/>
          <blue:argument type="byteArr" contextKey="actionForExit"/>
        </blue:call>

        <blue:call object="form" method="addCommand">
          <blue:argument type="variable" name="command"/>
        </blue:call>
        
        <!-- show the form on the screen of the device --->
        <blue:call manager="GeneralManager" method="setCurrent">
          <blue:argument type="variable" name="form"/>
        </blue:call>

      </definition>
    </action>

    <!-- 
      OK, we have the Bluelemon code we needed. 
      Now we can simply return it. 
    --->

    <finish name="done">
      <return>helloWorldScreen</return>
    </finish>

  </path>

</process>