PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Global variables
Global variables
Débuté par Carlos SIlva, 29 sep. 2004 11:44 - 4 réponses
Posté le 29 septembre 2004 - 11:44
Hello all.
I have simplified my code to 3 statements
//the first 2 are in the initialization for the project
GLOBAL
version_id_system is character
version_id_system = "ABC"

on any window that I launch I put a button and the code is:
Info(version_id_system)
I would expect the message window to display “ABC”
But it always shows “A” – The first and only character of the global variable content

What am I doing wrong? – Could someone please throw me a bone.
WD8 - WindowsXP SP2
Thanx
-carlos
Posté le 29 septembre 2004 - 11:59
Carlos,
Try the line:
version_id_system is string
instead of:
version_id_system is character
hth,
Clive
Posté le 29 septembre 2004 - 14:02
Carlos
Character is 1 character, use string which is a string of characters.
version_id_system is string = "ABC"
Also you don't need the global statment. Anything you put in the the initialization for the project is global.
You can also declare the variable and assign it a value in one line of code as I have done above. HTH
John
Hello all.
I have simplified my code to 3 statements
//the first 2 are in the initialization for the project
GLOBAL
version_id_system is character
version_id_system = "ABC"

on any window that I launch I put a button and the code is:
Info(version_id_system)
I would expect the message window to display “ABC”
But it always shows “A” – The first and only character of the global variable content

What am I doing wrong? – Could someone please throw me a bone.
WD8 - WindowsXP SP2
Thanx
-carlos
Posté le 23 décembre 2004 - 04:19
I want to write to a log file from many windows and when initializing and closing the project.

When I declare its handle "gLogID is int" in the Initialization of the project, it is not recognized by the Global procedures, for example

global procedure
PROCEDURE f_WriteToLog(sText)
IF gLogID <> -1 THEN
fWriteLine(gLogIDl,Today + " " + Left(Now,2) + ":" + Middle(Now,3,2) + ":" + Middle(Now,5,2) ...
+ " : " + sText)
END

does not recognize gLogID.

When I declare gLogID in the Global Procedures, then the project and the windows knowsnothing about it.

Is there any way to declare a very global variable or alternatively a very global procedure usable from everywhere?
Posté le 25 décembre 2004 - 18:30
Hello Ion,

that's cursios, for me and all of my apps I don't see such a behaviour. All things declared in the init of a project is visible/accessible
in the whole project.

Are you sure that the typo (gLogID1) in your example isn't the problem?

Regards

Raimund

In article <41ca20ed$1@news.pcsoft.fr>, Ion wrote:
I want to write to a log file from many windows and when initializing and closing the project.

When I declare its handle "gLogID is int" in the Initialization of the project, it is not recognized by the Global procedures, for example

global procedure
PROCEDURE f_WriteToLog(sText)
IF gLogID <> -1 THEN
fWriteLine(gLogIDl,Today + " " + Left(Now,2) + ":" + Middle(Now,3,2) + ":" + Middle(Now,5,2) ...
+ " : " + sText)
END

does not recognize gLogID.

When I declare gLogID in the Global Procedures, then the project and the windows knowsnothing about it.

Is there any way to declare a very global variable or alternatively a very global procedure usable from everywhere?