?
Solved

displaying a whole text on the screen

Posted on 2004-04-05
4
Medium Priority
?
232 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part III
Ransomware, the malware that locks down its victim’s files until they pay up, has always been a frustrating issue to deal with. However, a recent mobile ransomware will make the issue a little more personal… by sharing the victim’s mobile browsing h…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

649 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