set %text $replace(%text, |, $+(|,$chr(32)))
.....
$gettok(%text, $1, 124)
The reason why your while has to run twice is because you have three ||| next to each other. After the first loop, the first two || are replaced by one |, leaving two ||. So you need to run the loop again.