STRTOKEN$ function

Purpose: STRTOKEN$ returns, from a source string, a substring determined by the sequential position of a token.


 Syntax:

 RetStr$ = STRTOKEN$(Source$, TokChr$, Token_Number%)

 Parameters:

  • RetStr$ If TokChr$ is found, the substring to the left of the Token_Number% token is returned. If TokChr$ is found and Token_Number% is equal to the total tokens + 1, the return will be the right-most substring.
  • Source$ String literal or variable from which substring is to be extracted.
  • TokChr$ TokChr$ is a string literal or variable character token. TokChr$ may be a multicharacter string but only the left-most(first) character is used.
  • Token_Number% Counting tokens from the left, Token_Number% corresponds to the token following the substring to be returned.

Remarks: Source$, TokChr$, and Token_Number are not modified by this function.

Example:


 DIM a$, j

 a$ = "Bob,Barker,The Price Is Right,Hollywood,California,Come On Down!"

 DO
  IF STRTOKEN$(a$, "," , ++j) > "" THEN
   PRINT j, " ", STRTOKEN$(a$, "," , j)
  ELSE
   EXIT LOOP
  END IF
 LOOP

Result:


 1 Bob
 2 Barker
 3 The Price Is Right
 4 Hollywood
 5 California
 6 Come On Down!