ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

United Kingdom
#1  

Goto() performs the function of what the basic command Gosub is... We already have it.


# 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


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.


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