回 帖 发 新 帖 刷新版面

主题:一个写字板程序

uses Crt;

var
  OrigMode,LastCol,LastRow: Word;
  Ch: Char;
  Done: Boolean;

procedure Initialize;
begin
  CheckBreak:=False;                   
  OrigMode:=LastMode;                  
  TextMode(Lo(LastMode)+Font8x8);       
  LastCol:=Lo(WindMax)+1;              
  LastRow:=Hi(WindMax)+1;
  GoToXY(1,LastRow);                    
  TextBackground(Black);
  TextColor(White);
  Write(' Ins-InsLine  ',
        'Del-DelLine  ',
        #27#24#25#26'-Cursor  ',
        'Alt-W-Window  ',
        'Alt-R-Random  ',
        'Esc-Exit');
  Dec(LastRow,80 div LastCol);         
  Randomize;                        
end; { Init }

procedure MakeWindow;
var
  X,Y,Width,Height: Word;
begin
  Width:=Random(LastCol-2)+2;                
  Height:=Random(LastRow-2)+2;
  X:=Random(LastCol-Width)+1;           
  Y:=Random(LastRow-Height)+1;
  Window(X,Y,X+Width,Y+Height);
  if OrigMode = Mono then
  begin
    TextBackground(White);
    TextColor(Black);
    ClrScr;
    Window(X+1,Y+1,X+Width-1,Y+Height-1);
    TextBackground(Black);
    TextColor(White);
    ClrScr;
  end
  else
  begin
    TextBackground(Random(8));
    TextColor(Random(7)+9);
  end;
  ClrScr;
end; { MakeWindow }

procedure RandomText;
begin
  repeat
    Write(Chr(Random(256-32)+32));
  until KeyPressed;
end; { RandomText }

begin { program body }
  Initialize;
  MakeWindow;
  Done:=False;
  repeat
    Ch:=ReadKey;
    case Ch of
      #0:                                
      begin
        Ch:=ReadKey;
        case Ch of
          #17: MakeWindow;               
          #19: RandomText;               
          #45: Done:=True;               
          #72: GotoXY(WhereX,WhereY-1);  
          #75: GotoXY(WhereX-1,WhereY);  
          #77: GotoXY(WhereX+1,WhereY);  
          #80: GotoXY(WhereX,WhereY+1);  
          #82: InsLine;                  
          #83: DelLine;                  
        end;
      end;
      #3: Done:=True;                  
      #13: WriteLn;                      
      #27: Done:=True;                  
    else
      Write(Ch);
    end;
  until Done;
  TextMode(OrigMode);
end.

回复列表 (共13个回复)

沙发

what's the meaning

板凳

3 楼

4 楼

顶顶顶~~~~~~~~~

5 楼

请问一下作者是用什么工具编的,谢谢!

6 楼

turbo pascal

7 楼

我考,太强了八

8 楼

高手啊

9 楼

天才!

10 楼

有错啊。
除数为零

我来回复

您尚未登录,请登录后再回复。点此登录或注册