Solved

Memos and things

Posted on 2002-03-19
3
148 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 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
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…

691 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