Welcome to Synthiam!

The easiest way to program the most powerful robots. Use technologies by leading industry experts. ARC is a free-to-use robot programming software that makes servo automation, computer vision, autonomous navigation, and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by Rich!

Request To Ez-Robot

GOSUB Function , Please! I think that it would be very useful and we need it. Just my two cents.
Thanks,
;)


ARC Pro

Upgrade to ARC Pro

Synthiam ARC Pro is a cool new tool that will help unleash your creativity with programming robots in just seconds!

AI Support Bot
Related Content
Synthiam
United Kingdom
#1  
Goto() performs the function of what the basic command Gosub is... We already have it.

Code:


# Some code
Goto(checksensors)
# Some more code
...
...
# In case of an error stop the script before any sub routines
Halt()

# Sub routines
:checksensors
$sensor1 = GetADC(ADC0)
$sensor2 = GetPing(D0, D1)
$sensor3 = Httpget("http://192.168.1.150/currentroomtemp.php";)
Return()
#2  
Will it return to exactly from where it was called and go to the next line of code?
United Kingdom
#3  
Yep

Example with line numbers so I can explain the order of lines executed

Code:


1 Print("Hello World")
2 Goto(part1)
3 Print("Goodbye Worlds")
4 Halt()
5 :part1
6 Print("Hello Another World")
7 return()


This will run the code in the following order; 1, 2, 5, 6, 7, 3, 4 and the output would be;
Hello World
Hello Another World
Goodbye Worlds

Try it, open a script control and paste the following code in (not the one above with line numbers, it wont like it), then test the script and look in the right of the dialogue.

Code:


Print("Hello World")
Goto(part1)
Print("Goodbye Worlds")
Halt()
:part1
Print("Hello Another World")
Return()