ARC Pro

Upgrade to ARC Pro

Join the ARC Pro community and gain access to a wealth of resources and support, ensuring your robot's success.

PRO
Canada
#1  

Yes, you can merge three Blockly scripts into one in ARC. While Blockly doesn't have a direct "merge" function, you can achieve this by manually combining the blocks from each script into a single Blockly workspace. Here's a step-by-step guide to help you merge your Blockly scripts:

Step-by-Step Guide to Merging Blockly Scripts

  1. Open Your ARC Project:

    • Launch ARC and open your project that contains the Blockly scripts you want to merge.
  2. Add a New Script Skill:

    • Go to Project > Add Skill > Scripting > Script.
    • This will add a new Script skill to your project.
  3. Open Blockly Editor:

    • Click on the gear icon of the newly added Script skill to open its settings.
    • Select the Blockly tab to open the Blockly editor.
  4. Load the First Blockly Script:

    • Click on the Load Worksheet button and load the first Blockly script you want to merge.
  5. Copy Blocks from the First Script:

    • Select all the blocks in the Blockly workspace (you can click and drag to select multiple blocks).
    • Right-click and choose Copy to copy the selected blocks.
  6. Open the New Script Skill Again:

    • Go back to the new Script skill's Blockly editor.
    • Right-click in the Blockly workspace and choose Paste to paste the copied blocks.
  7. Repeat for the Other Scripts:

    • Repeat steps 4 to 6 for the remaining Blockly scripts you want to merge.
    • Ensure that you paste the blocks sequentially to maintain the logical flow of your combined script.
  8. Save the Merged Script:

    • Once you have pasted all the blocks from the three scripts, arrange them as needed to ensure they execute in the correct order.
    • Click the Save Worksheet button to save your merged Blockly script.
  9. Test the Merged Script:

    • Go back to the main window of the Script skill and click the Start button to execute the merged script.
    • Verify that the script runs as expected and make any necessary adjustments.

Example of Combining Blockly Scripts

Here's a visual representation of how you might combine three simple Blockly scripts:

  1. Script 1:

    <block type="controls_if">
      <value name="IF0">
        <block type="logic_compare">
          <field name="OP">EQ</field>
          <value name="A">
            <block type="variables_get">
              <field name="VAR">x</field>
            </block>
          </value>
          <value name="B">
            <block type="math_number">
              <field name="NUM">10</field>
            </block>
          </value>
        </block>
      </value>
      <statement name="DO0">
        <block type="text_print">
          <value name="TEXT">
            <block type="text">
              <field name="TEXT">x is 10</field>
            </block>
          </value>
        </block>
      </statement>
    </block>
    
  2. Script 2:

    <block type="controls_repeat_ext">
      <value name="TIMES">
        <block type="math_number">
          <field name="NUM">5</field>
        </block>
      </value>
      <statement name="DO">
        <block type="text_print">
          <value name="TEXT">
            <block type="text">
              <field name="TEXT">Hello</field>
            </block>
          </value>
        </block>
      </statement>
    </block>
    
  3. Script 3:

    <block type="variables_set">
      <field name="VAR">y</field>
      <value name="VALUE">
        <block type="math_arithmetic">
          <field name="OP">ADD</field>
          <value name="A">
            <block type="variables_get">
              <field name="VAR">x</field>
            </block>
          </value>
          <value name="B">
            <block type="math_number">
              <field name="NUM">5</field>
            </block>
          </value>
        </block>
      </value>
    </block>
    

Merged Script:

<xml xmlns="https://developers.google.com/blockly/xml">;
  <block type="controls_if" x="10" y="10">
    <value name="IF0">
      <block type="logic_compare">
        <field name="OP">EQ</field>
        <value name="A">
          <block type="variables_get">
            <field name="VAR">x</field>
          </block>
        </value>
        <value name="B">
          <block type="math_number">
            <field name="NUM">10</field>
          </block>
        </value>
      </block>
    </value>
    <statement name="DO0">
      <block type="text_print">
        <value name="TEXT">
          <block type="text">
            <field name="TEXT">x is 10</field>
          </block>
        </value>
      </block>
    </statement>
  </block>
  <block type="controls_repeat_ext" x="10" y="110">
    <value name="TIMES">
      <block type="math_number">
        <field name="NUM">5</field>
      </block>
    </value>
    <statement name="DO">
      <block type="text_print">
        <value name="TEXT">
          <block type="text">
            <field name="TEXT">Hello</field>
          </block>
        </value>
      </block>
    </statement>
  </block>
  <block type="variables_set" x="10" y="210">
    <field name="VAR">y</field>
    <value name="VALUE">
      <block type="math_arithmetic">
        <field name="OP">ADD</field>
        <value name="A">
          <block type="variables_get">
            <field name="VAR">x</field>
          </block>
        </value>
        <value name="B">
          <block type="math_number">
            <field name="NUM">5</field>
          </block>
        </value>
      </block>
    </value>
  </block>
</xml>

By following these steps, you can effectively merge multiple Blockly scripts into one within ARC. If you encounter any issues or need further assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#2  

@Athena. I don't think you have tried this course of action because there are some errors with it. Open Blockly Editor:

Click on the gear icon of the newly added Script skill to open its settings.                                     (No gear icon -you must mean ...) Select the Blockly tab to open the Blockly editor. Load the First Blockly Script:

Click on the Load Worksheet button and load the first Blockly script you want to merge. Copy Blocks from the First Script:                                                                                                 (This is fine use Load Workspace)

Select all the blocks in the Blockly workspace (you can click and drag to select multiple blocks). Right-click and choose Copy to copy the selected blocks.                                                            (Here is the problem you cannot right click Copy) Open the New Script Skill Again:

Go back to the new Script skill's Blockly editor. Right-click in the Blockly workspace and choose Paste to paste the copied blocks.                   (Cannot Paste)

I realize ARC is limited to what it can do but maybe this will start a conversation for a workaround. I can work in both languages but I find my brain works better with Blockly for editing purposes and speed.

PRO
Synthiam
#3  

What you described are functions.

PRO
Canada
#4  

Thank you for pointing out the issues with the initial steps. You're correct that ARC's Blockly editor does not support right-click copy and paste functionality. Let's explore a more accurate approach to merging Blockly scripts within ARC.

Alternative Approach to Merging Blockly Scripts

Since direct copy-pasting within the Blockly editor isn't possible, we can use a workaround by manually combining the scripts. Here's a revised step-by-step guide:

  1. Open Your ARC Project:

    • Launch ARC and open your project that contains the Blockly scripts you want to merge.
  2. Add a New Script Skill:

    • Go to Project > Add Skill > Scripting > Script.
    • This will add a new Script skill to your project.
  3. Open Blockly Editor:

    • Click on the ... (three dots) of the newly added Script skill to open its settings.
    • Select the Blockly tab to open the Blockly editor.
  4. Manually Combine Scripts:

    • Load the First Blockly Script:
      • Click on the Load Workspace button and load the first Blockly script you want to merge.
      • Note down or take a screenshot of the blocks and their arrangement.
    • Load the Second Blockly Script:
      • Click on the Load Workspace button again and load the second Blockly script.
      • Note down or take a screenshot of the blocks and their arrangement.
    • Load the Third Blockly Script:
      • Repeat the process for the third Blockly script.
  5. Recreate the Combined Script:

    • Using the notes or screenshots, manually recreate the blocks from all three scripts in the new Blockly workspace.
    • Ensure that you arrange the blocks sequentially to maintain the logical flow of your combined script.
  6. Save the Merged Script:

    • Once you have recreated all the blocks from the three scripts, click the Save Workspace button to save your merged Blockly script.
  7. Test the Merged Script:

    • Go back to the main window of the Script skill and click the Start button to execute the merged script.
    • Verify that the script runs as expected and make any necessary adjustments.

Example of Combining Blockly Scripts

Here's a visual representation of how you might combine three simple Blockly scripts:

  1. Script 1:

    <block type="variables_set" inline="true">
      <field name="VAR">x</field>
      <value name="VALUE">
        <block type="math_number">
          <field name="NUM">10</field>
        </block>
      </value>
    </block>
    
  2. Script 2:

    <block type="text_print">
      <value name="TEXT">
        <block type="text">
          <field name="TEXT">Hello</field>
        </block>
      </value>
    </block>
    
  3. Script 3:

    <block type="variables_set" inline="true">
      <field name="VAR">y</field>
      <value name="VALUE">
        <block type="math_arithmetic">
          <field name="OP">ADD</field>
          <value name="A">
            <block type="variables_get">
              <field name="VAR">x</field>
            </block>
          </value>
          <value name="B">
            <block type="math_number">
              <field name="NUM">5</field>
            </block>
          </value>
        </block>
      </value>
    </block>
    

Merged Script:

<block type="variables_set" inline="true">
  <field name="VAR">x</field>
  <value name="VALUE">
    <block type="math_number">
      <field name="NUM">10</field>
    </block>
  </value>
</block>
<block type="text_print">
  <value name="TEXT">
    <block type="text">
      <field name="TEXT">Hello</field>
    </block>
  </value>
</block>
<block type="variables_set" inline="true">
  <field name="VAR">y</field>
  <value name="VALUE">
    <block type="math_arithmetic">
      <field name="OP">ADD</field>
      <value name="A">
        <block type="variables_get">
          <field name="VAR">x</field>
        </block>
      </value>
      <value name="B">
        <block type="math_number">
          <field name="NUM">5</field>
        </block>
      </value>
    </block>
  </value>
</block>

By following these steps, you can effectively merge multiple Blockly scripts into one within ARC. If you encounter any issues or need further assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
#5  

@Athena The Load Workspace clears out what is already there and then fills it in with the particular new script. Maybe this will be adjusted in the future to add to the script rather than clear it out and put a new one in.This would take care of it.   @DJ I appreciate the input but on this one but it is not a scenario where it keeps calling upon certain variables in the functions. I am just trying to combine three scripts and put a while in between them so that each one executes nice and orderly. I did combine them all in Javascript and it works very nicely. Since you brought up what looks like it could be similar to a human machine interface (hmi), will there be the ability in the future ARCx to take your remote app and improve/customize upon it with this blocky type programming? Having thought about it a bit it is most likely not because that is "Beyond Blockly" type programming and it already started with Javascript.

PRO
Canada
#6  

Thank you for your patience and for providing more context.You're right that the current functionality of the Load Workspace button in ARC's Blockly editor replaces the existing script rather than appending to it. This limitation makes it challenging to merge multiple Blockly scripts directly within the editor.

Given the current constraints, here are a couple of alternative approaches you can consider:

Alternative 1: Use JavaScript for Merging

Since you've already successfully combined the scripts in JavaScript, you can continue using JavaScript for merging. Here's a step-by-step guide to help you transition from Blockly to JavaScript:

  1. Convert Each Blockly Script to JavaScript:

    • Open each Blockly script in the Blockly editor.
    • Click on the "JavaScript" tab to view the generated JavaScript code.
    • Copy the JavaScript code for each script.
  2. Combine the JavaScript Code:

    • Create a new Script skill in ARC.
    • Open the Script skill's editor and paste the JavaScript code from each Blockly script sequentially.
    • Add any necessary control flow logic (e.g., while loops) to ensure the scripts execute in the desired order.
  3. Test the Combined Script:

    • Save and run the combined script to verify that it works as expected.

Alternative 2: Manually Recreate the Combined Script in Blockly

If you prefer to stay within the Blockly environment, you can manually recreate the combined script by following these steps:

  1. Open a New Blockly Workspace:

    • Add a new Script skill in ARC.
    • Open the Blockly editor for the new Script skill.
  2. Manually Recreate the Blocks:

    • Open each of your existing Blockly scripts one by one.
    • Note down or take screenshots of the blocks and their arrangement.
    • Manually recreate the blocks from each script in the new Blockly workspace, ensuring they are arranged sequentially.
  3. Add Control Flow Logic:

    • Add any necessary control flow logic (e.g., while loops) to ensure the scripts execute in the desired order.
  4. Save and Test the Combined Script:

    • Save the combined Blockly script.
    • Run the script to verify that it works as expected.

Future Improvements

Regarding your question about future improvements and the potential for more advanced customization in ARCx, it's always a good idea to keep an eye on updates from Synthiam. The platform is continuously evolving, and new features are regularly added based on user feedback and technological advancements.

If you have specific feature requests or suggestions, you can also consider reaching out to Synthiam's support or community forums to share your ideas. This can help influence future development and ensure that the platform continues to meet the needs of its users.

If you need further assistance or have any other questions, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#7  
  1. Put the script in a script robot skill or script collection robot skill

  2. from another script, call the ControlCommand to execute the script in a loop

#8  

Yes that is what I have been doing but with that you have to have a trigger/variable for when it finishes and then use ControlCommand again, trigger again  then do do it again for a third time to have them synchronized.  I was just trying to clean it up and use ControlCommand() one time. Unless maybe there is a way to have.... actually I could just put the next ControlCommand at the end each script just before it shuts off. Thanks.