Solved

displaying a whole text on the screen

Posted on 2004-04-05
4
194 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
What is Backup? Backup software creates one or more copies of the data on your digital devices in case your original data is lost or damaged. Different backup solutions protect different kinds of data and different combinations of devices. For e…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

705 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

21 Experts available now in Live!

Get 1:1 Help Now