Jump to content
Sign in to follow this  
Ian Branch

class constructor - Backport to D2007.

Recommended Posts

Hi Team,

As much as I don't want to I have to backport an App to D2007.

It currently uses the following code to pass a variable around the App.

unit ViewerData;

interface

type
  TViewerData = class

  class var
    //
    mssFileName: String;
    class constructor Create;
    //
  end;

implementation

Uses WindowsStore;

class constructor TViewerData.Create;
begin
  //
  mssFileName := '';
  //
end;

end.

It has been a long time since I toiled in D2007 but IIRC it doesn't support either WindowsStore or class constructor.

Is the above code modifiable to D2007 compatability?

Appreciate any guidance.

 

Regards & TIA,

Ian

Edited by Ian Branch
Correction to Subject.

Share this post


Link to post

Make the class constructor a regular procedure, the class variable a variable inside the unit and call the procedure from initialization.

Share this post


Link to post

Class vars are global variables inside a type's name's pace. Class constructors are called from unit initialization. Class destructor from unit finalization. 

Share this post


Link to post

If the code you posted is all the class constructor does it's pointless anyway as string variables don't have to be initialized to empty string.

  • Haha 1

Share this post


Link to post

Hi Guys,

Apologies for not responding sooner.  Family issue.

All sorted now thank you.  As it was only one variable I just made it Global.

Regards,

Ian

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×