CStrTok:delete

CStrTok:new


The new method creates an instance of the CStrTok class. This method returns a reference to the object it creates. The calling code must assign this reference to a name (see below). If the object cannot be created, nil is returned.

Note: This method's name uses all lower case to present it as the analog of the C++ new operator. Generally, the names of class methods begin with an uppercase letter but new and delete are different.

Syntax

S = CStrTok:new( sString, sDelimiters )

    Creates a CStrTok object S and initializes it with the target string and the delimiters. You can begin calling Next to parse the target string into tokens.

S = CStrTok:new()

    Default constructor. The new CStrTok S is not initialized. You must call Init before parsing the string.

S = CStrTok:new( CStrTok2 )

    This is a copy constructor. The new CStrTok S is initialized to the target string and delimiters of the CStrTok instance.

Example

The following example shows the use of a constructor and destructor pair:

 

T = CStrTok:new( sStr, ", \t" )

-- create a new CStrTok object initialized to the

 

-- string sStr and delimiters comma, blank, and tab

  ...

-- parse the string and save or use its pieces here

T:delete()

-- delete the object and its associated memory.

Related Topics

CStrTok , Init, Next, delete