CStrTok:delete CStrTok:SetDelimiter

CStrTok:Init


The Init method initializes the CStrTok object to a target string and list of delimiters. This is usually done when the CStrTok object is constructed using new. Use the Init method when you want to change the string or delimiters for an existing CStrTok object or when you created the object using the default new without passing any arguments.

Syntax

CStrTok:Init( sStr, sDelim )

Example

The following script parses two strings sStr and sNewStr into pieces delimited by delimiter characters sDelim. This also could be done using two instances of CStrTok.

sDelim = ", \t\r\n"

-- delimiters comma, blank, tab, new line, and return

T = CStrTok:new( sStr, sDelim )

-- create a new CStrTok object initialized to the target

 

-- string sStr and delimiters sDelim

...

-- parse sStr and work with it

 

 

T:Init( sNewStr, sDelim )

-- change to a new string

 

 

  ...

-- parse the new string and work with it

T:delete()

-- delete the object and its associated memory.

Related Topics

CStrTok, new, Next, SetDelimiter