Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Assigning of object properties to variables

JPDJPD Member Posts: 28
In onTimer event I have something like this:

.procedure TForm1.Timer1Timer(Sender: TObject);
. top: integer;
. top := Button1.Top;
. top := top + 1;

it doesn't work. But if I use this:

.procedure TForm1.Timer1Timer(Sender: TObject);
. Button1.Top := Button1.Top + 1;

it works fine.
Can anyone explain that please? In JavaScript I allways assign object model to variables. {document.forms[0]... etc.}

Thanks in advance. Jiri


  • rmemoriarmemoria Member Posts: 3
    When you write such a declaration like this
    var top: integer;

    top := Button1.Top; [/code]

    You're coping the value of the property 'Button1.Top' to a integer variable called 'top', and not making a reference of 'Top' to the property 'Button1.Top', so when the line

    [code] top := top + 1; [/code]

    is executed, it increments the top's variable value, and the value of Button1.Top doesn't change.


  • Shawn CarterShawn Carter Member Posts: 0

    ________ { } free ebooks and video tutorials about [ JavaScript Visual Basic Swift Perl Go Assembly PHP Objective-C Delphi Scratch Python C PL/SQL MATLAB R Java C# C++ Ruby Visual Basic .NET SAS Scheme COBOL VBScript Julia Awk Apex Rust Dart ML Hack Fortran Scala Ada Bash LabVIEW FoxPro Prolog Crystal Kotlin Alice D Erlang Logo Lisp Lua ABAP F# Transact-SQL Clojure ] ______________

Sign In or Register to comment.