Welcome! Log In Create A New Profile

Advanced

Newbie question about global variables

Posted by Marco Rego 
Marco Rego
Newbie question about global variables
November 03, 2008 06:22PM
How do I create a global variable (an array in my case) in a project (a library) and use it in other projects that import the first one.
I could just create a variable global to one project only.
Thanks.
BLS
Re: Newbie question about global variables
November 03, 2008 09:44PM
Hi Marco,
not that bad for a "noob" question ! smiling smiley Indeed : a pretty complicated one

unfortun. your question is not very clear regarding the environment.
Do you mean : Share a variable between several application on a single workstation

Do you mean : How to share a variable within a LAN / WAN environment ?

Or do you talk about a WEB Site session ?

*Several solutions are possible, but it would be nice if you can specify what you need.

Bjoern
* Semaphore, Memory Mapped File, serialisation+file locking etc.
Oh, and before Fabrice is going mention it , you can always use a HF database record to store and retrieve ... smiling smiley

Hey Fabrice whay about the regex sources ?





Edited 3 time(s). Last edit at 11/03/2008 09:53PM by BLS.
Marco Rego
Re: Newbie question about global variables
November 03, 2008 10:42PM
In my specific case, I have a library-project (let's call it project A) where I have several sets of procedures and classes.

Then I have other projects where I use the procedures and classes of project A. No problem here.

Now, I declared an array on the global declaration section of project A and I thought it woud be visible to other projects that uses the library (project A), but it is not, it is visible just inside project A.

Now we go to my first question, is it possible to have an array declared in the global section of a library project be visible to other projects that uses the library ?

Thanks.

BLS
Re: Newbie question about global variables
November 03, 2008 11:47PM
Quote
Marco Rego
In my specific case, I have a library-project (let's call it project A) where I have several sets of procedures and classes.

Then I have other projects where I use the procedures and classes of project A. No problem here.

Ok, I see.

Quote

Now we go to my first question, is it possible to have an array declared in the global section of a library project be visible to other projects that uses the library ?

Yes.
Let's say you have something like that /

//Procedure library A
PUBLIC
a is array of 10 int
a[1] = 42

//Procedure library B
PUBLIC
a is array of 10 int
a[1] = B.a[1]

Frankly said, I am a bit guessing about your problem and I'm afraid that my hints don't help... show some code please. makes life easier. smiling smiley

Bjoern

Quote

Now, I declared an array on the global declaration section of project A and I thought it woud be visible to other projects that uses the library (project A), but it is not, it is visible just inside project A.

What is an array of global declarations ?
Let's say your procedure library A contains something like that
//projectA
PUBLIC
myFoo is int = 1
myBar is string = "HereIAm"
myStruct is structure
a is array of 2 string
end
and so on ...
----
I do not see (and beside there is no secure way) to declare an array of pointers to global declarations in Windev

In C++ you will declare void[] * arrayofdecl; But I thinks this is not what you want smiling smiley

However : you can indeed touch your global variables by calling them as follows

//set
projectA.myFoo = 100
//get
x is int = projectA.myFoo

I wish I can give you a more precise answer but therefor you have to show some code.


Fabrice Harari
Re: Newbie question about global variables
November 04, 2008 12:41AM
Hi Marco..

I must say that I never tried to use WDL with global projects variables... As there is already a global project section in any project, it looks to me like there would be a conflict...

PERHAPS doing something like LibraryName.GlobalVarName COULD work, but I would personally prefer to work differently (I use very rarely global variables :-)

So I would probably just store my array in a class (either as a standard variable if possible or as a global one, with global methods to access it...

As a class is usable in a library, the global array declared in it (and global methods to get/set/clean the garbage) would be available too...

best regards

Fabrice Harari
WinDev, WebDev, WinDev Mobile consulting

PS: Bjoern: I do NOT do EVERYTHING with HF :-)
BLS
Fabrice
November 04, 2008 02:51AM
Fabrice, I .........could....................not......................................resist,

winking smiley
Bjoern
Would be nice to meet you in Guadeloupe
My friend is born there, and since he is "Let's Go Fishing" fanatic like me ....hey maybe
KenKnight
Re: Newbie question about global variables
November 04, 2008 02:57AM
Hi Marco,

Check out the "Sharing Memory" component located in the components pane. This should provide you with the basic info on sharing memory. I have tested this in the past (even under vista) and it does work.

Cheers!
Ken
Fabrice Harari
Re: Fabrice
November 04, 2008 12:35PM
Hi Bjoern...

Just let me know when you come :-)


Fabrice
"Michel HERRSCHER".pcs.crosspost
Re: Fabrice
November 04, 2008 04:40PM
Hey some people works here,
but may be you'll check the new version of your next project during
"fishing"
;-)))

--
Michel HERRSCHER Consultant
tel : +33450870912


"Fabrice Harari" <guest@news.pcsoft.fr> a écrit dans le message de news:
35692008110412500343.16359@news.pcsoft.fr...
>
> Hi Bjoern...
> Just let me know when you come :-)
>
> Fabrice
>
>


Message forwarded from pcsoft.us.windev
Fabrice Harari
Re: Fabrice
November 04, 2008 05:27PM
That will be my only answer:



Plage de l'Autre Bord, Le Moule, Gaudeloupe AKA my second office grinning smiley

Fabrice
Jimbo
Re: Fabrice
November 04, 2008 05:53PM

Ouch ! That one hurts !
BLS
Re: Fabrice
November 05, 2008 06:26PM
YEP !
I think next year in November (after the rain is gone in Guadeloupe ) it would be great to meet you folks. Working that hard during the last two years, still having a lot of work, it would be great to have a time out . But I can't promise that a notebook is part of my journey equipment smiling smiley

In case that you have a need to stay in the south of france : Mi casa Tu Casa. 09/Ariege next to St'Girons

Bjoern

Beside : At least two gentleman are living here. (means not necessarily me smiling smiley




Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: