Asked — Edited
Resolved Resolved by DJ Sures!

Split Does Not Work

This code works as expected:

1: ClearVariables() 
2: $Statement = "one,two,three"
3: $token1 = Split($Statement, ",", 0)
4: $token2 = Split($Statement, ",", 1)
5: $token3 = Split($Statement, ",", 2)

The code below does not work:

1: ClearVariables() 
2: $Statement = "one two three"
3: $token1 = Split($Statement, " ", 0)
4: $token2 = Split($Statement, " ", 1)
5: $token3 = Split($Statement, " ", 2)

Line 3 is executed but does not get the token "one" and line 4 generated the error:


Error on line 4: Error splitting 'one two three' with SplitChar: '' to field #1. Index was outside the bounds of the array.


Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

South Africa

I don't know much about coding but could t have something to do with the comma because the first code has a comma in between one and two and two and three where as the second code does not have a comma on line 2



Yes and no. Yes in that you are correct that there is a comma in one example and a space in the next example and that is why it is not working. But no, because it should still work with a space between the words instead of a comma. As long as you use a space character in the Split() function instead of the comma it should work the same. So, DJ is checking out why the space character separator is not working.


fixed in next release

(i'm having a productive flight home)




Plane just landed - so I'll have the new release up when I get home.