I'm having difficulty manipulating strings in my scripts. Specifically, I need to use a substring function and a split (tokenizer) function. I'm able to read a file from memory line-by-line, but I get the non-printable line terminators (CR/LF) at the end of my strings, and I need to cut these off. I also need to split a string on a delimiter. I've found the following page on the AngelScript site:
http://www.angelcode.com/angelscript/sd ... tring.html
which has the two functions I need, but the compiler does not seem to like these. Could you please tell me if these are compatible with PowerVision scripting and if so explain how to use them? Any help would be much appreciated.
Scripting - String Manipulation
- pbj
- Posts: 10
- Joined: Mon Oct 11, 2010 3:02 pm
- jtilley
- Enovation Controls Development
- Posts: 31
- Joined: Wed Sep 08, 2010 10:02 am
Re: Scripting - String Manipulation
The substring and split string functions are not available in the PowerVision AngelScript implementation. The string available in scripting is the AngelScript string (STL) object.
Unfortunately, this means that you'll have to create any string handling utilities you need manually. However, AngelScript does allow a string to be treated like a character array, so you can use that to iterate through the string and parse it. I've attached a file containing a few string utilities that were written in AngelScript for a PowerVision configuration. You should be able to use the getCsvFields function as an example of how to split a string on a delimiter.
As far as removing the line terminators, the string.resize(int length) function should work for that. For instance would remove the last two characters off a string.
Let me know if you have any questions.
Unfortunately, this means that you'll have to create any string handling utilities you need manually. However, AngelScript does allow a string to be treated like a character array, so you can use that to iterate through the string and parse it. I've attached a file containing a few string utilities that were written in AngelScript for a PowerVision configuration. You should be able to use the getCsvFields function as an example of how to split a string on a delimiter.
As far as removing the line terminators, the string.resize(int length) function should work for that. For instance
Code: Select all
str.resize(str.length() - 2)
Let me know if you have any questions.
- Attachments
-
- stringUtils.cpp
- AngelScript string utilities
- (3.62 KiB) Downloaded 83 times
Joe Tilley
Software Engineer
FW Murphy
Software Engineer
FW Murphy