Recent

Author Topic: Runtime Error in console app.  (Read 5583 times)

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Runtime Error in console app.
« on: March 15, 2011, 03:03:18 am »
Hi wanting to test pollkeyevent I took this sample code below from here:
http://www.freepascal.org/docs-html/rtl/keyboard/pollkeyevent.html

New Project, Item 2; Program (also tried Item 3 console app)
compiler settings a gtk2 beta, but also tried no gui
Anyone with the time please try to compile and advise thanks.
Get a debug error each time I try to run this:

Code: [Select]
program Project1;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Classes,keyboard
  { you can add units after this };

{$IFDEF WINDOWS}{$R project1.rc}{$ENDIF}

Var
  K : TKeyEvent;

begin
 InitKeyBoard;
  Writeln('Press keys, press "q" to end.');
  Repeat
    K:=PollKeyEvent;
    If k<>0 then
      begin
      K:=GetKeyEvent;
      K:=TranslateKeyEvent(K);
      writeln;
      Writeln('Got key : ',KeyEventToString(K));
      end
    else
      write('.');
  Until (GetKeyEventChar(K)='q');
  DoneKeyBoard;
end.




Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Runtime Error in console app.
« Reply #1 on: March 15, 2011, 05:49:11 am »
Works fine here (Kubuntu 10.10, FPC 2.5.1 about 2 weeks ago)

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Runtime Error in console app.
« Reply #2 on: March 15, 2011, 06:34:54 am »
Works fine here (Kubuntu 10.10, FPC 2.5.1 about 2 weeks ago)

FPC 2.4.0 i386-linux-gtk 2 (beta)
Hi did you make it same way - 2nd option Program (not console). It could be my compiler, but its unlikely. More than likely my settings are amiss.
Thanks.
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8835
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Runtime Error in console app.
« Reply #3 on: March 15, 2011, 07:25:11 am »
Quote
Hi did you make it same way - 2nd option Program (not console). It could be my compiler, but its unlikely. More than likely my settings are amiss.
It has nothing to do with Lazarus. Now before we go any further: what runtime error do you get?

AlistairG

  • Jr. Member
  • **
  • Posts: 70
Re: Runtime Error in console app.
« Reply #4 on: March 15, 2011, 07:53:06 am »
Also it compile warning:
pollkeyevent.pas(21,16) Fatal: Syntax error, "." expected but ";" found

K:=PollKeyEvent;  <<warn here
Lazarus 0.9.28.2-10ubuntu1 r22277 FPC 2.4.0 i386-linux-gtk 2 (beta)
       My pledge - if I waste your time, I donate to Lazarus.

 

TinyPortal © 2005-2018