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

What Is Wrong With This Script

for some reason I can not get the following simple statement to work

Code:


$Test = "123 123 123"
repeatuntil(contains($Test," ") != true)
Print($Test)
endrepeatuntil

I get the following error

Code:


8: repeatuntil(contains($Test," ") = true)
> Error on line 8: Missing ) in Expression


I have tried using repeatWhile also same result.

I just don't see what I am missing


ARC Pro

Upgrade to ARC Pro

Experience the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

PRO
USA
#2  
if I replace the Repeat statement with an IF statement it works, but I want to preform a loop to count the spaces in the sentence is the finial goal.
PRO
USA
#3  
It seems a Bug, does not work if the function has two parameters.

no errors:

Code:


$value=-1.2345
repeatwhile(Abs($value)>0)
print("value="+$value)
$value=0
endrepeatwhile


same error:

Code:


$value=1.2345
repeatwhile(Round($value,1)>0)
print("value="+$value)
$value=0
endrepeatwhile


EDIT: The problem is common to RepeatWhile and RepeatUntil statements.
PRO
USA
#4  
Thanks PTP,
Good to know its not just me. I am sure DJ will have it corrected first chance he gets. Until then I will use a if statement and a loop counter.
I am surprised this went so long without being reported.
PRO
Synthiam
#5  
If that syntax parser bug in repeat didn't exist, the code still wouldn't work. It would loop for ever... for infinite and beyond! as Buzzzz would say from Toy Story.

Use the new Count() function from this release: http://www.ez-robot.com/Community/Forum/Thread?threadId=10983

Code:


$haystack = "These are some words"

# how many words are in the haystack? Count by blank space
$cnt = Count($haystack, " ")

print($cnt + " words")
PRO
USA
#6  
@DJ
Count function how did I miss that!
That is a bit shorter than I was doing it.

Code:


$WordCount = 1
$LetterCount = 0
$TestLength = Length($HumanSaid)
:WordCountLoop1
if(SubString($HumanSaid,$LetterCount,1) != " ")
$LetterCount = $LetterCount + 1
Print($LetterCount)
else
$LetterCount = $LetterCount + 1
$WordCount = $WordCount + 1
Print($WordCount)
endif
if($TestLength > $LetterCount)
goto(WordCountLoop1)
endif


Thanks again DJ.
PRO
Synthiam
#7  
You can do this...

Code:


$haystack = "Here are some words for you to parse"

# Get the number of words separated by blank space
$wordCount = count($haystack, " ")

REPEAT ($cnt, 0, $wordCount, 1)

$word = split($hayStack, " ", $cnt)

print($word)

ENDREPEAT