CT_SAVETOKEN

 SAVETOKEN()
 Saves the incremental tokenizer environment to a variable
------------------------------------------------------------------------------
 Syntax

     SAVETOKEN() --> cTokenEnvironment

 Returns

     The character string returned contains the internal environment for the
     incremental tokenizer.

 Description

     By saving and later restoring the internal tokenizer environment, an
     interlocking implementation of the incremental tokenizer is made simple.
     The complete, previously initialized string is saved, as are the
     internal pointers and the corresponding file areas.  This string serves
     as a return value for SAVETOKEN(), regardless of the later restoration
     of the tokenizer environment using RESTTOKEN().

 Note

     .  The returned value is only valid for the currently running
        program because it is concerned with internal pointers.

 Examples

     .  Here is an incremental tokenizer.  Text is broken into
        individual lines, and each line is broken into words:

        TOKENINIT(@cTextString, CHR(13) + CHR(10), 2)

        DO WHILE .NOT. TOKENEND()
           cLine   :=  TOKENNEXT(cTextString)
           WORD(cLine)
        ENDDO

     .  The function then breaks the lines into words:

        FUNCTION WORD(cLine)
              cOldEnv  := SAVETOKEN()
              TOKENINIT(@cLine, " .,-:;")
              cWord  := TOKENNEXT()

              DO WHILE .NOT. TOKENEND()
                 cWord := TOKENNEXT(cLine)
                 ? cWord
              ENDDO
              RESTTOKEN(cOldEnv)

              RETURN("")

See Also: RESTTOKEN() TOKENINIT() TOKENNEXT()

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.