CStrTok:Init CStrTok:Next

CStrTok:new


The new method creates an instance of the CStrTok class. Note that the object can also be created using new_strtok.

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( strString, strTokens )

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

bullet.gif    strString is the string to parse.

bullet.gif    strTokens specified the tokens used to parse the string.

S = CStrTok:new()

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

S = CStrTok:new( CStrTok2 )

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

bullet.gif    On success, a CStrTok object is created and returned.

bullet.gif    On failure, nil is returned.

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, new_strtok


Mira Pro x64 Script User's Guide, v.8.73 Copyright Ⓒ 2024 Mirametrics, Inc. All Rights Reserved.