User Tools

Site Tools


xmlscripting:course-en
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


xmlscripting:course-en [2018/11/12 08:56] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +====== XmlScript: Quick Start Guide ======
 +[[:english#objects|{{  :objects.png}}]][[:english|{{  :rocrail-logo-35.png}}]]
 +[[:english|Content]] -> [[:english#objects|Objects]] ->   [[:timed-actions-en|Actions]]
 +  * [[:actions-en|Action Setup]] | [[:actionctrl-en|Action Control]] | [[:actioncond-en|Action Condition]] | [[:xmlscripting-en|XML Scripting]] | [[:action-example-en|Example]]
 +    * **[[:xmlscripting:course-en|Quick Start Guide]]**
 +
 + \\
 +=====1: Introduction=====
 +This small guide will try to learn you how to use XmlScript actions in Rocrail.\\
 +====Requirements====
 +  * How to __**[[:actions-en|Create Actions]]**__.
 +  * How to __**[[:actionctrl-en|Link Actions with Objects]]**__.
 +  * Some __**[[http://www.w3schools.com/xml/|XML basic knowledge]]**__.
 +  * A Rocrail installation with revision __**[[http://rocrail.net/software/rocrail-snapshot/|10289+]]**__.
 +
 +
 +
 + \\
 +
 +=====2: Hello World=====
 +This chapter will show you in only a few steps how an XmlScript can be used as action.\\
 +
 +====The Layout====
 +  * {{:xmlscripting:plan-1.xml.zip}}
 +{{:xmlscripting:xmlscript-course-img1.png}}\\
 +The layout is very simple and contains only a button, **b1**, and a text field **t1**\\
 +Goal is to trigger with the button a XmlScript which will display "Hello world!" in the text field.\\
 +====Creating the script====
 +  - Create an action with the ID **script1**.
 +  - Write in the command file field **script1.xml**.
 +  - Click on the **Edit** button.
 +{{:xmlscripting:xmlscript-course-img2.png}}\\
 +
 +After clicking on the **Edit** button the XmlScript editor will show up with a XmlScript skeleton:\\
 +{{:xmlscripting:xmlscript-course-img3.png}}\\
 +
 +  - Place the cursor in the XmlScript editor somewhere between <xmlscript> and </xmlscript>.
 +  - Select in the Statement box **text**.
 +  - Select in the ID box **t1**.
 +  - Select in the Command box **format**.
 +  - Write in the Parameter box **Hello world!**.
 +  - Push the **Insert** button.
 +  - The new line will show up.
 +  - Push the **Save** button.
 +{{:xmlscripting:xmlscript-course-img4.png}}\\
 +
 +====Link the action with the button====
 +Now the link must be defined with the push button **b1**.
 +  - Open the button **b1** properties.
 +  - Push the **Actions...** button.
 +  - Select the action ID **script1**.
 +  - Select the action State **on**.
 +  - Push the **Add** button.
 +  - Push the **OK** buttons.
 +{{:xmlscripting:xmlscript-course-img5.png}}\\
 +
 +====Test the XmlScript====
 +All is ready now to make the 'Hello world!' test.
 +  - Click on button **b1**.
 +  - Button **b1** will turn to green color.
 +  - The text field **t1** will show: **Hello world!**.
 +  - Congratulations! Your first XmlScript did work.
 +  - To run it again you can reset the text from **t1** by clicking on it and delete the text in the popup.
 +{{:xmlscripting:xmlscript-course-img6.png}}\\
 +
 +
 +
 + \\
 +
 +=====3: Make a decision=====
 +In this chapter a decision will be made which depends on the text field **t2** contents.\\
 +====The layout====
 +  * {{:xmlscripting:plan-2.xml.zip}}
 +{{:xmlscripting:xmlscript-course-img7.png}}\\
 +The layout is extended with an extra text field **t2**.\\
 +The contents of this new text field will be used for a XmlScript decision.\\
 +Text field **t2** has became the **Input** option to make it easy to change the containing text.\\
 +
 +====Extending the script====
 +The goal is to make the new text for text field **t1** dependant of the contents of text field **t2**.\\
 +
 +  - Open the **Actions dialog**, double click on the action **script1** to open the XmlScript editor.
 +  - Extend the existing XmlScript as follows:
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<xmlscript>
 +  <if condition="$t2 # 4711">
 +    <then>
 +      <tx id="t1" format="t2 is 4711 :)"/>
 +    </then>
 +    <else>
 +      <tx id="t1" format="t2 is not 4711 but $t2 :("/>
 +    </else>
 +  </if>
 +</xmlscript>
 +</code>
 +
 +With the **<if>** statement a decision can be made. This decision must be defined in the **condition** attribute of the **<if>** line.\\
 +In this example the condition is defined as follows:\\
 +| The contents of text field **t2**, **$t2** , is textually compared, **#**, with the value **4711**. |\\
 +
 +If the condition is true all commands between **<then>** and **</then>** are executed.\\
 +If its not true, and there is an **<else>** node, all commands between **<else>** and **</else>** are executed.\\  
 +
 +Because text field **t2** is defined as an input field you can play around changing the **t2** contents and push button **b1**.\\
 +
 +
 +
 + \\
 +=====4: Next steps=====
 +  * Check the __**[[:xmlscripting-en|XmlScript]]**__ page which statements and commands are available.
 +  * Use __**[[:xmlscripting-en#trace|Trace]]**__ lines to see what is happening in your script.
  
xmlscripting/course-en.txt · Last modified: 2018/11/12 08:56 by 127.0.0.1