Jump to content

Variables


fil

Recommended Posts

Why is a globally declared variable in the Main Form publicly available for all sessions?

I am declaring a variable in the main form. And this variable is publicly available for all sessions. It is not right.

how to avoid this? I need a separate variable for each session.

Link to comment
Share on other sites

9 hours ago, fil said:

Why is a globally declared variable in the Main Form publicly available for all sessions?

 

Not only in the main form. Probably in any form. And in the unimainmodule including.

You need to declare global variables in the public section of the main module.

Link to comment
Share on other sites

10 hours ago, fil said:

Why is a globally declared variable in the Main Form publicly available for all sessions?

 

 

Quote

When implementing the functionality of this form, it is important to remember that it can only use the ServerModule, DataModule, and any other temporary form using them, but not the MainForm. In fact, no form should ever access the MainForm, but the MainModule.

 

Link to comment
Share on other sites

On 10/30/2020 at 9:57 AM, fil said:

Why is a globally declared variable in the Main Form publicly available for all sessions?

I am declaring a variable in the main form. And this variable is publicly available for all sessions. It is not right.

how to avoid this? I need a separate variable for each session.

How do I repeat this behaviour? I run two instances of the app in two tabs of the same browser or one instance each of the app in two different browsers and I am not seeing this.

I declare a variable in the public section of the MainForm:

  public
    { Public declarations }
    cVar : String;

and add a button in the MainForm to change the variable to something in the OnClick event:

cVar:='Changed';

and show the variable in the MainForm's OnShow event:

showmessage(cVar);

After clicking the button in the first instance of the app, I run the second app but do not see the "Changed" message.

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1539)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...