The SDL Component Suite is an industry leading collection of components supporting scientific and engineering computing. Please visit the SDL Web site for more information....


Class: none
Declaration: function ParseQuotedName (cc, QuoteChar: char; var CurrentName: string; var State: TQuotedStrState): boolean;

The function ParseQuotedName can be used to parse a string for quoted names. A quoted name is either a single word consisting of printable characters without spaces, or a string of several words enclosed by quotes (e.g. "This is a quoted name"). The enclosed string may contain non-printable characters (i.e. a CRLF combination) which are considered to be part of the quoted name.

The routine implements a finite state machine which is controlled by the variable parameter State. In order to parse a stream for a quoted name you have first to clear the variable parameter CurrentName and to set the state variable to vsState. Next, you have to pass the characters of the stream to be parsed to the function (using the parameter cc). The function returns TRUE if the variable name is complete. The parameter QuoteChar determines which character is used as the quotation character.

Example: The following example shows how to use ParseQuotedName in order to extract a quoted name. After the initialization the characters read from the text file InFile are passed to ParseQuotedName until the function returns TRUE or the end of the file has been encountered. At this point the variable myName contains the detected name:
  myName : string;      // contains parsed name on completion of loop
  eon    : boolean;     // TRUE: valid name found
  state  : TVNStates;   // state variable of finite state machine
  cc     : char;        // character read from file InFile
myName := '';
state := vsStart;
eon := false;
  read (InFile, cc);
  eon := ParseQuotedName (cc, '"', myName, state);
until eon or eof(InFile);

Last Update: 2012-Oct-20