[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

displaying a whole text on the screen

Posted on 2004-04-05
4
Medium Priority
?
235 Views
Last Modified: 2010-04-16
Hi everybody,

i need some help about screen managing things
for example i wrote a program which read a whole text from a txt-file and it should write it on the screen
the text is stored in an array of string, 400 lines
but if i do something like that the user can't read the line from 1 to 360

FOR i:=1 To 400 Do
 WriteLn(WholeText[i]);

the main purpose of the program is that the user could read the WHOLE text and not just the 40 last lines,
i would like to activate something like the "Page-Up and Page-Down" keys
so that the user could go to the top and browse around

can someone help me out if that ???

here is the code i now have;
PROGRAM Test; Uses DOS;
CONST
 i:Integer=0;

VAR
 WholeText:Array[1..400] Of String[100];
 F:Text;
 sr:SearchRec;

BEGIN
 FindFirst('readme.*', AnyFile, sr);
 While DosError = 0 Do
 Begin
  Assign(F,sr.Name);
  Reset(F);

   While Not (Eof(F)) DO
   Begin
    i:=i+1;
    ReadLn(F, WholeText[i]);
   End;

  Close(F);
  FindNext(sr);
 End;
 ReadLn;
END.

it is very primitive, it is just to illustrate the problem i have
0
Comment
Question by:Elvis1
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
Jase-Coder earned 105 total points
ID: 10756747
consoles have about 24 rows and 80 collumns so, to view the whole file your going to have to display 23 lines then you could tell the user to press a key, then clear the screeen then display another 23 lines. so simple peusdo

Display 23 lines
prompt user for key press
clear then screen
Display 23 lines

to display 23 lines you could read 80 chars from the file then display that on screen so

while (not eof) do
begin
  for a := 1 to 23 do
  begin
    for i := 1 to 80 do
    begin
       read(F, Str[i]);
    end;
    writeln(str);
  end;
  writeln('Press a key');
  readln;
end;

I have had chance to compile this so you might find some errors
 
0
 
LVL 101

Assisted Solution

by:mlmcc
mlmcc earned 120 total points
ID: 10763006
Is this a homework assignment or something you are doing on your own?  Sounds like an assignment we did to start writing a text editor.

Basic idea

Read the file as you are doing
---
   lines := 1;
   While Not (Eof(F)) DO
   Begin
   lines := lines +1;
    ReadLn(F, WholeText[lines]);
   End;
---
Display 1 screen of text
   start := 1;
  Repeat
   For i = start to start+22 do
     Writeln (WholeText[i]);
   Display keycodes
   When a key is hit - respond
   Pgup  start := start;
   Pgdn  start := start + 22;
   Quit
  until quit

Needs a fair amount of work but bit gives you the ggeneral idea.

mlmcc
   
0
 

Author Comment

by:Elvis1
ID: 10763823
it's something i'm doing on my own, it is in fact to write a basic text editor, i'm folowing a tutorial,

i look it up, consoles have 80 columns and 25 rows
so for a nice layout i should take the first line for my heading and menu and so on and the last line is to ask the user for page-up or page-down ???

Elvis
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 10801008
Glad I could help

mlmcc
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Last month Marc Laliberte, WatchGuard’s Senior Threat Analyst, contributed reviewed the three major email authentication anti-phishing technology standards: SPF, DKIM, and DMARC. Learn more in part 2 of the series originally posted in Cyber Defense …
Tech giants such as Amazon and Google have sold Alexa and Echo to such an extent that they have become household names. And soon they are expected to be used by commoners in their homes, ordering takeout, picking out a song, answering trivia questio…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question