| || |
I am using Delphi Script. i need to split a String (ex: XXX,John Y), I need to get each word seperatley... how can i achieve the same.
You can use the BuiltIn.GetListCount and BuiltIn.GetListItem functions to do this. For example:
<font class="small">Code:</font><hr /><pre>
var list, i, delimiter;
list := 'XXX,John Y,third';
delimiter := ',';
for i := 0 to BuiltIn.GetListCount(list, delimiter) - 1 do
Log.Message(VarToStr(i) + ': ' + BuiltIn.GetListItem(list, i, delimiter));
Please see the "BuiltIn.GetListCount" and "BuiltIn.GetListItem" help topics for more information.
I need to comapre two strings, in which one i am passing using variable and another string i need to fetch from the application using OCR functions Gettext method(since that string is inside the Grid). since i am using OCR function i am getting each string with single qoute as precedence (ex:'xxxxxxxxxx)and i am not able to trim or delete the single qoute. If i count the length of the both string manually that will be same, but when i use length(str) method the length of both the string differce. how can i compare this kind of strings using Delphi script please advice me.
Thanks in Advance
You can use the Copy function which returns the given number of characters beginning from the given position in the string:
<font class="small">Code:</font><hr /><pre>...
str := // Obtain the string you need to compare
str := Copy(str, 2, Length(str)); // Remove one character in the beginning of the string.
More information on DelphiScript routines can be found in the "DelphiScript - List of Supported Routines and Variables" help topic.