[fpc-pascal]Odd behavior with Crt unit..

Jonas Maebe jonas at zeus.rug.ac.be
Mon Dec 10 13:54:33 CET 2001


On vrijdag, december 7, 2001, at 05:33 , Gene Buckle wrote:

>
>>> I still think there is
>>> a bug in the CRT unit somewhere (in GetXY?) but this is a good enough 
>>> fix
>>> for me.
>>
>> I already mentioned this problem before, but nobody cared. :-(
>
> Maybe it's not that no one card, but the right person didn't see the bug
> report.  Hey!  Right PErson!  See this?  Fix it! *laughs*

Maybe its simply that no one has the time (or that te person who wrote 
this doesn't see any error in the code). Here's the source, but I don't 
know anyting about ansi codes, so I frankly don't have a clue about how 
ths works.

***
procedure GetXY(var x,y:byte);
var
   fds    : fdSet;
   i,j,
   readed : longint;
   buf    : array[0..255] of char;
   s      : string[16];
begin
   x:=0;
   y:=0;
   s:=#27'[6n';
   fdWrite(0,s[1],length(s));
   FD_Zero(fds);
   FD_Set(1,fds);
   if (Select(2, at fds,nil,nil,1000)>0) then
    begin
      readed:=fdRead(1,buf,sizeof(buf));
      i:=0;
      while (i+5<readed) and (buf[i]<>#27) and (buf[i+1]<>'[') do
       inc(i);
      if i+5<readed then
       begin
         s:=space(16);
         move(buf[i+2],s[1],16);
         i:=Pos(';',s);
         if i>0 then
          begin
            Val(Copy(s,1,i-1),y);
            j:=Pos('R',s);
            if j=0 then
             j:=length(s);
            Val(Copy(s,i+1,j-(i+1)),x);
          end;
       end;
    end;
end;
***


Jonas





More information about the fpc-pascal mailing list