List property
I have a list property that I query from the database to get the values contained in that list using $LISTFROMSTRING() when the list is returned the list values contain a rectangle like character similar to when you copy past something to the Terminal and it has a preceding space .The problem is I need to compare those values to other values and they do not match because of this value I have tried to use $EXTRACT(value,*W) and *P but this is not striping the preceding character how do I get rid of this character any ideas please.
the values returned from the Database ![]()
here is what I have tried code :![]()
Comments
Since you're using ObjectScript you should get the value from the list using something like $LISTGET(CList,i). That should return the correct value without control chars.
If you still want to use $PIECE then SET CListString = $LISTTOSTRING(CList) and then use the $PIECE on the CListString
@Warlin Garcia Thank you just what I needed $LISTGET(CList,i)
You should never attempt to filter the list manually (using $replace). Instead of that, if you already know what item you want to fetch then you can :
Use the $listfind to retrieve the index of the matching item inside your list and $listget to to finally fetch it.
set list = $listbuild("a","b","c")
set whatIWantToFind = "c"
set index = $listfind(list, "c") // returns the index 3.
write $listget(list, index) // returns "c".
If you don't know the content on that list, you can use $listlength to get the size of the list:
set list = $listbuild("a","b","c")
for i=1:1:$listlength(list) {
write $listget(list, i) // returns the current item at index i.
}
If you want extreme performance, then I'd suggest you to go with $listnext:
set pointer = 0
set list = $listbuild("a","b","c")
while $listnext(list, pointer, item) {
// Self-explanatory.
}
If you really want to filter the list separators, you can use $listtostring to do the opposite of $listfromstring that you used.
set list = $listbuild("a","b","c")
write $listtostring(list, "|") // "a|b|c"
Finally, you can also compare the list as whole using $listsame:
set list = $listbuild("a","b","c")
set listB = $listbuild("a", "b", "d")
set listC = $listbuild("a","b","c")
write $listsame(list, listB) // 0. False, because they're not the same.
write $listsame(list, listC) // 1. True, the values match.