Asked — Edited

What Is Wrong With This Script

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


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

I get the following error


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

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

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:


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

same error:


$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: https://synthiam.com/Community/Questions/10983


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


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


$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