Currently the delimiter is hard-coded to '|' but you could easily make that a parameter. Before calling the function, you need to push both the token number you want returned and the list of strings onto the stack. One caveat to note is that the the list of string needs to have a delimiter at the very end. So an example of a working list of strings would be:
Function gettoken
Pop $0 ;list of strings
Pop $1 ;desired token number
StrCpy $R0 0 ;base index
StrCpy $R1 -1 ;string index
StrCpy $R3 1 ;iteration
StrLen $R5 $0
token_nextchar:
IntOp $R1 $R1 + 1
IntCmp $R1 $R5 token_empty 0 0
StrCpy $R2 $0 1 $R1
StrCmp $R2 '|' 0 token_nextchar
IntCmp $R3 $1 token_return token_nexttoken 0
token_nexttoken:
IntOp $R0 $R1 + 1
IntOp $R3 $R3 + 1
Goto token_nextchar
token_return:
IntOp $R4 $R1 - $R0
StrCpy $R2 $0 $R4 $R0
Goto token_done
token_empty:
StrCpy $R2 "_empty_"
token_done:
Push $R2
FunctionEnd
"The United States of America|Japan|Korea|China|"
You can iterate from 1 to N calling the function at each index to tokenize the entire list. The return value is pushed onto the stack. Your iteration can terminate if the return value was "_empty_".