EZ-B V4 Info icon EZ-B V4 Info Displays EZ-B v4 internal temperature and battery voltage, shows built-in battery monitor and LiPo protection settings in Connection Control. Try it →

ARC Pro

Upgrade to ARC Pro

ARC Pro will give you immediate updates and new features needed to unleash your robot's potential!

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()