Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 999541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:22:15+00:00 2026-05-16T07:22:15+00:00

this code works fine: procedure TForm2.Timer1Timer(Sender: TObject); var Text: string; begin SetLength (Text,555); GetWindowText

  • 0

this code works fine:

procedure TForm2.Timer1Timer(Sender: TObject);
var
  Text: string;
begin  SetLength (Text,555);
  GetWindowText (getforegroundwindow, PChar (Text),555);
  Form2.gtListBox1.Items.Add (
    IntToStr (getforegroundwindow) + ': ' + Text);
end;

but when i put

var
  Text: string;

from Timer1Timer event handler to
units implementation section or ”text : string” in the units var section i get error : E2197 Constant object cannot be passed as var parameter
according to documentation :

This error message appears when you
try to send a constant as a var or out
parameter for a function or procedure.

but i didnt declared text as constant then why am i getting this error?
Edit:@mason wheeler: i do not understand than why does this work:

implementation
{$R *.dfm}
 var 
 char :integer;//first of all why does delphi let me declare variable that is also a type name
procedure TForm2.Button1Click(Sender: TObject);
begin
char:=11; 
showmessage(IntToStr(char));
end;

my first code was not working because i declared text as string ,you say : ”the compiler might think it’s a reference to the type and not to the variable” than why doesnt the compiler think its a reference to the type and not to the variable in this case? i am confused
Edit2: i now understand what was wrong but still have 1 confusion i did’nt use a with statement then why delphi is treating as if i am using:

 with
      form1 do
       text := 'blahblahblah';

this is wrong on the delphi part i mean delphi should not let us do text := 'blah' but form1.text := blah; or with form1 do text := 'blah'; do i need to turn on/off some compiler setting(s) i am using delphi 2010 without any ide experts

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T07:22:15+00:00Added an answer on May 16, 2026 at 7:22 am

    Actually if you declare Text in implementation section and use it in Timer1Timer(Sender: TObject), compiler will consider Text as Form1.Text.

    Change the name of text as sText and it will work.

    Edit 1:

    Because there is no property/Field for form like Form1.Char.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code works fine in Chrome. However, in Firefox, when it hits the GMxhr
This code works fine, but I'll want to handle exception if any thing goes
this code works fine until I start scrolling: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This code works fine to find an available room within certain date, but it
This code works fine in C#: Expression.Lambda(LambdaBody); But none of the methods for building
The code below is creating a server to communicate with clients.This code works fine
web page : http://sideradesign.com/eco-art/gallery/ This code works fine in all brwosers except IE8 (haven't
I'm using core motion in my app. This code works fine: motionManager = [[CMMotionManager
Please i need help, this code below works fine on my localhost, php5.3+ but
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.