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
Solved

Memos and things

Posted on 2002-03-19
3
145 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
3 Comments
 
LVL 6

Accepted Solution

by:
Stuart_Johnson earned 50 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 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