Asked

Scripts Will Not Run From Previous Synthiam Version Software

I have tried to run both ARC 4.3 and ARC 4.5 with scripts from my previous Synthiam software.    I receive an error code that identifys a LOOP LABEL as not identified.  I have reidentified the LOOP and still indicates an error. I have performed multiple EZB4 resets and removed/reinstalled above software versions to include a computer retart. I am using widows 10 All scripts operated beautifully until I updated this morning.  I tried ARC 2 and problem remains. Any help? I'm desparate. Jack


Related Hardware EZ-B v4

ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

PRO
Synthiam
#1  

If you post code, I can help

#2  
DEVIATION_LEFT = false;

LoopStart:
sleep(1);

if (DEVIATION_LEFT == true) {

  print(DEV_PITCH + "LEFT DEV  ");
  Digital.set(d11, true);
  sleep(1);


}

continue LoopStart;

Thankyou DJ.  I have multiple scripts that normally run.  This is one of them.  I have found that if I open the script up, it gets "corrupted" and sends an error code.  Of the scripts that I did not open since the revision download, they run fine.  The above code error message is LoopStart "undefined". Jack

PRO
Synthiam
#3   — Edited

Unfortunately, that would never have run in any JavaScript environment. The reason is the label needs to be directly before a loop. I believe the confusion you have is moving from EZ-Script to JavaScript and misinterpreting the label: functionality. That's easy to do because EZ-Script was terrible:)

A label: is defined in JavaScript quite differently, see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

And more specifically, someone attempting to use it in the similar fashion and realizing the label: needs to be applied directly before a looping statement, here: https://stackoverflow.com/questions/6393648/why-is-this-labeled-javascript-continue-not-working

Here is your code re-written. Keep in mind, as the code comment says, DEVIATION_LEFT is always false. So the IF condition will never be met.


// loop for ever and don't do anything because DEVIATION_LEFT is always false

var DEVIATION_LEFT = false;

while(true) {

  sleep(1);

  if (DEVIATION_LEFT == true) {

    print(DEV_PITCH + "LEFT DEV  ");
    Digital.set(d11, true);
    sleep(1);
  }
}

Perhaps if you're communicating with other controls, you'd want DEVIATION_LEFT to be public across the entire project. In that case, use getVar() and setVar(). Such as....


// loop for ever and don't do anything because DEVIATION_LEFT is always false
// unless DEVIATION_LEFT is set from another control to TRUE

setVar("$DEVIATION_LEFT", false);

while(true) {

    sleep(1);

  if (getVar("$DEVIATION_LEFT") == true) {

    print(DEV_PITCH + "LEFT DEV  ");
    Digital.set(d11, true);
    sleep(1);
  }
}

#4  

All my scripts are in blockly.  They do not run.  This version of ARC does not run my Blockly Scripts. What am I to do? Jack

PRO
Synthiam
#5   — Edited

Don't use goto/label, as per the manual for JavaScript states. Unless you're using it for the correct intended purpose, which is outlined in the JavaScript manuals.

The solution would be to use the Loop Forever block, which produces while (true) loop

User-inserted image

#6  
PITCHBACK = false;

SCAN:
IR = (ADC.get(adc7));

sleep(1);

if (IR <= 65) {

  PITCHBACK = true;

  continue SCAN;


}

PITCHBACK = false;

continue SCAN;

On this script an error msg "unble to get"(ADC 7). It is connected to the EZB4.  I have tried recoding it using Blockly from this current ARC. My scripts ran perfectly earlier this morning before the download.  Does a  previous version exist that I could use?  I would say that the last update I did was 3-6m ago.  I tried ARC 4.2 with the same results. Thanks Jack

PRO
Synthiam
#7   — Edited

There indeed seems to be a naming mismatch between the Blockly and JavaScript using ADC.get and ADC.getADC. I'll fix that for the next release:). There will be a new Beta release candidate this evening. I recommend switching to that channel

#10  

I have tried ARC 4.6.  I have been able to run my one script using ADC7.  Thankyou. However, the rest of my scripts have multiple GOTO in Blockly.  These do not lend themselves to FOREVER Looping.  These scripts all error with Label not defined.

Does latest ARC support Blockly?

I'm really stuck here.  My project of 3yrs is now bricked because this latest version will not run my scripting.  All 11 scripts were functioning beautifully together this morning before the update.

Is it possible to obtain a previous version so that I may continue my work until your Blockly issues get sorted out? Thankyou very much, Jack

PRO
Synthiam
#11  

Replace the GOTO with LOOP FOREVER. GOTO is not a supported in JavaScript:). I provided examples earlier in this thread for ya

#12  

Ok  Thanks.  I'll set to reworking my Blockly scripts by removing my GOTO commands. Jack

#13  

Hi DJ One more question.  You provided an example of using a Variable globally across the entire project.  This was done in JavaScript. Can you provide an example in Blockly?  I did this often in Blockly with the past ARC revision but cannot seem to get it to work now. Thank you Jack

#15   — Edited

OK thank you DJ.  I was able now to control variables globally.   I downloaded the latest beta. I have reviewed the link that you provided previously:

Quote:

A label: is defined in JavaScript quite differently, see here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label

And more specifically, someone attempting to use it in the similar fashion and realizing the label: needs to be applied directly before a looping statement, here: https://stackoverflow.com/questions/6393648/why-is-this-labeled-javascript-continue-not-working

However I cannot make sense in blockly.  Nothing works for me.  Could I impose for a simple example in Blockly of LABEL, CONTINUE, & BLOCK. Thanks so much. Jack

PRO
Synthiam
#16   — Edited

Stop using the label and continue and use loops instead. Do not use the label because it doesn't seem to apply to your needs.

All you seem to need is are loops. You want code to loop. So use the loop instead of thinking about labels. The examples i provided above have loops.

PRO
Synthiam
#17   — Edited

Here's an example of using public (global) and private variables in a loop...

Notes:

  • notice how a public (Global) variable has a $ (dollar sign) at the beginning. A global public variable means it can be accessed by all scripts.
  • the variable "countThisIsNotPublic" does not start with a $ (dollar sign). Therefore, it only exists within this script. It cannot be accessible by other scripts.
  • see how the main code is within a "loop forever". That will loop for ever, as the name suggests. You can exit the loop with a BREAK. Or you can exit the entire script with a HALT or a RETURN

    User-inserted image

And here's the JavaScript it generates...


countThisIsNotPublic = 0;

while (true) {

  setVar("$MyGlobalVariable", Utility.getRandom(0, 10));if (getVar("$MyGlobalVariable") == 5) {

    print("The random number matched my number");
    break;
  }

  countThisIsNotPublic = (countThisIsNotPublic + 1);
}

print("Break got me here because it breaked out of the loop.");
print("It took " + countThisIsNotPublic + " times to guess my number with random");

#18  

Thanks a million, I think I'm back on track. Jack