Recent

Author Topic: ReadLn gets a "We're pulling the plug message"  (Read 4617 times)

texasyen

  • New Member
  • *
  • Posts: 16
ReadLn gets a "We're pulling the plug message"
« on: May 12, 2012, 10:23:41 pm »
I'm on WinXP-32 SP3,
Lazarus : 0.9.30.4
FPC : 2.6.0-win32

I've written the following code to read a text file.

procedure TfmChiSquare.RadioGroup1Click(Sender: TObject);
var Buffer : String; F : Text;
begin
    with Sender as TRadioGroup do
       if ItemIndex = 1 then
{ If ItemIndex < 1, then user to enter data manually }
          if OpenDialog1.Execute then
          begin
             System.Assign(F,OpenDialog1.FileName);
             try
                Reset(F);
                while not eof(F) do
                begin
                   Readln(F,Buffer);
                  {
                   Disambiguate(Buffer)
   To be written routine to disambiguate Buffer
                  }
                end;
             finally
               System.Close(F)
             end;
          end;
end;

Stepping through the code line by line, I get to the readln command. At that point, I get the following message:

Debugger Error
Ooooops, the debugger entered the error state
[NB: I may have the number of 'o's' wrong]
Save your work now!
Hit Stop, and hope the best, we're pulling the plug

That's the entire message with nothing omitted--except for the OK button.

The opendialog is acting perfectly and the opendialog1.FileName is exactly right.

I tried changing the "System.Assign(...)" command to "Assign(...)" but then I get the compiler error message that I haven't provided the correct number of parameters. So I went back to System.Assign.

I've tried redefining Buffer to ansistring. No help. I've tried redefining Buffer to array[0..80] of char. No help.

What am I doing that is so incredibly stupid that I can't even read a simple line from a text file?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: ReadLn gets a "We're pulling the plug message"
« Reply #1 on: May 12, 2012, 10:55:00 pm »
Try it with "AssignFile".
http://wiki.freepascal.org/Text
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

texasyen

  • New Member
  • *
  • Posts: 16
Re: ReadLn gets a "We're pulling the plug message"
« Reply #2 on: May 12, 2012, 11:15:45 pm »
Went to the Wiki page. Made the changes but it still happened (i.e., "we're pulling the plug" message).

Wrote a "dummy" procedure and placed the breakpoint in the procedure which is called immediately after the readln and has Buffer as a parameter.

procedure TfmChiSquare.Disambiguate(Buffer : String);
var vTemp : Integer;
begin
    vTemp := pos(',',Buffer);
end;

The program runs to the break point and I can see the values in the watch window. The break point is placed on the "end" statement.

Here's where things get strange: If I press the "run" button, everything works fine and I get the results of the readln.

But if I place the break point on the vTemp line, and either step over or step into the statement, I get the "we're pulling the plug" message.

What did I do to deserve that?

texasyen

  • New Member
  • *
  • Posts: 16
Re: ReadLn gets a "We're pulling the plug message"
« Reply #3 on: May 12, 2012, 11:35:36 pm »
Okay, now I'm more confused than ever. I just went back and placed a break point on every line of code. On some I "stepped into" which brought me to the run time library. I pressed "run" and I was brought to the next break point. I pressed "step over" and I went to the next statement. I pressed "run" and I was brought to the next break point. Rinse and Repeat.

Every thing executed perfectly. Setting break points, stepping into, stepping over, or running from that point should not be this exciting! Any suggestions as to how to make this part of programming as boring as it should be?

Blaazen

  • Hero Member
  • *****
  • Posts: 3241
  • POKE 54296,15
    • Eye-Candy Controls
Re: ReadLn gets a "We're pulling the plug message"
« Reply #4 on: May 12, 2012, 11:43:55 pm »
I tried the wiki example (I also added while construction) and no problems.

Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  MyFile: TextFile;
  S: string;
begin
  AssignFile(MyFile, '/home/v1/Docs/VS.PAS');
  Reset(MyFile);
  try
    while not EOF(MyFile) do
      begin
        Readln(MyFile, S);
        WriteLn(S);
      end;
  finally
    CloseFile(MyFile);
  end;
end;           

Do you have {$mode objfpc}{$H+} ?
Is your file valid (line endings etc.) ?
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12340
  • Debugger - SynEdit - and more
    • wiki
Re: ReadLn gets a "We're pulling the plug message"
« Reply #5 on: May 12, 2012, 11:58:12 pm »
"We're pulling the plug message"

normally does not mean an error in your app.

It indicates a problem in either GDB (used by he IDE) or the IDE itself.

I would advice to switch to the 0.9.31 fixes branch snapshots. It has many debugger related fixes and improvements over 0.9.30.4.

In any case, please:
- open the "Debug output" window http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session
- then run your app

and after the error copy and attach the output.

This may allow to find out more

 

TinyPortal © 2005-2018