2014-01-13 61 views
0

我的學校任務是用pascal創建一個類似菜單的程序,顯示其他程序的代碼。它從行逐行讀取文本並將其打印到控制檯。當它不顯示完整的輸出時,它工作得很好。這是它顯示的輸出: http://postimg.org/image/3r4ua8poz/Pascal程序不顯示完整輸出

當它運行時,它會逐行顯示所有內容,但最終只能看到適合控制檯窗口的代碼部分,而不能向上滾動。誰能告訴我如何解決這個問題?這將是非常appresiated。 下面是實際工作的代碼:

program pascalMenu //ime na programata 
{$mode objfpc};//OOP pascal ili neshto takova(zaduljitelno e) 
uses sysutils, 
crt, graph; 
Var choice : array[1..5] of string;//masiv, v sluchaq sadurja chas ot imenata na failovete 
programFile : Text;//shte sudurja imeto na faila 
userFile,line,number,filename : string; 
i,j,value : integer; 
c : char; 
begin 
     writeln('This program will open all of our previous tasks.'); 

     //pulnene na masiva 
     for i := 1 to 5 do 
     begin 
       str(i,number); 
       choice[i] := 'program' + number; 
     end; 
     j:=1; 

     repeat 
     writeln('Use the arrow keys to navigate, ENTER to open and ESC to close.'); 


     //pokazvane na elementite v masiva sled vsqka vrutka na cikula 
     for i:= 1 to 5 do 
      begin 
       if i = j then 
       begin 
       //tva e za cveta 
       textcolor(red); 
       writeln(choice[i]); 
       textcolor(white); 
       continue; 
       end; 
       writeln(choice[i]); 

      end; 

     //beggining the menu loop 

     c := readkey;//chetene na kopche rofl 
     clrscr;// - chisti konzolata(optional) 
     if ord(c) = 0 then 
     c := readkey; 
     value := ord(c); 
     //options 
     case value of 
     72 : 
       begin 
       j:= j - 1; 
       if j < 1 then j :=5; 
       end; 
     80: 
       begin 
       j:= j + 1; 
       if j > 5 then j:= 1; 
       end; 
     13: 
       begin 
       str(j,number); 
       filename := 'program' + number + '.txt'; 
       assignfile(programFile,filename);//prilaga imeto na faila na promenlivata 
       //tva nz za kakvo e, obache sled 5-q opit reshi, che bez nego nemoje 
       try 
       reset(programFile);//otvarq faila za chetene 

       repeat 

         readln(programFile, line);//chete 1 red ot faila v line 
         writeln(line); 
       until (Eof(programFile));//eof - end of file 
       closefile(programFile);//zaduljitelno!! bez nego ne mogat dase otvarqt 2/poveche faila 
             //zaradi greshka v read/write dostupa 
       except on E:EInOutError do begin 
       writeln('The program could not read the file. Check the file''''s''name and directory.');end; 
       end; 

       writeln('Press any key to return to the main menu.'); 
       writeln('P.S. - This will erase the text'); 
       readln; 
       clrscr; 
       end; 
     end; 
     until value =27; 


end. 

回答

0

滾動通過使用單元CRT的禁止。不用它。

或者看看FPC附帶的「Lister」演示,它會嘗試一些相同的(光標移動以進行選擇和顯示)