En este segundo vídeo sobre el desarrollo de Movelets desde Eclipse veremos cómo crear una calculadora muy simple con una pantalla de formulario y, más importante aun, cómo comenzar a utilizar el código de programación MEL y aplicarlo en el sitio/trigger correcto.
El código visto en el vídeo se correspondería con el siguiente:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
<MovilizerRequest systemId="${#Project#SystemID}" systemPassword="${#Project#Password}" xmlns="http://movilitas.com/movilizer/v16"> <moveletDelete moveletKey="SCN_CALCULATOR" /> <moveletSet> <movelet moveletKey="SCN_CALCULATOR" initialQuestionKey="SCR_CALC" moveletType="MULTI"> <question key="SCR_CALC" type="5" title="Calculator"> <answer key="ANS_VALUE1" nextQuestionKey="END" attributeType="2" position="1" labelFontStyle="BOLD" columnSizeType="LEFT" > <text>Value 1:</text> <valueHintText>Write the value 1 here</valueHintText> </answer> <answer key="ANS_VALUE2" nextQuestionKey="END" attributeType="2" position="2" labelFontStyle="BOLD" columnSizeType="LEFT" > <text>Value 2:</text> <valueHintText>Write the value 2 here</valueHintText> </answer> <answer key="ANS_OPERATOR" nextQuestionKey="END" attributeType="6" position="3" labelFontStyle="BOLD" columnSizeType="LEFT" sortAnswerItemsByClientKey="true"> <item clientKey="CK_1SUM"> <value>Addition</value> </item> <item clientKey="CK_2RES"> <value>Subtraction</value> </item> <item clientKey="CK_3MUL"> <value>Multiplcation</value> </item> <item clientKey="CK_4DIV"> <value>Division</value> </item> <text>Operator:</text> <valueHintText>Select the operator here</valueHintText> </answer> <restriction nextQuestionKey="END"> <condition>false</condition> <matchingAssignment> </matchingAssignment> </restriction> <validation position="1" type="ERROR"> <condition>true</condition> <text>The result is: %RESULT%</text> <matchingAssignment> setPlaceholder("%RESULT%", data["RESULT"]); </matchingAssignment> </validation> <onEnterAssignment> </onEnterAssignment> <onLeaveOkPrepareAssignment> data = null; data["VALUE1"] = getAnswerValueByClientKey($answer:"ANS_VALUE1", null); data["VALUE2"] = getAnswerValueByClientKey($answer:"ANS_VALUE2", null); data["OPERATOR"] = getAnswerValueByClientKey($answer:"ANS_OPERATOR", null); if( data["OPERATOR"] == "CK_1SUM" ) { data["RESULT"] = data["VALUE1"] + data["VALUE2"]; } else{ if( data["OPERATOR"] == "CK_2RES" ) { data["RESULT"] = data["VALUE1"] - data["VALUE2"]; } else{ if( data["OPERATOR"] == "CK_3MUL" ) { data["RESULT"] = data["VALUE1"] * data["VALUE2"]; } else{ if( data["OPERATOR"] == "CK_4DIV" ) { data["RESULT"] = data["VALUE1"] / data["VALUE2"]; }}}} </onLeaveOkPrepareAssignment> <onLeaveOkPersistAssignment> </onLeaveOkPersistAssignment> <onLeaveBackAssignment> </onLeaveBackAssignment> <onScreenValueChangeEvent> function( $ref:answerKey, $ref:clientKey, $ref:value, $ref:data ) { } </onScreenValueChangeEvent> </question> <name>Calculator</name> </movelet> <participant participantKey="Test1" name="Test1" deviceAddress="${#Project#Participant}" /> </moveletSet> </MovilizerRequest> |