?
Solved

Memos and things

Posted on 2002-03-19
3
Medium Priority
?
149 Views
Last Modified: 2011-09-20
I have a case statement to deal with printing reports - This bit is fine.

I want to describe the report to users and I am using a Tmemo to do this.

So I have something like


radiogroup1.index of

0: begin
Fillthememocase0;
othercode;
end;
1: begin
fillthememocase1;
othercode;
end;
2: begin
fillthememocase2;
othercode;
end;
3: begin
fillthememocase3;
othercode;
end;
end;

etc,etc,etc,


I can clearly fillthememo by using memo1.lines.add('bumph');


I feel sure that there must be a tidier way.

Can I please have some thoughts on tidying this up.

This isn't a question of not being able to cope - This is a question of readability of code;

TVMIA

Regards John

0
Comment
Question by:jbeh
[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
3 Comments
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 200 total points
ID: 6881669
Hi John,

The way I would do this is like this:

procedure TForm1.FillMemo;
const
  MemoLines: Array[0..3] of String = ('This is comment1',
    'This is comment2', 'This is comment3',
    'This is comment4');
begin
  Memo1.Lines.Text := MemoLines[RadioGroup1.Index];
  othercode;
end;

If you need to do multiple lines (example):

This is my first report.

It is really good.

You'd do the following:

  MemoLines: Array[0..3] of String = ('This is my first report' + #13 + 'It is really good.',
  'This is comment2','This is comment3',
  'This is comment4');

I hope this helps,

Cheers,

Stu.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6881890
whats wrong with this,
it seems ok to me,
specially that you've also
othercode in each case

more readability you can get with comment-lines,
where you could describe what this case do

meikl ;-)
0
 

Author Comment

by:jbeh
ID: 6882196
Looks good to me -

All this means is that I can now shuffle acres of commentary somewhere else so that I can still read my case statement sensibly -

Thanks
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

764 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