Getrss icon Getrss Fetch RSS via GetRSS command; populates $RSSSuccess, $RSSErrorMsg and arrays $RSSTitles, $RSSDescriptions, $RSSLinks, $RSSDates for scripts. Try it →
Asked — Edited

Array Index Reference Error

This script has run without errors.


ControlCommand("Answer array", ScriptStart)
#Get 1 0f 16 random phrases from the array Answers
$z = (GetRandomUnique(0,15))  
$phrase = ($Answers[$z])
ControlCommand("Script Manager"' ScriptStart, Speak (phrase")

But, now with ARC - Version 2016.02.18.02 I get:
Error on line 4: Input string was not in a correct format.

The last release that this script ran correctly was the one downloaded on 02/02/201.


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
PRO
Synthiam
LinkedIn Thingiverse Twitter YouTube GitHub
#9  

Yes - the second way is correct. Absolutely not the first way... There is an examples folder in ARC and quite a few of the examples are regarding how to use Arrays. ARC array is similar format as all programming languages, as such, and each have their own constructor...


DefineArray($Answers, 4) # your missed the $ dollar sign
$Answers[0] = "This is some data"
$Answers[1] = "Notice how there are no brackets"
$Answers[2] = "None of the examples in any languages of strings use brackets"
$Answers[3] = "Not sure where you got the bracket ideas from"

$phrase = $Answers[3]

# of

$cnt = 2

$phrase = $Answers[$cnt]

Brackets are only used for the reasons stated above, to override math operations or for function parameters. Such as...


$x = (2 / 3) + (4 * 2)

Servo(d0, 20)

You do not use brackets for absolutely any other reason - specifically never used while declaring a string...