Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inserting text into an app.

Posted on 1998-02-23
7
Medium Priority
?
140 Views
Last Modified: 2010-08-05
I am writing an application which needs to act as a
text editor, but also be able to insert specific lines of
text when a menu item is selected. The inserted text needs
to then behave as if it were entered by the user ie. the
user should then be able to delete, add to, or alter the
text in any way. Anyone know how?
afterwards if neccesary.
0
Comment
Question by:kh5395
[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
  • 4
  • 3
7 Comments
 
LVL 5

Accepted Solution

by:
inter earned 40 total points
ID: 1359727
1 - Just open a new project
2 - Place a button and TMemo component on form
3 - dblclick on button. and write the following in between
    Memo1.Lines.Add('This is the interted line');
4 - Run the project
5 - type in some lines in memo
6 - press the button
7 - For doing this by menu write down the same or similiar code to the menus click method normally

Is it OK
Igor
0
 

Author Comment

by:kh5395
ID: 1359728
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
 

Author Comment

by:kh5395
ID: 1359729
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:kh5395
ID: 1359730
Igor,
     That's exactly what I needed to do. However, my problem is
that I have several dialog boxes. These all need to take data
from the user and then display a piece of text.
     e.g. one box asks the user to choose a style, each of which
is listed as a radio box. The dialog box unit then needs to
display this information on the TMemo. My problem now is that
I can't get at the TMemo because it is in the main unit. Could
you tell me how to do this? I tried putting the main unit in the
'uses' declaration, but it says this is a circular statement.
I would really appreciate your help.
Thanks again,
Nik



0
 
LVL 5

Expert Comment

by:inter
ID: 1359731
Try forming a uses clause in the implementation that is

unit2

interface
...

implementation

uses
  Unit1;
...

Ok?
Igor
0
 

Author Comment

by:kh5395
ID: 1359732
Igor,

I've tried that, but it doesn't seem to work :

unit Main;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, Menus, StdCtrls, docclsdg;

type
  TMainForm = class(TForm)
    ...
    ...
    ...

    procedure RunLaTeX1Click(Sender: TObject);
    procedure Class1Click(Sender: TObject);
    procedure InsertText(var S: String);
 
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.DFM}

procedure TMainForm.RunLaTeX1Click(Sender: TObject);
begin
WinExec('Latex',SW_SHOWMAXIMIZED);
end;

procedure TMainForm.Class1Click(Sender: TObject);
begin
     docclassdlg.ShowModal;
end;

procedure TMainForm.InsertText(var S: string);
begin
     MainForm.EditPad.Lines.Add(S);
end;
end.

****************

unit Docclsdg;

interface

uses WinTypes, WinProcs, Classes, Graphics, Forms, Controls, Buttons,
  StdCtrls, ExtCtrls;

type
  Tdocclassdlg = class(TForm)
    OKBtn: TBitBtn;
    CancelBtn: TBitBtn;
    HelpBtn: TBitBtn;
    Bevel1: TBevel;
    RadioGroup1: TRadioGroup;
    Label1: TLabel;
    procedure OKBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  docclassdlg: Tdocclassdlg;

implementation
uses
    Main;
{$R *.DFM}

procedure Tdocclassdlg.OKBtnClick(Sender: TObject);
begin
     InsertText('Inserted Text');
end;

end.


I get a syntax error when it tries to run InsertText. Any idea
why?
Thanks, Nik.

0
 
LVL 5

Expert Comment

by:inter
ID: 1359733
Hi,

When you call one class method from another, you should specify the class name before the method just as refering a member of a record so

InsertText('Inserted Text') should be
MainForm.InsertText('Inserted Text') is this ok?

Igor
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Loops Section Overview
Suggested Courses

598 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