renciso218 / blockly

Automatically exported from code.google.com/p/blockly
0 stars 0 forks source link

Python and JavaScript output is different and order of function declaration in python #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I clicked the following simple program
<xml>
  <block type="variables_set" inline="false" x="134" y="56">
    <title i="1">item</title>
    <value i="0">
      <block type="math_number">
        <title i="0">0</title>
      </block>
    </value>
    <next>
      <block type="procedures_callnoreturn">
        <mutation name="procedure"></mutation>
        <next>
          <block type="text_print" inline="false">
            <value i="0">
              <block type="variables_get">
                <title i="1">item</title>
              </block>
            </value>
          </block>
        </next>
      </block>
    </next>
  </block>
  <block type="procedures_defnoreturn" x="348" y="69">
    <title i="0">procedure</title>
    <statement i="0">
      <block type="variables_set" inline="false">
        <title i="1">item</title>
        <value i="0">
          <block type="math_number">
            <title i="0">1</title>
          </block>
        </value>
      </block>
    </statement>
  </block>
</xml>
When running the JavaScript code the output is 1
When running the Python code the output is 0
Before running the Python code you have to move the function definition to the 
top of the program or you will get an error.

Either at global item in the python or var item in JavaScript inside the 
function definition would correct the Problem.
Or better let the user choose to have global or local variable.

Original issue reported on code.google.com by Gwa...@gmail.com on 5 Jun 2012 at 8:29

GoogleCodeExporter commented 8 years ago
Fixed.  All functions are now declared at the top.  Thanks!

(Sorry, the XML format just changed, so the above code no longer compiles.)

Original comment by neil.fra...@gmail.com on 8 Jun 2012 at 11:58