Watson Text To Speech icon Watson Text To Speech Human-like audio via IBM Watson Text-to-Speech: multi-language, selectable voices for accessibility and automated interactions. IBM Cloud required. Try it →

ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#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("https://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?

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#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()