Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 2 Jahren, 3 Monaten
Letzter Beitrag:
vor 2 Jahren, 3 Monaten
Beteiligte Autoren:
Sivaprakash, Curtis, Marc De Swert, Fabrice Harari

[Windev 20] Globale variable declaration

Startbeitrag von Sivaprakash am 17.11.2015 10:51

Hello,

When I try to define the same globale variable in two different windows, I get the following error.

will be renamed to
Ambiguities may occur with global variable 'WIN-X.'.

Is it not possible to define the same (global) variable in two different windows ?

May be this is really silly, but I couldn't locate the problem, if any.

Happiness Always
BKR Sivaprakash

Antworten:

It's better to define a global variable in the project initializing, then you can use it every where

von Marc De Swert - am 17.11.2015 11:23
Thanks Marc De Swert,

Yes, that's an alternative. But in another project, I saw the same variables used in two different windows. It's working there, but not in my project. That wonders me. As I'm new to WX, I couldn't figure out what's wrong in my project.

Happiness Always
BKR Sivaprakash

von Sivaprakash - am 17.11.2015 13:05
Hi

Are you sure it's an error? I would think this is indicated as a WARNING... Which would be correct, and you can of course click on it and tell windev to stop woarning you about that specific case.

Best regards

von Fabrice Harari - am 17.11.2015 13:18
i did a test and yes, on 2 different windows i can set the same variable
declared as

global
SComment is string

von Marc De Swert - am 17.11.2015 13:24
In my experience WinDev is hit or miss when it comes to telling you that ambiguities may occurr between variables. Sometimes it will warn you, sometimes it won't.

What I don't understand is why there is an ambiguity to begin with. Say that I have 2 windows, WinA and WinB. If I create a variable 'nCount is int' in the global declaration of each window why would they conflict? If I'm using nCount on WinB, how or why would it ever mistake nCount from WinA?

von Curtis - am 17.11.2015 16:25
-IT- would never mistake anything... -YOU- would

If you have two windows active at the same time, and the second one is called by the first one (even with a few other in the middle) and you have the same gloabl variable in the two, YOU may think that you are using winA variable even when you are in winB...

Furthermore, I think that there is a PROJECT level option changing the scope of variables that may influence this warning

Best regards

von Fabrice Harari - am 17.11.2015 17:33
Thanks Fabrice, that makes sense. I'll have to look into the project options.

von Curtis - am 17.11.2015 18:02
Thanks for you replies.

Yes, it's a warning only. Not an error.
My scenario is to call two windows one after another from Project init code. The second window is opened, after closing the first window, and only if necessary.

My declaration is
gwsWindowName, gwsFileName, gwsGUIDName is ANSI string

(I'm using WXReplication and I need to set values to these variables )

And the warnings appear immediately on introduction of these variables in the window and NOT at runtime.

I'm trying to avoid to declare all these at project level. I saw in WXReplication that these variables are declared in every window.

I thought that some project level setting might be there as mentioned by Fabrice, but I couldn't figure it out.

Happiness Always
BKR Sivaprakash

von Sivaprakash - am 19.11.2015 06:08
Hello,

Small Update

I tried to introduce new global variable in WXReplication project. It complains with the same warning. Seems those warnings are suppressed by Fabrice, for declared variables.

I think it takes to the valid point by Curtis. Why it should complain, when these two are from different objects and not siblings or child windows ?

Marc De Swert could tell us how he did ?

Happiness Always
BKR Sivaprakash

von Sivaprakash - am 19.11.2015 08:08
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.