Hi Peter,

1. This appears to be the best way and is easy to do. To extract the $$$ commands, you can use Pos with PosEx or regular expressions. To test this, I used this regular expression: '\$\$\$[^\n\r$]+\$\$\$'

2. You will need to alter the buffer in the OnDataAvailable event. I have looked through the TTnEmulVT code in which the event is called before displaying the data. Something like this:

function TForm1.ProcessForCommandTag(InStr: string) : string;
var
Regex: TPerlRegEx; // PerlRegEx library
begin
 Result := '';

 Regex := TPerlRegEx.Create;
 try
   Regex.RegEx := '\$\$\$[^\n\r$]+\$\$\$';
   Regex.Options := [];
   Regex.State := [preNotEmpty];
   Regex.Subject := InStr;
   if Regex.Match then begin
     repeat
InStr := StringReplace(InStr, Regex.MatchedText, '', [rfReplaceAll]);
       // Process Regex.MatchedText ($$$ tag)

       // matched text: Regex.MatchedText;
       // match start: Regex.MatchedTextOffset;
       // match length: Regex.MatchedTextLength;
       // backreference n text: Regex.Groups[n];
       // backreference n start: Regex.GroupOffsets[n];
       // backreference n length: Regex.GroupLengths[n];
     until not Regex.MatchAgain;
   end;

   Result := InStr;
 finally
   Regex.Free;
 end;
end;

procedure TForm1.TnEmulVT1DataAvailable(Sender: TObject; Buffer: Pointer; var Len: Integer);
var tmpStr : string;
   tmpChar: PAnsiChar;
   aIdx   : Integer;
begin
 if (Len <= 0) then Exit;

 try
   SetString(tmpStr, PAnsiChar(Buffer), Len);
   // process tmpStr
   tmpStr := ProcessForCommandTag(tmpStr);
   // To preven buffer overruns,
   // tmpStr must be no larger than len
   strpcopy(PAnsiChar(Buffer), tmpStr);
 finally
 end;
end;

*** It is important to note that the modified string ($$$ tags removed) must be shorter than the original string. This will prevent buffer overrun issues.

3.  Don't know.  I tested using ANSI.

4. I scanned the OverbyteIcsTnEmulVT.pas file. This showed me how the interaction between the EmuVT and TnCnx components worked.

Hope this helps.

Thanks,
Ken.

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to