Command Help regarding GetSubstring

Hi all,

I was wondering whether, throughout different versions of PAC, the code for the GetSubString has been changed but the command help hasn’t been updated? As I see it now, how we write it in OptoScript : GetSubstring(StringVariable, Start Index, number of characters in the SubString, SubStringVariable). In the past versions, could it have been : GetSubstring(StringVariable, Start Index, End Index, SubString Variable) ?

Thanks all,
innotech01

Hello innotech01,

In general, we try not to make changes like that (at least not on purpose) to commands since your code would get broken by a firmware upgrade.

Why do you ask? What are you seeing?

-OptoMary

Hi OptoMary,

I was wondering because as of now we have a String of length 48, let’s call this string A , and we can use the GetSubString command and go from index 26, with a character length of 31, and put that substring into a new string, B. This would not make sense as the string is only 48 characters long and 26+31 > 48 but somehow our code works. The string is suppose to be only 5 characters long. This part of the code was written about 10 years ago.

From what I write now, I would say : GetSubstring(A,26,5,B). This makes more sense, and this works also. So I was wondering whether there has been a change but the CommandHelp has not been updated.

If you request more characters than are left at the end of string A, the command just gives you the rest of the string. (Besides making commands backwards/forwards compatible, we also try to make them as forgiving as possible.)