Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by VGosine!

Help With Strings

Hello all,

I am working on a script and have worked out all the logic using arduino code and again in VB.net using sdk.

I was wanting to put the script in EZ-Script code but can seem to get what I thought would be the easiest thing working. so here goes.

$sent = "This is a test of something for the robot to say."

lets say you have this String Var.

I need to look at each word. My first thought was Split will do this. but guess what?
You cant split on an empty space.

so next it try to

$value = indexof($sent , " ")
print (substring($sent,0,$value))

Work ok but only finds the first word.

I will need a loop that looks at each word one at a time until i reach the end.

All the code for converting the word to a phonetic so we can get property mouth movement. That part i got working .. I just cant seem to find a way using the function given for doing the simple task of spiting this sentence.

Thanks in advance for you help.

AI Support Bot
Related Content
What i did to avoid the problem with splitting from the space is


$sent[IndexOf($sent," ")+1]="."

so you can create a loop that will replace the space with a period and then use the split function to parse each word into separate variables.
Thanks ,

how would you determine how many elements (or words) you had in the sentence?) I can use a char other than . because i will need the . to know end of sentence. so I will use something uncommon like a PIPE (|) or something. My issue is the knowing how many to grab.

I relay wish the split function would just return an array() if there is no index.

when i get each word i have to talk though that too but i can use length to determine how many letters to evaluate. its the how many words in the sentence that is causing my issues.
I am new around here as far as posting but I have been reading the forums for a while.

I would try a regular expression for this type of string manipulation.
Once you get the setup right it will parse strings consistently for you in the way you want. The regular expression class has a matches collection that you can then iterate through and you can examine the individual strings that matched your criteria.

An excellent tutorial on Regex can be found here:

I would just take time to read it in order so that you get an understanding of how the engine works.

Hope this helps,
So this should do what you want done. It isn't the most elegant solution and there's probably a better way of doing it but it works.:)


$sent="This is a test of something for the robot to say."

REPEATWHILE($temp!="." )
IF ($temp=" " )


$sent[IndexOf($sent," ")+1]="|"


I know you said you need the "." at the end of the sentence so we can simply reset the sentence to how it was before, OR you can use a temporary variable that stores everything that's in the sentence and then modify the temporary variable, leaving the original untouched.
Hi I took a minute to work this out and it works for any group of letters followed by a space. I haven't worked in VB in several months so there might be syntax error or two (sorry!).

If you are using vb.net:

Dim pattern As String = "[a-zA-Z]* "
'a test sentence
Dim sentence As String = "Jack is a Dog"
Dim wordFinder As Regex = New Regex(pattern)
Dim wordLength As Integer = 0
For Each word As Match In wordFinder.Matches(sentence)
wordLength = word.Length
Thanks guy.
I will work this out and post code later as the solution we used.