<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[&quot;Identifier redefined as global&quot; error when using Blockly functions]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/1">@m5stack</a> I have this program in uiFlow (v1.6.2 or v1.4.5, it doesn't matter)<br />
<img src="/assets/uploads/files/1598132037622-screen-shot-2020-08-22-at-5.33.16-pm.png" alt="0_1598132036682_Screen Shot 2020-08-22 at 5.33.16 PM.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">This is the resulting python code and it successfully runs:</p>
<pre><code>localVarX = None
localVarY = None
global globalVarA, globalVarB
global globalVarA, globalVarB

def myFunction(localVarX, localVarY):
  global globalVarA, globalVarB
  pass

global globalVarA, globalVarB
global globalVarA, globalVarB
</code></pre>
<p dir="auto">However, when I try to set or change the local variables (localVarX and localVarY) within the function, uiFlow redefines them as global variables in the function and I get an error on the m5stickC when I run the program.<br />
<img src="/assets/uploads/files/1598132276572-screen-shot-2020-08-22-at-5.36.56-pm.png" alt="0_1598132273836_Screen Shot 2020-08-22 at 5.36.56 PM.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">New python code:</p>
<pre><code>localVarX = None
localVarY = None
global globalVarA, localVarX, globalVarB, localVarY
global globalVarA, localVarX, globalVarB, localVarY

def myFunction(localVarX, localVarY):
  global globalVarA, localVarX, globalVarB, localVarY
  localVarX = 3
  localVarY = 4

global globalVarA, localVarX, globalVarB, localVarY
global globalVarA, localVarX, globalVarB, localVarY

</code></pre>
<p dir="auto">Here is the error on the serial monitor:</p>
<pre><code>Traceback (most recent call last):
  File "flow/m5cloud.py", line 76, in _exec_fun
  File "&lt;string&gt;", line 13, in &lt;module&gt;
SyntaxError: identifier redefined as global
</code></pre>
<p dir="auto">Running the same function on the <a href="https://blockly-demo.appspot.com/static/tests/playground.html" target="_blank" rel="noopener noreferrer nofollow ugc">Blockly Playground</a>, it seems to work correctly.<br />
<img src="/assets/uploads/files/1598132843267-screen-shot-2020-08-22-at-5.44.43-pm-resized.png" alt="0_1598132832681_Screen Shot 2020-08-22 at 5.44.43 PM.png" class=" img-fluid img-markdown" /><br />
<img src="/assets/uploads/files/1598132846153-screen-shot-2020-08-22-at-5.45.25-pm-resized.png" alt="0_1598132843034_Screen Shot 2020-08-22 at 5.45.25 PM.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/topic/2233/identifier-redefined-as-global-error-when-using-blockly-functions</link><generator>RSS for Node</generator><lastBuildDate>Mon, 16 Mar 2026 12:10:03 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/2233.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 22 Aug 2020 21:50:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Tue, 23 Feb 2021 22:26:04 GMT]]></title><description><![CDATA[<p dir="auto">I have the same issue. Has this been fixed ? Thanks !</p>
]]></description><link>https://community.m5stack.com/post/12635</link><guid isPermaLink="true">https://community.m5stack.com/post/12635</guid><dc:creator><![CDATA[natcl]]></dc:creator><pubDate>Tue, 23 Feb 2021 22:26:04 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Thu, 22 Oct 2020 06:12:27 GMT]]></title><description><![CDATA[<p dir="auto">Hi, is this bug has been resolved? Seems the bug is still there.</p>
]]></description><link>https://community.m5stack.com/post/10433</link><guid isPermaLink="true">https://community.m5stack.com/post/10433</guid><dc:creator><![CDATA[beacon88]]></dc:creator><pubDate>Thu, 22 Oct 2020 06:12:27 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Fri, 04 Sep 2020 12:53:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/700">@lukasmaximus</a> for my win10-pc the problem also seems to be solved, many thanks</p>
]]></description><link>https://community.m5stack.com/post/9943</link><guid isPermaLink="true">https://community.m5stack.com/post/9943</guid><dc:creator><![CDATA[Gaviota]]></dc:creator><pubDate>Fri, 04 Sep 2020 12:53:18 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Thu, 03 Sep 2020 19:25:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/700">@lukasmaximus</a> on my IPad ist seems to work fine, the problem occured on a WIN10 pc, tomorrow i try it again on WIN10.</p>
]]></description><link>https://community.m5stack.com/post/9931</link><guid isPermaLink="true">https://community.m5stack.com/post/9931</guid><dc:creator><![CDATA[Gaviota]]></dc:creator><pubDate>Thu, 03 Sep 2020 19:25:01 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Tue, 25 Aug 2020 11:30:58 GMT]]></title><description><![CDATA[<p dir="auto">I just started to get this error today too when trying an m5f file that had previously worked fine. Thanks for highlighting this guys, I'll create a bug report</p>
]]></description><link>https://community.m5stack.com/post/9836</link><guid isPermaLink="true">https://community.m5stack.com/post/9836</guid><dc:creator><![CDATA[lukasmaximus]]></dc:creator><pubDate>Tue, 25 Aug 2020 11:30:58 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Sun, 23 Aug 2020 16:52:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/700">@lukasmaximus</a>  <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/1">@m5stack</a>  <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/443">@ajb2k3</a> <a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/20">@admin</a><br />
<strong>Critical bug with the word "global" at python code transformation from UIFlow 1.6.2</strong></p>
<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/187">@world101</a><br />
... i agree with you, there is a critical bug in UIFlow 1.6.2.</p>
<p dir="auto">E.g. using the word "global" causes the python code transformation to replace the following text with all defined variables. Or defining a function with parameters causes a global definition in this function with the given paramater (look at my short test_global-program):<br />
<img src="/assets/uploads/files/1598193008566-global1-resized.jpg" alt="0_1598192973024_global1.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">with variables: value, var01<br />
var01 is set to "Bug with text global"</p>
<p dir="auto">In function "dosomething" with given parameter "value" i placed an Execute-code block with following content:<br />
# Test function for global error<br />
# look for global error<br />
# look for Global error</p>
<p dir="auto">when switching to &lt;/&gt;Python - page you can see that UIFlow made incorrect code transformation:<br />
<img src="/assets/uploads/files/1598193359563-global2-resized.jpg" alt="0_1598193335312_global2.jpg" class=" img-fluid img-markdown" /></p>
<p dir="auto">This code cann not run because:<br />
Line 17: the identifier "value" is redifined as global<br />
Line 27: the text after the word "global" is replaced by "var01, value" and the closing quotation mark is missing</p>
<p dir="auto">As you can see, each time the word "global" appears, the following text is replaced by all defined variables (see lines 18, 19 and 27).</p>
<p dir="auto">In line 20, the word "global" begins with a capital letter which doesn't lead to mistakes in code transformation.</p>
<p dir="auto"><strong>Note:<br />
With UIFlow 1.6.1 desktop version this problem does not exist!</strong></p>
]]></description><link>https://community.m5stack.com/post/9810</link><guid isPermaLink="true">https://community.m5stack.com/post/9810</guid><dc:creator><![CDATA[Gaviota]]></dc:creator><pubDate>Sun, 23 Aug 2020 16:52:28 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Sat, 22 Aug 2020 23:05:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/1872">@gaviota</a></p>
<p dir="auto">Thanks for confirming. I think this is indeed a bug in uiFlow then. I shouldn't have to use the execute block to work with local variables in the functions. Especially if Blockly Playground behaves differently.</p>
]]></description><link>https://community.m5stack.com/post/9798</link><guid isPermaLink="true">https://community.m5stack.com/post/9798</guid><dc:creator><![CDATA[world101]]></dc:creator><pubDate>Sat, 22 Aug 2020 23:05:48 GMT</pubDate></item><item><title><![CDATA[Reply to &quot;Identifier redefined as global&quot; error when using Blockly functions on Sat, 22 Aug 2020 22:43:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="mention plugin-mentions-user plugin-mentions-a" href="https://community.m5stack.com/uid/187">@world101</a><br />
In UIFlow defined variables are every time global. Using local variables in UIFlow only works in execute blocks.</p>
]]></description><link>https://community.m5stack.com/post/9796</link><guid isPermaLink="true">https://community.m5stack.com/post/9796</guid><dc:creator><![CDATA[Gaviota]]></dc:creator><pubDate>Sat, 22 Aug 2020 22:43:16 GMT</pubDate></item></channel></rss>