<?xml version="1.0"?>
<flowgorithm fileversion="2.11">
    <attributes>
        <attribute name="name" value=""/>
        <attribute name="authors" value="Roberto"/>
        <attribute name="about" value=""/>
        <attribute name="saved" value="2020-10-26 10:37:16 AM"/>
        <attribute name="created" value="Um9iZXJ0bzsgUk9CRVJUTy1QQzsgMjAxNi0wMS0xODsgMDg6Mjc6MTAgOyAyNjg2"/>
        <attribute name="edited" value="Um9iZXJ0bzsgUk9CRVJUTy1QQzsgMjAxNi0wMS0xODsgMTA6NTI6NDAgOyAyNjgw"/>
        <attribute name="edited" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIwLTEwLTI2OzEwOjM3OjE2IEFNOzE7MzAzNA=="/>
    </attributes>
    <function name="Main" type="None" variable="">
        <parameters/>
        <body>
            <declare name="N" type="Integer" array="False" size=""/>
            <call expression="LoadArray"/>
            <declare name="LengthStringMax" type="Integer" array="False" size=""/>
            <output expression="&quot;[IT] Grandezza array?&quot; &amp; ToChar(13) &amp; ToChar(10) &amp; &quot;[EN] Array size?&quot;" newline="True"/>
            <input variable="N"/>
            <declare name="v" type="String" array="True" size="N"/>
            <declare name="ch" type="Integer" array="False" size=""/>
            <assign variable="ch" expression="0"/>
            <assign variable="LengthStringMax" expression="0"/>
            <do expression="ch &gt; 2 OR ch &lt;= 0">
                <output expression="&quot;1. [IT] Lunghezza fissa   [EN] Fixed length&quot;  &amp; ToChar(13) &amp; ToChar(10) &amp; &quot;2. [IT] Lunghezza variabile   [EN] Variable length&quot;" newline="True"/>
                <input variable="ch"/>
                <if expression="ch = 1">
                    <then>
                        <output expression="&quot;MAX lunghezza stringa?&quot;" newline="True"/>
                        <input variable="LengthStringMax"/>
                    </then>
                    <else/>
                </if>
            </do>
            <output expression="&quot;[IT] Prima di mescolare&quot;  &amp; ToChar(13) &amp; ToChar(10) &amp; &quot;[EN] Before shuffle&quot;" newline="True"/>
            <call expression="FillArrayString(v, LengthStringMax, ch)"/>
            <call expression="ShowArrayString(v)"/>
            <output expression="&quot;[IT] Dopo mescolato&quot;  &amp; ToChar(13) &amp; ToChar(10) &amp; &quot;[EN] After shuffle&quot;" newline="True"/>
            <call expression="ShuffleArrayString(v)"/>
            <call expression="ShowArrayString(v)"/>
        </body>
    </function>
    <function name="FillArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
            <parameter name="LengthStringMax" type="Integer" array="False"/>
            <parameter name="choice" type="Integer" array="False"/>
        </parameters>
        <body>
            <declare name="i" type="Integer" array="False" size=""/>
            <declare name="s" type="String" array="False" size=""/>
            <declare name="length" type="Integer" array="False" size=""/>
            <declare name="DecimalChar" type="Integer" array="False" size=""/>
            <declare name="CountChar" type="Integer" array="False" size=""/>
            <assign variable="length" expression="size(a)"/>
            <assign variable="CountChar" expression="0"/>
            <assign variable="s" expression="&quot;&quot;"/>
            <for variable="i" start="0" end="length - 1" direction="inc" step="1">
                <if expression="choice = 2">
                    <then>
                        <assign variable="LengthStringMax" expression="random(length) + 1"/>
                    </then>
                    <else/>
                </if>
                <do expression="CountChar &lt; LengthStringMax">
                    <assign variable="DecimalChar" expression="random(123)"/>
                    <comment text="Strings are composed by:&#13;&#10;&#13;&#10;dec 48..57, 65..90, 97..122&#13;&#10;char &quot;0&quot;..&quot;9&quot;, &quot;A&quot;..&quot;Z&quot;, &quot;a&quot;..&quot;z&quot;"/>
                    <if expression="(DecimalChar &gt;= 48 AND DecimalChar &lt;= 57) OR (DecimalChar &gt;= 65 AND DecimalChar &lt;= 90) OR (DecimalChar &gt;= 97 AND DecimalChar &lt;= 122)">
                        <then>
                            <assign variable="s" expression="s &amp; ToChar(DecimalChar)"/>
                            <assign variable="CountChar" expression="CountChar + 1"/>
                        </then>
                        <else/>
                    </if>
                </do>
                <assign variable="a[i]" expression="s"/>
                <assign variable="s" expression="&quot;&quot;"/>
                <assign variable="CountChar" expression="0"/>
            </for>
        </body>
    </function>
    <function name="LoadArray" type="None" variable="">
        <parameters/>
        <body>
            <declare name="Deck" type="String" array="True" size="30"/>
            <declare name="count" type="Integer" array="False" size=""/>
            <for variable="count" start="0" end="9" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;R&quot;&amp;count+1"/>
            </for>
            <declare name="count2" type="Integer" array="False" size=""/>
            <assign variable="count2" expression="1"/>
            <for variable="count" start="10" end="19" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;Y&quot;&amp;count2"/>
                <assign variable="count2" expression="count2+1"/>
            </for>
            <assign variable="count2" expression="1"/>
            <for variable="count" start="20" end="29" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;B&quot;&amp;count2"/>
                <assign variable="count2" expression="count2+1"/>
            </for>
        </body>
    </function>
    <function name="ShowArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
        </parameters>
        <body>
            <declare name="i" type="Integer" array="False" size=""/>
            <declare name="s" type="String" array="False" size=""/>
            <declare name="length" type="Integer" array="False" size=""/>
            <assign variable="length" expression="size(a)"/>
            <assign variable="s" expression="&quot;&quot;"/>
            <for variable="i" start="0" end="length - 1" direction="inc" step="1">
                <if expression="i = length - 1">
                    <then>
                        <assign variable="s" expression="s &amp; ToString(a[i])"/>
                    </then>
                    <else>
                        <assign variable="s" expression="s &amp; ToString(a[i]) &amp; &quot; &quot;"/>
                    </else>
                </if>
            </for>
            <output expression="s" newline="True"/>
        </body>
    </function>
    <function name="ShuffleArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
        </parameters>
        <body>
            <declare name="length" type="Integer" array="False" size=""/>
            <declare name="i" type="Integer" array="False" size=""/>
            <declare name="change" type="Integer" array="False" size=""/>
            <declare name="k" type="Integer" array="False" size=""/>
            <assign variable="length" expression="size(a)"/>
            <for variable="i" start="0" end="length - 1" direction="inc" step="1">
                <assign variable="k" expression="length - i"/>
                <assign variable="change" expression="i + (random(k))"/>
                <call expression="SwapArrayString(a, i, change)"/>
            </for>
        </body>
    </function>
    <function name="SwapArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
            <parameter name="i" type="Integer" array="False"/>
            <parameter name="change" type="Integer" array="False"/>
        </parameters>
        <body>
            <declare name="tmp" type="String" array="False" size=""/>
            <assign variable="tmp" expression="a[i]"/>
            <assign variable="a[i]" expression="a[change]"/>
            <assign variable="a[change]" expression="tmp"/>
        </body>
    </function>
</flowgorithm>
