Rural Geek
Canada
Asked
— Edited
Can you use and's and or's when you are wrting a script? I.E. if(d2=0) and if(getping => 30) result i.e. forward()
I am trying to write a script but its seems a very long way of doing it if I have to type each if or else statment with the same result after each one. I mean i have a bunch of IF's that will result in the same action like stop(). I am just wondering if there is a way to write it like
IF() or IF() or IF() or IF() STOP()
or do I HAVE to write it like.
IF() STOP() ElseIF() STOP() ElseIF() STOP()
I am just used to writing industrial plc code the first 2 ways and wonding if it can be done in EZ-Script?
Thank you for any help. Jason
To the right of the script editor is the EZ-Script Manual, which contains help for each command. You can scroll through to find the specific command, or use the Search Feature on the top of the window. The command you are looking for is...
[feature] If (Value Condition Value )
:)
Ah crap DJ I didn't read it right. Sorry for the brain fart. Thanks for the help.
DJ, I heard what you said and got it figured out after reading the manual.
But I missed something again.
This the main forward script
:100
this will get the ping data and
and put it into a variable
$MAIN_PING = GetPing(d0,d0) $LEFT_PING = GetPing(d1,d1) $RIGHT_PING = GetPing(d2,d2)
#Using the Sharp sensor for edge detection and #put the data into a variable $FRONT_EDGE = GetADC(adc3)
Forward(50)
If($MAIN_PING 41 or $LEFT_PING > 41 or $RIGHT_PING > 41 or $FRONT_EDGE > 41) Goto(100)
Sleep(100)
when I run this script it runs through the ifs at least it looks like right but it solves the first if and stops the bot then loops around again and starts the bot forward then solves the first if again and stop it again. It just keeps doing that.
Now what I am trying to do is for it to stop only when the first if is solved, but it seems like it looks at the if and then just runs the stop. What am I missing to tie that stop command to the if statement.
Thanks again