Community Question

This script has run without errors.

Code:


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 EZ-Builder - 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.

OldBotBuilder
Commented February 2016
@WBS00001,

You
are correct. I miss typed the ControlCommand("Script Manager"' ScriptStart, Speak (phrase") line.
The script has:

Code:

ControlCommand("Script Manager", ScriptStart, Speak (phrase")



Again, the reported error has to do with "Input string was not in a correct format"
from the

Code:

$phrase = ($Answers[$z])

line.

With this latest EZ - Builder release (2016.02.18.02) the Check Syntax button and my script do not work.

With release 2016.01.31.00 Both my script and the Check Syntax work.

With release, 2016.02.18.02 my script and Check Syntax do not work on my computer which is a Dell Latitude E6420 Lap Top running Windows 7 Professional.

OldBotBuilder
Commented February 2016
@JR,
My
project is in the cloud as LESTER 02-19-16 No Camera.

Any help is very much appreciated.
DJ Sures
Commented February 2016
This release will solve the issue: http://www.ez-robot.com/Community/Forum/Thread?threadId=9086

I reviewed your project - neat stuff you're doing. However, i do recommend proper use of brackets. Everything appears to be in a bracket, and i mean everything :)

Brackets are only necessary for overriding order of math operations or parameters for functions.
OldBotBuilder
Commented February 2016
@DJ,

How
do you define the index to an array?
Are they "parameters for functions"?

Is this the proper construct for an array?

Code:


DefineArray(Answers,4)
$Answers[0]=("Phrase 0")
$Answers[1]=("Phrase 1")
$Answers[2]=("Phrase 2")
$Answers[3]=("Phrase 3")



Where did the smiley faces come from?

Wouldn't the proper way to set $phrase to the third element in the array be;

Code:

$phrase=$Answers[2]


?

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

Code:


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...

Code:


$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...

Question
AvatarOldBotBuilder
Asked on Thursday, February 18, 2016