Solved

displaying a whole text on the screen

Posted on 2004-04-05
4
198 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 35 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 100

Assisted Solution

by:mlmcc
mlmcc earned 40 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 100

Expert Comment

by:mlmcc
ID: 10801008
Glad I could help

mlmcc
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Cloud-based technologies and services will continue to grow in popularity in 2017 thanks to the simple, scalable and cost-effective solutions they deliver. Here are three areas where cloud adoption is poised to really take off.
Knowledge base software has turned out to be a quite reliable method for storing information, promoting collaborative work and for sharing valuable input and solutions.However, some organizations are trying to develop a knowledge base that works wit…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now