Demonstrations of BlocklyToSmartPascal

This is the first of many pages of demonstrations of BlocklyToSmartPascal. This demonstration creates an array of the months from a comma-separated string then prints all of the elements of the array. See below a screenshot, the corresponding XML code of the blocks and the generated Smart Pascal code.

The blocks

The blocks

XML Code of Blocks

<xml xmlns="http://www.w3.org/1999/xhtml">
  <block id="Qj([9d/uI)+1vsyp+MU%" type="procedures_defnoreturn" y="-4562" x="-237">
    <mutation>
      <arg name="strInputArray"></arg>
    </mutation>
    <field name="NAME">PrintStringArray</field>
    <statement name="STACK">
      <block id="z2Y%;T,q|3EIt2T=,{IS" type="controls_forEach">
        <field name="VAR">i</field>
        <value name="LIST">
          <block id="4%%ydTjL5GAS!E}!7bza" type="variables_get">
            <field name="VAR">strInputArray</field>
          </block>
        </value>
        <statement name="DO">
          <block id="EJa8(9[D+dT(Q|6[KeX8" type="text_print">
            <value name="TEXT">
              <shadow id="6kQ_ca7oscqqk8~Rj}|0" type="text">
                <field name="TEXT"></field>
              </shadow>
              <block id="=KcX(6TKB2F[l3s1sOf^" type="variables_get">
                <field name="VAR">i</field>
              </block>
            </value>
          </block>
        </statement>
      </block>
    </statement>
  </block>
  <block id=",jZ-K_zNW/Y$-F=RD44," type="variables_set" y="-4437" x="-237">
    <field name="VAR">strMonthNames</field>
    <value name="VALUE">
      <block id="5*233IYf]j!{ViJ|g_?s" type="text">
        <field name="TEXT">January,February,March,April,May,June,July,August,September,October,November,December</field>
      </block>
    </value>
    <next>
      <block id="@2.P.k)s-22(YJZy|.Jt" type="variables_set">
        <field name="VAR">strMonthArray</field>
        <value name="VALUE">
          <block id="M~SaNI/V.Wg]wHQGltNg" type="lists_split">
            <mutation mode="SPLIT"></mutation>
            <field name="MODE">SPLIT</field>
            <value name="INPUT">
              <block id="1YAVD`S.Uhyz.2VugTu*" type="variables_get">
                <field name="VAR">strMonthNames</field>
              </block>
            </value>
            <value name="DELIM">
              <shadow id="+3-Xw55Tkr53jV00:4Sb" type="text">
                <field name="TEXT">,</field>
              </shadow>
            </value>
          </block>
        </value>
        <next>
          <block id="=MYZbq#94GXm|/GR*nsi" type="procedures_callnoreturn">
            <mutation name="PrintStringArray">
              <arg name="strInputArray"></arg>
            </mutation>
            <value name="ARG0">
              <block id="[RC%@q2gYbg$o2dNzjCa" type="variables_get">
                <field name="VAR">strMonthArray</field>
              </block>
            </value>
          </block>
        </next>
      </block>
    </next>
  </block>
</xml>  

Generated Smart Pascal Code

var strInputArray: TStrArray;
var strMonthArray: TStrArray;
var strMonthNames: String;


procedure PrintStringArray(strInputArray: TStrArray);
begin
  for var i in strInputArray do
  begin
    Console.writeln(i);
  end;
end;



strMonthNames := 'January,February,March,April,May,June,July,August,September,October,November,December';
strMonthArray := StrSplit(strMonthNames, ',');
PrintStringArray(strMonthArray);
    
Programming - a skill for life!

A generator to help you to code in Smart Pascal