Recent

Author Topic: (SOLVED) Keyboard doesn't respond when recompiling old TP source code.  (Read 2807 times)

DavyGravy

  • Newbie
  • Posts: 6
This is likely a simple problem that any of you FP experts can spot immediately. And I will feel stupid, but that is nothing new. I recently tried to upgrade an old TP program that I compiled and ran on a PS2 way back in CS school. But now, at runtime the keyboard fails to display entered keystrokes. I an now running a 5-year-old Compaq. I suspect something simple so I'll skip the architecture details for now.  Here goes.....

1. The program opens with:

PROGRAM EVOLUTE(Input, Output, Displayfile, MasterFile);

USES
  Crt, Graph;

CONST
  MaxPopulation    = 4000;
  StartPopulation  = 800;

TYPE
  Person = Array[1..10] of integer;   
  ............ etc....

*****************************************

2. Execution starts in the Main Program:

BEGIN
  Assign(DisplayFile,'Display.TXT');
  Assign(MasterFile, 'MastFile.TXT');
  AssignCrt(Input);  Reset(Input);
  AssignCrt(Output); Rewrite(Output);
  Exit := False;
  TextColor(Cyan);
  ClrScr;
  ShowDisplayFile(1);              (* Displays text from a file on the screen *)
  TextColor(Yellow);
  AMA := Nil;
  EndOfPage;                          (* Problem shows up here *)
  TakeInputData;   ..........       

*******************************************

3. When the running the procedure "EndOfPage", the screenful of text looks
    the way it used to, the cursor is the correct color and blinks at the underscore
    in the correct position - BUT THE KEYBOARD WILL NOT DISPLAY (OR READ)
    WHAT IS TYPED!  Grrrrr!  Any ideas? The same code ran fine on TP.
    Any suggestions would be appreciated. I know I am missing something
    simple.   Thanks!!!!

Procedure EndOfPage;
VAR
  Ch : char;
BEGIN
  Ch := ' ';
  while (Ch <> 'C') and (Ch <> 'c') do
  begin
    CursorOn;
    GoToXY(60, 25);
    Read(Ch);
    if (Ch = 'X') or (Ch = 'x') then
    begin
      If AMA <> nil then     (* Memory has been dynamically allocated *)
        begin
         Dispose(AMA);  Dispose(AFA);  Dispose(IMA);  Dispose(IFA);
        end;
      TextMode(LastMode);
      TextColor(White);
      Halt;                                          (* Return to DOS *)
    end;
  end;
END;







« Last Edit: December 22, 2014, 11:45:12 pm by DavyGravy »

kapibara

  • Hero Member
  • *****
  • Posts: 610
Re: Keyboard doesn't respond when recompiling old TP source code.
« Reply #1 on: December 19, 2014, 02:32:29 am »
Have you read this? Try the test code on the bottom of that page:
http://www.freepascal.org/docs-html/rtl/crt/assigncrt.html

I dont know so much about typed or text files, but try use AssignFile instead of Assign. Shouldn't make a difference maybe, but anyway..
Lazarus trunk / fpc 3.2.2 / Kubuntu 22.04 - 64 bit

DavyGravy

  • Newbie
  • Posts: 6
Re: Keyboard doesn't respond when recompiling old TP source code.
« Reply #2 on: December 19, 2014, 06:14:25 pm »
Kapibara, I made the "AssignFile" change, recompiled and reran it, but it did not fix the problem. But I really appreciate the suggestion. ..... 

Woh! I changed the AssignCRT statement and that worked! Apparently, I have to Assign the CRT to a file after writing a text file to the screen, and I have to assign the CRT to "Input" when in full CRT mode. Thanks! I'll buy you a beer!!
« Last Edit: December 19, 2014, 06:31:04 pm by DavyGravy »

 

TinyPortal © 2005-2018