Solved

unable to use variable for application.title in dpr?

Posted on 2006-07-06
2
390 Views
Last Modified: 2010-04-05
Title says it all, but can someone explain why I can't seem to associate a string variable at runtime in the dpr to the application.title?
Everytime I put the line of code in, it disables the RUN application button, and then if I save and leave it in and try and reopen the application, it is now corrupt and I have to restart from a prvious version of the code.

I'm guessing this is just something I didn't know you couldn't do but I'm just checking.

var
  sTemp: String;
begin
  .
  .
  .
  Application.Title := 'This string'+ sTemp;
0
Comment
Question by:mikelittlewood
2 Comments
 
LVL 26

Accepted Solution

by:
Russell Libby earned 50 total points
ID: 17050385
Its a "known" feature (at least to borland)/

// This is a known 'feature' and it has been there since Delphi 1. Notice I
// don't call it a bug. The reason this works like this is because we allow you
// to set the Application.Title in the IDE so we need to set it to a string.
// With a const we wouldn't know what type it was unless we did a full
// expression parse on it. It isn't worth it.
//
// -- Robert Kozak (Borland)


The workaround is to perform something similar to the following:


var
  sTemp:         String;

procedure SetTitle(App: TApplication);
begin

  App.Title:='This string'+ sTemp;

end;

begin

  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  SetTitle(Application);
  Application.Run;

end.


Regards,
Russell
0
 
LVL 15

Author Comment

by:mikelittlewood
ID: 17154236
Ah ok thanks for that Russell, interesting to find out.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtuailstring tree compare node issue 14 117
Help on project with Soap 10 54
Delphi Form ownership 4 90
Firemonkey android show image from resource ? 1 42
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

777 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