[IronPython] Console and comment line 0.9.6

Stute, Detlef ALRT/EEG4 Detlef.Stute at al-lighting.com
Wed Dec 14 09:15:50 CET 2005


Hi all,
I'm using IronPython 0.9.6 as scripting engine.
I redirect the Iconsole to my own ReadLine and so on. In my ReadLine I read a file and transfer it line by line to the scripting engine. It was working with version 0.9.3
To make a long story short:
When the file includes a comment line ( like "# this is a comment"), the console only answers for the future with "...".
The same occurred, on IronPythonConsole.exe when you enter a line starting with '#' .

I resolved the problem in the file PythonEngine.cs function DoOneInteractive

public bool DoOneInteractive( Frame topFrame )
{
  MyConsole.Write( sys.ps1.ToString(), Style.Prompt );
  StringBuilder b = new StringBuilder();
  Stmt s;
  bool isMultiLine = false;
  while( true )
  {
    string line = MyConsole.ReadLine();
    if( line == null )
    {
      if( ExecWrapper != null )
      {
        Ops.Call( ExecWrapper, new object[] { null } );
      }
      return false;
    }
    b.Append( line );
    b.Append( "\n" );

    s = ParseText( b.ToString(), line.Length == 0 );


    // !!! this was the old line   !!!
    // if( line.Length == 0)

    if( line.Length == 0 || null == s)        
    {
      break;
    }
    if( !isMultiLine )
    {
      isMultiLine = true;
      if( s != null )
        break;
    }

    MyConsole.Write( sys.ps2.ToString(), Style.Prompt );
 }

... More code

I added a break from the loop when ParseText returns null.
Is that the right way?
I found that the difference between 0.9.3 and 0.9.6 is that the comment is now a token ( TokenKind.cs).

Mit freundlichen Grüßen/ kind regards/ Cordiali Saluti
 
Detlef Stute
SEATEC GmbH
Robert-Bosch-Breite 10
37081 Goettingen
Germany
Mailto: detlef.stute at seatec-gmbh.com
www.seatec-gmbh.com
 



More information about the Ironpython-users mailing list