<?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[UIFLOW variable declaration issues - need help]]></title><description><![CDATA[<p dir="auto">I am having issues using a variable in a for loop when I am using UIFLOW. Here are two separate issues. In the first example you can see the start and stop value are not being properly populated with the value from the block. This happens as soon as a variable is used in the for loop.<br />
<strong>TypeError("generator' object is not iterable",)</strong><br />
<img src="https://i.pinimg.com/564x/ba/a3/f2/baa3f2dddb7da26f07e45fad97f4241f.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<pre><code>from m5stack import *
from m5ui import *
clear_bg(0x111111)


btnA = M5Button(name='ButtonA', text='ButtonA', visibility=False)
btnB = M5Button(name='ButtonB', text='ButtonB', visibility=False)
btnC = M5Button(name='ButtonC', text='ButtonC', visibility=False)
rect0 = M5Rect(0, 0, 30, 30, 0x000000, 0xFFFFFF)

step = None
X = None
Y = None

def upRange(start, stop, step):
  while start &lt;= stop:
    yield start
    start += abs(step)



while True:
  step = 40
  for X in upRange:
    for Y in upRange:
      rect0.setBgColor(0x999999)
      rect0.setPosition(X, Y)
  wait(0.001)
</code></pre>
<p dir="auto">This is the code for the second attempt. I'm not sure why it's defining the type as float. The error I get is <strong>TypeError('can't convert float to int')</strong><br />
<img src="https://i.pinimg.com/564x/99/13/ec/9913ec571b63c770db1382c8c4b1f8cc.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
<pre><code>from m5stack import *
from m5ui import *
clear_bg(0x111111)


btnA = M5Button(name='ButtonA', text='ButtonA', visibility=False)
btnB = M5Button(name='ButtonB', text='ButtonB', visibility=False)
btnC = M5Button(name='ButtonC', text='ButtonC', visibility=False)
rect0 = M5Rect(0, 0, 30, 30, 0x000000, 0xFFFFFF)

start = None
stop = None
step = None
X = None
Y = None

def upRange(start, stop, step):
  while start &lt;= stop:
    yield start
    start += abs(step)

def downRange(start, stop, step):
  while start &gt;= stop:
    yield start
    start -= abs(step)



start = 0
stop = 200
step = 40
while True:
  for X in (float(start) &lt;= float(stop)) and upRange(float(start), float(stop), step) or downRange(float(start), float(stop), step):
    for Y in (float(start) &lt;= float(stop)) and upRange(float(start), float(stop), step) or downRange(float(start), float(stop), step):
      rect0.setBgColor(0x999999)
      rect0.setPosition(X, Y)
  wait(0.001)
</code></pre>
]]></description><link>https://community.m5stack.com/topic/404/uiflow-variable-declaration-issues-need-help</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 22:33:22 GMT</lastBuildDate><atom:link href="https://community.m5stack.com/topic/404.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Nov 2018 05:29:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Fri, 24 Feb 2023 09:36:55 GMT]]></title><description><![CDATA[<p dir="auto">I am still getting a "can't convert float to int" error whenever I use a variable in the by argument in the count with i from to block. If I use an integer block in by it works fine. If I set a variable to the same integer it gives me an error and if I convert to int or convert to float I get the same error. If I click on details it reads: File&lt;'string'&gt; line57 in &lt;module&gt; TypeError: can't convert float to int. This is a bummer since I need to use a variable in the by argument of the block. Any help would be appreciated</p>
<p dir="auto"><img src="/assets/uploads/files/1677231076819-screenshot-2023-02-24-012950-resized.png" alt="0_1677231094954_Screenshot 2023-02-24 012950.png" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/20182</link><guid isPermaLink="true">https://community.m5stack.com/post/20182</guid><dc:creator><![CDATA[jpilarski]]></dc:creator><pubDate>Fri, 24 Feb 2023 09:36:55 GMT</pubDate></item><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Wed, 28 Nov 2018 13:48:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/heybin" aria-label="Profile: heybin">@<bdi>heybin</bdi></a> I looked for the float and int block in the v1.0 release but I didn't see them. Can you tell me the status on this issue. By the way it looks like as of 0.91 the python code being generated is now casting all variables used in a  for loop to float type and their is no longer an error caused by mixed types. I'm not sure if you are still planning to have blocks to specify types but I think it could be a good feature to have.</p>
]]></description><link>https://community.m5stack.com/post/2099</link><guid isPermaLink="true">https://community.m5stack.com/post/2099</guid><dc:creator><![CDATA[jpilarski]]></dc:creator><pubDate>Wed, 28 Nov 2018 13:48:26 GMT</pubDate></item><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Sun, 11 Nov 2018 22:42:56 GMT]]></title><description><![CDATA[<p dir="auto">That's great news. Please keep up the good work and I look forward to the update. Please see what you can do to add some basic UART bluetooth blocks. I would really like to use the M5stack bluetooth capabilities similarly to the microbit. The microbit adds an easy way to pair to a tablet and send and receive serial messages over bluetooth. This provides an easy path for app development using the board along with a tool like <a href="http://iot.appinventor.mit.edu/#/" target="_blank" rel="noopener noreferrer nofollow ugc">mit app inventor</a> or <a href="https://evothings.com/doc/examples/microbit-sensors.html" target="_blank" rel="noopener noreferrer nofollow ugc">evothings</a> or some such app maker.</p>
]]></description><link>https://community.m5stack.com/post/1975</link><guid isPermaLink="true">https://community.m5stack.com/post/1975</guid><dc:creator><![CDATA[jpilarski]]></dc:creator><pubDate>Sun, 11 Nov 2018 22:42:56 GMT</pubDate></item><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Sun, 11 Nov 2018 07:20:33 GMT]]></title><description><![CDATA[<p dir="auto">hello, in v0.1.0, we will add a block to make float to int</p>
]]></description><link>https://community.m5stack.com/post/1961</link><guid isPermaLink="true">https://community.m5stack.com/post/1961</guid><dc:creator><![CDATA[heybin]]></dc:creator><pubDate>Sun, 11 Nov 2018 07:20:33 GMT</pubDate></item><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Sun, 11 Nov 2018 06:55:59 GMT]]></title><description><![CDATA[<p dir="auto">UIFLOW is doing this which is giving TypeError(can't convert float to int)</p>
<blockquote>
<p dir="auto">start = 0<br />
stop = 200<br />
step = 40<br />
while True:<br />
for X in (float(start) &lt;= float(stop)) and upRange(float(start), float(stop), step) or downRange(float(start), float(stop), step):</p>
</blockquote>
<p dir="auto">It looks like UIFLOW should be doing the following and be casting the variable to an int instead of a float. Can you please update UIFLOW or let me know what I need to do to correct this issue</p>
<blockquote>
<p dir="auto">start = 0<br />
stop = 200<br />
step = 40<br />
while True:<br />
for X in (int(start) &lt;= int(stop)) and upRange(int(start), int(stop), step) or downRange(int(start), float(stop), step):</p>
</blockquote>
]]></description><link>https://community.m5stack.com/post/1960</link><guid isPermaLink="true">https://community.m5stack.com/post/1960</guid><dc:creator><![CDATA[jpilarski]]></dc:creator><pubDate>Sun, 11 Nov 2018 06:55:59 GMT</pubDate></item><item><title><![CDATA[Reply to UIFLOW variable declaration issues - need help on Sat, 10 Nov 2018 09:14:09 GMT]]></title><description><![CDATA[<p dir="auto">Am I correct in thinking that if I want to use the blocks and I want to use variables I have to use while() and not range(). This approach does work but it feels so inefficient.<br />
<img src="https://i.pinimg.com/564x/02/c1/14/02c114239203a94bb281cdf4ccab1e6a.jpg" alt="alt text" class=" img-fluid img-markdown" /></p>
]]></description><link>https://community.m5stack.com/post/1956</link><guid isPermaLink="true">https://community.m5stack.com/post/1956</guid><dc:creator><![CDATA[jpilarski]]></dc:creator><pubDate>Sat, 10 Nov 2018 09:14:09 GMT</pubDate></item></channel></rss>