hedrickbt / ClrBlockly

Clive Lego Robotics Blockly by Paul Richards
Apache License 2.0
0 stars 0 forks source link

Fix issue with variable declaration and "change...by" #4

Closed hedrickbt closed 6 years ago

hedrickbt commented 6 years ago

image

from numbers import Number

i = None

//Includes
//Instantiations

void setup () { // --- This runs once ---
  Serial.begin (9600);
  Serial.println ("Ready");
  i = 1;
}

void loop  () { // --- This runs continually ---
  i = (i if isinstance(i, Number) else 0) + 1
  //Updates
}

<xml xmlns="http://www.w3.org/1999/xhtml">
  <variables>
    <variable id="h]Rb`-WPx2x+8w146+6?" type="">i</variable>
  </variables>
  <block id="R/^W`PL~5D^l;s9MSpkw" type="setuploop" y="38" x="163">
    <field name="BAUDRATE">9600</field>
    <statement name="SETUPCODE">
      <block id="w:57Oudp3;g0U*,%pd.;" type="variables_set">
        <field id="h]Rb`-WPx2x+8w146+6?" name="VAR" variabletype="">i</field>
        <value name="VALUE">
          <block id="zZ/2dX9!YblLqutLy;:g" type="math_number">
            <field name="NUM">1</field>
          </block>
        </value>
      </block>
    </statement>
    <statement name="LOOPCODE">
      <block id="/d=NX(c5bG:j%2T!}}xG" type="math_change">
        <field id="h]Rb`-WPx2x+8w146+6?" name="VAR" variabletype="">i</field>
        <value name="DELTA">
          <shadow id="^|0%vy7`T)YUbQ(fD/,!" type="math_number">
            <field name="NUM">1</field>
          </shadow>
        </value>
      </block>
    </statement>
  </block>
</xml>