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
United Kingdom
Asked — Edited

Command Syntax For Data Retrieval

It seems a lot of people are getting a little confused over the script commands for receiving data and have noticed the syntax is incorrect. So it's tutorial time again:)

Basically, the common mistake is to assume the command for receiving ADC, HTTP etc. data is like;

Code:

HTTPGet("http://192.168.0.100/temp.cgi")


However that will return an invalid syntax.

If you think about it, that is no different to having a line of code which is;

Code:

23


The returned data in the HTTPGet example could be 23, so what use is 23 on it's own? You have to remember that all get/fetch commands should be looked at as though they are data and not commands. The data alone will be of no use if not used as part of a process or stored as a variable for later use.

The correct syntax would be;

Code:

$temp = HTTPGet("http://192.168.0.100/temp.cgi")


or as part of a function

Code:

IF(HTTPGet("http://192.168.0.100/temp.cgi";) > 23)
SayWait("Man, it's hot in here!")
ElseIf(HTTPGet("http://192.168.0.100/temp.cgi";) < 18)
SayWait("Brrrr, it's cold in here!")
Else
SayWait("It''s perfect in here")
EndIf


The same applies to all commands that will fetch data from somewhere including;
GetPWM
GetServo
GetServoSpeed
GetSpeed
GetSpeedLeft
GetSpeedRight
GetCPUTemp
GetVoltage
GetADC
GetRandom
GetRandomUnique
GetDigital
GetPing
HTTPGet
GetChatAt
GetByteAt
GetByte
GetAsByte
GetBit
GetVolume
I2CRead
UARTRead
FileReadEnd
FileReadChar
FileReadLine
FileReadAll
FileReadLineRandom

And possibly more, I think I listed them all but with ARC updates so often it probably wont stay that way.

If you get a syntax error read the help on the right of the script dialogue, there are always examples:)



Update: That said, HTTPGet() will work without assigning variables etc. since it can be used to operate devices and websites etc. such as NotifyMyAndroid. However if used to return data it must be assigned to a variable or used as part of an operation/process.


ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#1  
Great compilation of commands that require that fetch data, I had no idea there were so many! ....I certainly stumbled on the I2CRead command earlier :( Thanks for this short but ***Sweet*** tutorial!
United Kingdom
#2  
Yeah this one is short and sweet, I just wanted to explain that some commands need a little more to them than just the command on a single line. I plan to cover those commands a little better at some point however need some kind of script idea to follow where I can use them.

Some are V4 specific, the GetVoltage, GetCPUTemp and UARTRead, so until Six arrives I can only assume and get that part ready to test before it's posted. But the rest I'll cover with a bunch of examples shortly (in the mean time there are examples in ARC's examples folder).
#3  
I'd be interested in knowing what the new command UARTRead does and its applications but DJ was not "talking":)
#4  
Thanks Rich. And btw nice new profile pic.:)