Friday, August 15, 2008

SilkTest - Convert String to List of String

Last month, my friend asked a silktest function similar to Split in QTP. Silktest does not have any built-in function. I thought to develop a function for this need. See the 4test code below:

4Test Code - Convert STRING contents as List of STRING

[+] List of STRING SplitToList (String sInput, String sDelimiter) [ ] List of STRING lsReturn = {} [ ] Integer iIndex =1 [ ] [+] while (GetField (sInput,sDelimiter,iIndex) != "") [ ] ListAppend (lsReturn, GetField (sInput,sDelimiter,iIndex)) [ ] iIndex++ [ ] [ ] return lsReturn

1 comment:

Udita said...

This is useful code, however it is not working if sInput = @@abc@def@ghi@jkl@@

where delimiter is @

in this case it is returning blank list of string.

Could you please handle this situation.