
mooshroom27
USA
Asked
— Edited

So I am coding some multi color recognition software in ez-script, but whenever I run the code it says that I am missing a binary operator in the command used to search for a color. pleass note that am running this code on a pc and not on the ez-b code is below ControlCommand("Camera", CameraMultiColorTrackingEnable) If($CameraObjectColor()= "color" ) Print("TWO") Elseif($CameraObjectColor()="color") Print("ONE") EndIf
Remove the brackets from after the variable $CameraObjectColor
Also, you seem to be asking (in the script) the same thing for the IF and the ElseIF, however that wont throw an error since the IF will take priority and it will PRINT("TWO")
Hopefully that solves it however if it doesn't please post your project's .ezb file and I'll take a look at it (just one script isn't always enough since you will have other variables set up such as the custom colours.
Thanks, the code works now, and I can now pass coding class finals!


Your code works fine in ARC... When you check syntax, anyway ...
So, along the same vane... (at the risk of being a thread jacker and possibly a dumb ass), how does one set up user variables in ARC? Or even can you? Or do you even have to? ARC is definitely not like any programing software I have ever used in the past....
$variable = "whatever you want it to be"
$x = 1 $y = 7 $z = GetADC(ADC0) $a = GetRandom(0,100) $calc1 = $y * $a $text = "This is some text"
That's just a few ways
Basically, all variables begin with the $ character and then are a group of characters without spaces.
$xyz = will set the variable to whatever is after the =. That could be a number, a string (in quotes), a command such as GetADC, GetRandom, GetPWM etc. a calculation such as 1 * 2 + 3 or a calculation with variables like $voltage / $current. You can also use $x++ to increase $x by 1 (I presume it only works for decimal numbers though).
If you want a specific example give me the scenario and I'll explain it. Without a scenario it's difficult to cover every single method of creating variables. A good example to look at for use of variables and setting them are my Ping Roam scripts and my Battery Monitor script. Battery Monitor does some simple calculations too.
So you don't have to declare variables a head of time? You just start using them in the script, then?
Thanks Rich
Just define variables at the top of your script. Ideally an intit script.
This will in theory move the servo on D0 back and forth between 75 and 25.
Hope that helps
[edit]
Rich and I must have been typing at the same time. LOL
Once you define a variable it exists until the session ends. You can then call it and change it from any other script or control.
Correct, no need to declare variables ahead of time. Just make sure if you have a command which uses a variable that it has been set before hand otherwise it will say it doesn't know what $variablename is.
For instance, run this code and it will throw an error;
However, if you run this code it will work
If the variable exists in another script or control ($soundservo, $CameraObjectColor etc) make sure the other script or control has run before you run the script or it will throw an error.
@Antron007 @Rich Awesome, thanks...
Now just wish I had an EZB board to start fiddlin' with...
You don't need an EZ-B to write scripts
Although it does make it that much more awesome to see something move from a script but you can still sort out the backbone of the script(s) without an EZ-B.
This one for example doesn't even control anything yet (and is a little bit of a hint at what one of my future build's main function will be).
I'll check it out Rich... Cheers
Edit... Ok, LOL.... I can see how ARC can keep one busy indefinitely...
R
Looks like you're making a Robo-Bartender. Very keen