vars declared as public - multi user environment

vars declared as public - multi user environment

am 06.12.2007 18:12:16 von mirandacascade

Apologies in advance for what I'm guessing may be a trivial question.

Assume the following:
1) multi-user environment
2) standard (i.e. not a class module) module with:

Public strSample as String

3) first user user opens app at 9:00 and runs code that results in
setting the variable strSample to "abc"
4) first user keeps the app open, but does nothing with the app for 2
minutes
5) second user opens app at 9:01 and runs code that results in setting
the variable strSample to "xyz"
6) second user keeps his/her app open, but does nothing with the app
for 2 minutes
7) at 9:02, first user returns to using the app, and runs code that
needs to interrogate the contents of the variable strSample

Question: is there any risk that at step #7 when the first user runs
code that interrogates the contents of strSample, that variable will
contain "xyz" (set at 9:01 by second user) rather than "abc" (set at
9:00 by first user)?

As you can tell, I have a fundamental lack of understanding how
applications manage address space in a multi-user environment. I
would guess that, even though this is a multi-user environment and the
variable is declared 'Public', that each user gets his/her own address
space, and that there is no risk that the strSample variable that got
set in the first user's address space will get 'stepped on' by the
second user. But, that's just conjecture on my part...hence the
question.

Thank you.

Re: vars declared as public - multi user environment

am 06.12.2007 21:02:50 von Salad

mirandacascade@yahoo.com wrote:

> Apologies in advance for what I'm guessing may be a trivial question.
>
> Assume the following:
> 1) multi-user environment
> 2) standard (i.e. not a class module) module with:
>
> Public strSample as String
>
> 3) first user user opens app at 9:00 and runs code that results in
> setting the variable strSample to "abc"
> 4) first user keeps the app open, but does nothing with the app for 2
> minutes
> 5) second user opens app at 9:01 and runs code that results in setting
> the variable strSample to "xyz"
> 6) second user keeps his/her app open, but does nothing with the app
> for 2 minutes
> 7) at 9:02, first user returns to using the app, and runs code that
> needs to interrogate the contents of the variable strSample
>
> Question: is there any risk that at step #7 when the first user runs
> code that interrogates the contents of strSample, that variable will
> contain "xyz" (set at 9:01 by second user) rather than "abc" (set at
> 9:00 by first user)?

Variables are stored in memory. They don't have a static value. I
could enter
Dim i as integer
i = 1
i = 2
i = 3
I is now holds the value of 3.

Memory on your computer isn't stored in the memory of another computer.
So if a variable is 1 on your machine and 2 in another there's no
conflict.

Now if you mean "variable" actually meaning a value stored in a table
and written to disk...then of course there'd be a difference if one
person changed the value and wrote an updated value to a table.

> As you can tell, I have a fundamental lack of understanding how
> applications manage address space in a multi-user environment. I
> would guess that, even though this is a multi-user environment and the
> variable is declared 'Public', that each user gets his/her own address
> space, and that there is no risk that the strSample variable that got
> set in the first user's address space will get 'stepped on' by the
> second user. But, that's just conjecture on my part...hence the
> question.

From the above you aren't referring to a table field. I think if we
were of the Borg, a public variable would be sharable amoung entities.
But we aren't Borg and neither are computers...yet. That's why
mind-reading is an accurate art.

Let's say I have a routine called SumIt() in a form. I would make it
private to that form. If I had 50 forms, and all used a function called
SumIt(), they could all be the same or could be different. If all of
the SumIt() functions were the same, it would be better to put it in a
code Module and make the funtion Public and remove that function from
all the forms. That way all forms using SumIt could call the same
function in the code module. If I made a change to that function, all
calls from all forms would take the new changes.

> Thank you.
>