Jump to content

TUniMainModule class variables


leon220

Recommended Posts

On you forum you wrote:

If you declare them as TUniMainModule class variables they will global for

same session but invisible to other sessions. Otherwise if you declare as

regular global vars they will be global to all session.

 

Please can you instruct me how to do this?

 

I do not know wher and how to declare those variables.

 

Kindly regards Leo Nillesen

Link to comment
Share on other sites

As far I understand, each session create it owned TUniMainModule object, so, each field (not class var) of it, is unique for this session and only can accessed by this session.

 

However, a global var or class var (static class var), are common to all session. It's as application variables, instead session variables. This var types can be accessed by all session and must be protected by critical section

Link to comment
Share on other sites

As far I understand, each session create it owned TUniMainModule object, so, each field (not class var) of it, is unique for this session and only can accessed by this session.

 

However, a global var or class var (static class var), are common to all session. It's as application variables, instead session variables. This var types can be accessed by all session and must be protected by critical section

 

I made a very simple application with 2 editfields, uniedit1 and uniedit2 and 2 buttons unibutton1 and unibutton2.

The unibutton1 loads the content of the uniedit1 in a variable called GV_data

The unibutton2 loads the content of GV_Data in uniedit2.

 

What you see now is:

if the first session loads via unibutton1 the content of uniedit1 in GV_data you can via a second session load the data

from gv_data into uniedit2 by pressing unibutton2.

 

As fare as i see i declared GV_data in the correct module.

I attacted the simple application in a zip file.

would you be so kind to look at it?

 

 

Kindly regards Leo Nillesen.

Link to comment
Share on other sites

As far I understand, each session create it owned TUniMainModule object, so, each field (not class var) of it, is unique for this session and only can accessed by this session.

 

However, a global var or class var (static class var), are common to all session. It's as application variables, instead session variables. This var types can be accessed by all session and must be protected by critical section

 

 

I think i missed the attachment

so again:

 

 

I made a very simple application with 2 editfields, uniedit1 and uniedit2 and 2 buttons unibutton1 and unibutton2.

The unibutton1 loads the content of the uniedit1 in a variable called GV_data

The unibutton2 loads the content of GV_Data in uniedit2.

 

What you see now is:

if the first session loads via unibutton1 the content of uniedit1 in GV_data you can via a second session load the data

from gv_data into uniedit2 by pressing unibutton2.

 

As fare as i see i declared GV_data in the correct module.

I attacted the simple application in a zip file.

would you be so kind to look at it?

 

 

Kindly regards Leo Nillesen.

Multiuser.zip

Link to comment
Share on other sites

Yes, both sessions can see the GV_data content because it's a module global var.

 

If you declare GV_data as TUniMainModule var, then both session have it own GV_Data and can't see the value of another session var:

 

TUniMainModule = class(TUniGUIMainModule)

private

 

public

{ Public declarations }

GV_data: String;

end;

 

.....

 

procedure TMainForm.UniButton1Click(Sender: TObject);

begin

UniMainModule.GV_Data := UniEdit1.Text;

end;

 

procedure TMainForm.UniButton2Click(Sender: TObject);

begin

UniEdit2.Text := UniMainModule.GV_Data;

end;

Link to comment
Share on other sites

Yes, both sessions can see the GV_data content because it's a module global var.

 

If you declare GV_data as TUniMainModule var, then both session have it own GV_Data and can't see the value of another session var:

 

TUniMainModule = class(TUniGUIMainModule)

private

 

public

{ Public declarations }

GV_data: String;

end;

 

.....

 

procedure TMainForm.UniButton1Click(Sender: TObject);

begin

UniMainModule.GV_Data := UniEdit1.Text;

end;

 

procedure TMainForm.UniButton2Click(Sender: TObject);

begin

UniEdit2.Text := UniMainModule.GV_Data;

end;

 

 

Dear Juan,

 

thanks for the quick responce.

Indeed in this way is works fine.

 

Does that mean that all the sqlquery's also has to be defined in the

TUniMainModule part or is this only valid for the variables.

 

Again thank you very much and kindly regards

Leo Nillesen.

Link to comment
Share on other sites

Dear Juan,

 

thanks for the quick responce.

Indeed in this way is works fine.

 

Does that mean that all the sqlquery's also has to be defined in the

TUniMainModule part or is this only valid for the variables.

 

Again thank you very much and kindly regards

Leo Nillesen.

 

 

I don't understand what you mean with'sqlquery's'. TSQLQuey components? In any case, when you drag and drop a TQuery component into UniMainModule, it's a private field of object UniMainModule, so it's private for this session, (each seassion have it's own TQuery Object). Any component, object or variable defined as part of TUniMainModule class is private for each session because each session has it's own TUniMainModule object via UniMainModule function.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...