CStrTok:new

CStrTok Class Description


The CStrTok class is used to parse a target string into shorter strings bounded by separator characters. This process is known as "tokenizing". For example, a string might contain 10 values separated by commas which must be split into 10 pieces, or "token". Any number of separator characters may be specified. To parse the string into tokens, use the Next method to return each piece until it returns nil indicating no more pieces exist. This class works like the C language strtok() function.

Usage

Construction

Object = CStrTok:new()

Destruction

Object:delete()

Methods

Construction

new

Creates a new instance of a CStrTok object. Various constructors are available. The target string and delimiters may be specified in the constructor.

delete

Deletes the instance of the CStrTok object.

Operations

Init

Initializes the target string and delimiters. You also can do this in the new method when you create an instance of the class.

SetDelimiter

Specifies the character delimiters to use henceforth while tokenizing the target string. The delimiter is initially set using new or Init, but this method allows you to change it while the string is being parsed.

Next

Returns the next string token.

Related Topics

Script Classes