NEWS
Abfrage Liste - Konvertierung Astrozeitenskript in Blockly
-
Bin gerade dabei das Astrozeitenskript hier aus dem Forum in Blockly umzusetzen.
Wie kann ich folgenden Abschnitt in Blockly schreiben?
nxt = (abschnitt + 1 === tageszeiten.length) ? tageszeiten[0] : tageszeiten[parseInt(abschnitt + 1, 10)];
Das durch Blockly erzeuge JS hat beim 'else' noch ein '-1' - Woher kommt das?
<xml xmlns="http://www.w3.org/1999/xhtml"> <variables> <variable type="" id=";n{6[?[{$=8:QTfdloqd">i</variable> <variable type="" id="/W{U,=czPw.ii`I$||qJ">tageszeiten</variable> </variables> <block type="procedures_defnoreturn" id="u;%3l18Y@=FV2fD15}3e" x="813" y="238"> <mutation> <arg name="i" varid=";n{6[?[{$=8:QTfdloqd"></arg> </mutation> <field name="NAME">etwas tun</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"> <block type="controls_if" id="][?ex;if!5(S`,zD%jvk"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="Pl0ELsLx6D?*sqmhu)qA"> <field name="OP">EQ</field> <value name="A"> <block type="math_arithmetic" id="*wBE^;J1wEMLj^S}8JM)"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="Q*a|P7THbcgr_^thah`%"> <field name="NUM">1</field> </shadow> </value> <value name="B"> <shadow type="math_number" id="rVR%(wk|D,;yxm%R6Yb3"> <field name="NUM">1</field> </shadow> <block type="math_number" id="j)M$C|$mA@G4N;w5tu#."> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> <block type="lists_length" id="!l544YZ.,r@dTlInOmxX"> <value name="VALUE"> <block type="variables_get" id="SE%PL[8}IB-9W;9*O;pF"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="debug" id="6!W4eZX$vKIQ4UeB8j^g"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p;ZX7r-b9h=}%cyE!hby"> <field name="TEXT">test</field> </shadow> <block type="lists_getIndex" id="O;W8%`u3uEIaYjB%}qdY"> <mutation statement="false" at="true"></mutation> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> <block type="variables_get" id="7:+#CLK-+IYu1(#X)L7x"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> <value name="AT"> <block type="math_number" id="|z?tl0q-gL`GSO!BMOnW"> <field name="NUM">1</field> </block> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="debug" id="B00.bcp]Oa__HSfhcB?a"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id=";tHbjtCkf*)VIo5*#DV."> <field name="TEXT">test</field> </shadow> <block type="lists_getIndex" id="w9^l=o.V~D2;OnV7anc?"> <mutation statement="false" at="true"></mutation> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> <block type="variables_get" id="%{3{2J*%Is,wX`(x#2SP"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> <value name="AT"> <block type="math_arithmetic" id="hGAGFJF`VWlhh#zT|Jv!"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="Q*a|P7THbcgr_^thah`%"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="Fo3j7-W)k?~f3c(.EdRq"> <field name="VAR" id=";n{6[?[{$=8:QTfdloqd" variabletype="">i</field> </block> </value> <value name="B"> <shadow type="math_number" id="rVR%(wk|D,;yxm%R6Yb3"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </value> </block> </statement> </block> </statement> </block> <block type="variables_set" id="7O_?2wRS)v@MH`f/3UM[" x="813" y="513"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> <value name="VALUE"> <block type="lists_create_with" id="#3c5hSpdyjXoOxaKN7VJ"> <mutation items="8"></mutation> <value name="ADD0"> <block type="text" id="hT.{tf6rLXu+z2W9Cl%S"> <field name="TEXT">Nacht</field> </block> </value> <value name="ADD1"> <block type="text" id="Glm~qkO*lcq*.kU|$^9D"> <field name="TEXT">Morgendämmerung</field> </block> </value> <value name="ADD2"> <block type="text" id="qUMpHBVKQPjbAq5Dnd+Y"> <field name="TEXT">Morgen</field> </block> </value> <value name="ADD3"> <block type="text" id="y9?I/)Uf};*[!vPV/Z0-"> <field name="TEXT">Vormittag</field> </block> </value> <value name="ADD4"> <block type="text" id="(CtsY6u0ev3+]pMJt9vn"> <field name="TEXT">Mittag</field> </block> </value> <value name="ADD5"> <block type="text" id="jmibB%nZRHoD+(hz[#@Q"> <field name="TEXT">Nachmittag</field> </block> </value> <value name="ADD6"> <block type="text" id="o}[I8p|U_acB,0z0/YoH"> <field name="TEXT">Abenddämmerung</field> </block> </value> <value name="ADD7"> <block type="text" id="Y%C`9/b7%|jZI=WGm+%?"> <field name="TEXT">Abend</field> </block> </value> </block> </value> <next> <block type="schedule" id="qvc,g|l-Dp;I:`$JUH/P"> <field name="SCHEDULE">* * * * *</field> <statement name="STATEMENT"> <block type="procedures_callnoreturn" id="2UbD{L{tIwswHL|Je1S{"> <mutation name="etwas tun"> <arg name="i"></arg> </mutation> <value name="ARG0"> <block type="math_number" id="~3OW)u4j1~8XWEBpKB%/"> <field name="NUM">0</field> </block> </value> </block> </statement> </block> </next> </block> </xml>
-
Guten Morgen,
das ist kein Bug sondern ein Feature ... es liegt daran das Listen in Blockly nicht bei [0] begonnen werden zu zählen sondern bei [1] ...Mit einem zusätzlichen +1 würde es funktionieren, schön ist aber anders:
<xml xmlns="http://www.w3.org/1999/xhtml"> <variables> <variable type="" id="/W{U,=czPw.ii`I$||qJ">tageszeiten</variable> <variable type="" id="]0j+(fGNY(]AJjAv3hmf">test</variable> </variables> <block type="schedule" id="qvc,g|l-Dp;I:`$JUH/P" x="1513" y="-387"> <field name="SCHEDULE">*/5 * * * * *</field> <statement name="STATEMENT"> <block type="variables_set" id="a)bnCEh5BM05}i9Hvqiu"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> <value name="VALUE"> <block type="lists_create_with" id="Q2:h`{oqE*BCT7`xy+Kg"> <mutation items="8"></mutation> <value name="ADD0"> <block type="text" id="-hvJ#koD0zea@xpt!eMP"> <field name="TEXT">Nacht</field> </block> </value> <value name="ADD1"> <block type="text" id="F-[fo_c,N.IS-l$SI{J|"> <field name="TEXT">Morgendämmerung</field> </block> </value> <value name="ADD2"> <block type="text" id="n~okDyHScEj7Np}E_o|q"> <field name="TEXT">Morgen</field> </block> </value> <value name="ADD3"> <block type="text" id="`f[9n.X=kvWR`)Cw0P1~"> <field name="TEXT">Vormittag</field> </block> </value> <value name="ADD4"> <block type="text" id="1^9R(^_YWi0O?D4H!xj|"> <field name="TEXT">Mittag</field> </block> </value> <value name="ADD5"> <block type="text" id="/j/zYB+xY;d:3HT0l[r5"> <field name="TEXT">Nachmittag</field> </block> </value> <value name="ADD6"> <block type="text" id="waj4#d+eu2}uil?{Lwx0"> <field name="TEXT">Abenddämmerung</field> </block> </value> <value name="ADD7"> <block type="text" id="Dx+(C@@fEmKcWM#QgL4Z"> <field name="TEXT">Abend</field> </block> </value> </block> </value> <next> <block type="variables_set" id="YK}Vr}iss[/Nux^Of@1g"> <field name="VAR" id="]0j+(fGNY(]AJjAv3hmf" variabletype="">test</field> <value name="VALUE"> <block type="math_number" id="^(VJlP~L9CT[|9g|v(1W"> <field name="NUM">2</field> </block> </value> <next> <block type="comment" id="f;4k1dM91VNX:[]M*s4k"> <field name="COMMENT">Aktuelle Tageszeit</field> <next> <block type="debug" id="2@05?W;?/!{V0}[j7^x:"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="^7lla0/+/$!R.^wMP{b3"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="Do!n3=z7EDpWR`H#hH9T"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="2d:Kpu+yh(s.ABn~VDEA"> <field name="TEXT">Aktuelle Tageszeit: </field> </block> </value> <value name="ADD1"> <block type="lists_getIndex" id="#P;oal!,sc__.P0QRVte"> <mutation statement="false" at="true"></mutation> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> <block type="variables_get" id="g|_}o8e9zyx2W-V:?EGc"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> <value name="AT"> <block type="math_arithmetic" id="X(wDbsJKMhe$zNumm*vD"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="9@A,o8b6aRwUy1;rXu=+"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="-90p$hq`{^x]u|u(qhKv"> <field name="VAR" id="]0j+(fGNY(]AJjAv3hmf" variabletype="">test</field> </block> </value> <value name="B"> <shadow type="math_number" id="aBG^cdP|l:Y@VjA?zan)"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </value> </block> </value> <next> <block type="comment" id="[!?R@N*t{3J4|L%WY/NA"> <field name="COMMENT">Nächste Tageszeit</field> <next> <block type="controls_if" id="][?ex;if!5(S`,zD%jvk"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="Pl0ELsLx6D?*sqmhu)qA"> <field name="OP">EQ</field> <value name="A"> <block type="math_arithmetic" id="*wBE^;J1wEMLj^S}8JM)"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="Q*a|P7THbcgr_^thah`%"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="e99:je.?A9z0I4(4V+N0"> <field name="VAR" id="]0j+(fGNY(]AJjAv3hmf" variabletype="">test</field> </block> </value> <value name="B"> <shadow type="math_number" id="rVR%(wk|D,;yxm%R6Yb3"> <field name="NUM">1</field> </shadow> <block type="math_number" id="j)M$C|$mA@G4N;w5tu#."> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> <block type="lists_length" id="!l544YZ.,r@dTlInOmxX"> <value name="VALUE"> <block type="variables_get" id="SE%PL[8}IB-9W;9*O;pF"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="debug" id="6!W4eZX$vKIQ4UeB8j^g"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="p;ZX7r-b9h=}%cyE!hby"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="Q%Ck$L;j?aq_USw7U:|R"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="d?+`~+f%u[|J,eN/pCf3"> <field name="TEXT">(if) Nächste Tageszeit: </field> </block> </value> <value name="ADD1"> <block type="lists_getIndex" id="O;W8%`u3uEIaYjB%}qdY"> <mutation statement="false" at="false"></mutation> <field name="MODE">GET</field> <field name="WHERE">FIRST</field> <value name="VALUE"> <block type="variables_get" id="7:+#CLK-+IYu1(#X)L7x"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> </block> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="debug" id="B00.bcp]Oa__HSfhcB?a"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id=";tHbjtCkf*)VIo5*#DV."> <field name="TEXT">test</field> </shadow> <block type="text_join" id="KW/}K|1v~.E1:LsKyMT5"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="_fwRg~xJ,t7wqCd958(v"> <field name="TEXT">(else) Nächste Tageszeit: </field> </block> </value> <value name="ADD1"> <block type="lists_getIndex" id="w9^l=o.V~D2;OnV7anc?"> <mutation statement="false" at="true"></mutation> <field name="MODE">GET</field> <field name="WHERE">FROM_START</field> <value name="VALUE"> <block type="variables_get" id="%{3{2J*%Is,wX`(x#2SP"> <field name="VAR" id="/W{U,=czPw.ii`I$||qJ" variabletype="">tageszeiten</field> </block> </value> <value name="AT"> <block type="math_arithmetic" id="Mvbwf1PxXCjVjdvmNJl6"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="Gh6+VuMmuFQ=9+3lp?6d"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="hGAGFJF`VWlhh#zT|Jv!"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="Q*a|P7THbcgr_^thah`%"> <field name="NUM">8</field> </shadow> <block type="convert_tonumber" id="pzOwY/4vpZz9*(B[-/!{"> <value name="VALUE"> <block type="variables_get" id="Fo3j7-W)k?~f3c(.EdRq"> <field name="VAR" id="]0j+(fGNY(]AJjAv3hmf" variabletype="">test</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="rVR%(wk|D,;yxm%R6Yb3"> <field name="NUM">1</field> </shadow> <block type="math_number" id="qQK2$cnDghsf|W{lB051"> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id=".@~H=vjx/dFF^;mMUGjI"> <field name="NUM">1</field> </shadow> </value> </block> </value> </block> </value> </block> </value> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </xml>