GLOBAL e GLOBAL EXTERNAL
Moderador: Moderadores
GLOBAL e GLOBAL EXTERNAL
Pesquisando,
Achei este tipo no documento do xHarbour, isso existe no harbour?
GLOBAL <varName> [:= <xValue> ]
GLOBAL EXTERNAL <extVarName>
GLOBAL <varName>
<varName> is the symbolic name of the global variable to declare.
<xValue>
<xValue> is an optional value to assign to the GLOBAL variable after being declared. To assign a value, the inline assignment operator (:=) must be used. The simple assignment operator (=) cannot be used. Only literal values are allowed for <xValue> when declaring GLOBAL variables.
GLOBAL EXTERNAL <extVarName>
This is the name of a GLOBAL variable that is declared in another PRG file and must be referred to in the current PRG file.
Achei este tipo no documento do xHarbour, isso existe no harbour?
GLOBAL <varName> [:= <xValue> ]
GLOBAL EXTERNAL <extVarName>
GLOBAL <varName>
<varName> is the symbolic name of the global variable to declare.
<xValue>
<xValue> is an optional value to assign to the GLOBAL variable after being declared. To assign a value, the inline assignment operator (:=) must be used. The simple assignment operator (=) cannot be used. Only literal values are allowed for <xValue> when declaring GLOBAL variables.
GLOBAL EXTERNAL <extVarName>
This is the name of a GLOBAL variable that is declared in another PRG file and must be referred to in the current PRG file.
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
GLOBAL e GLOBAL EXTERNAL
Eu testei aqui e não funcionou com Harbour 3.2
Testei dessa forma e ele nem compilou.
global.prg
prc.prg
Testei dessa forma e ele nem compilou.
global.prg
Código: Selecionar todos
GLOBAL v := "Teste"
PROCEDURE Main
//GLOBAL v := "Teste"
? V
? PrcExterna()
RETURN
Código: Selecionar todos
GLOBAL EXTERNAL v
PROCEDURE PrcExterna()
? v
RETURN
GLOBAL e GLOBAL EXTERNAL
Acho que isso é exclusivo do xharbour
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
GLOBAL e GLOBAL EXTERNAL
Também cheguei a testar se isso funcionava.
Já teria algum uso pra isso?
Resolvi com funções.
Já teria algum uso pra isso?
Resolvi com funções.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
GLOBAL e GLOBAL EXTERNAL
Achei essa informação:
GLOBAL variables:
GLOBAL <Id1> [,<Id2> [,<IdN>]]
GLOBAL Variables are a new kind of a declared variables. they have PUBLIC like visibility, but are faster than even STATICs. GLOBALS can be referenced from other modules using the syntax:
GLOBAL EXTERNAL <Id1> [,<Id2> [,<IdN>]]
GLOBAL Variables have the added benefit of being *directly* accessible from C code too.
Sample code:
GLOBAL variables:
GLOBAL <Id1> [,<Id2> [,<IdN>]]
GLOBAL Variables are a new kind of a declared variables. they have PUBLIC like visibility, but are faster than even STATICs. GLOBALS can be referenced from other modules using the syntax:
GLOBAL EXTERNAL <Id1> [,<Id2> [,<IdN>]]
GLOBAL Variables have the added benefit of being *directly* accessible from C code too.
Sample code:
Código: Selecionar todos
//-------------------------------------//
GLOBAL g_MyObject
#include "hbclass.ch"
PROCEDURE Main()
g_MyObject := MyClass()
MyCFunction()
RETURN
CLASS MyClass
METHOD MyMethod INLINE Alert( "MyMethod" )
ENDCLASS
#pragma BEGINDUMP
HB_FUNC( MYCFUNCTION )
{
hb_objSendMsg( &G_MYOBJECT, "MyMethod", 0 );
// Note must be ALL-CAPS!
}
#pragma ENDDUMP
//-------------------------------------//
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
GLOBAL e GLOBAL EXTERNAL
Bom, as minha duvidas foram esclarecidas:
### GLOBAL / GLOBAL EXTERNAL (GLOBAL_EXTERN) ###
======================================================
xHarbour support application wide static variables called GLOBALs.
To declare GLOBAL variable you have to put
GLOBAL <varname> [ := <initValue> ]
before the 1-st function in compiled .prg module and use -n compiler
switch. In xHarbour GLOBAL variables cannot be declared inside function
body. If user wants to use GLOBAL variable in different .prg module
then he has to add declaration
GLOBAL EXTERNAL <varname>
to his code before the 1-st function in compiled .prg module and use
-n compiler switch. Also, GLOBAL EXTERNAL declaration cannot be used
in function body. Unlike other variables GLOBALs declared in xHarbour
reserve used names so they cannot be used in the same module in local
function declarations, f.e. xHarbour cannot compile code like:
GLOBAL var
GLOBAL EXTERNAL var2
func F1( var )
return var * 2
func F2()
FIELD var2
return var2
due to name conflicts. In general users should be careful using the same
names for different type of variables in xHarbour.
GLOBAL variables in xHarbour need static link time bindings so they
do not work with dynamically loaded PCODE functions from .hrb files
or shared libraries (.dll, .so, .sl, .dyn, ...). Just like STATICs
they cannot be accessed by macro compiler.
Harbour does not support GLOBALs.
Fonte:https://github.com/vszakats/harbour-cor ... b-diff.txt
### GLOBAL / GLOBAL EXTERNAL (GLOBAL_EXTERN) ###
======================================================
xHarbour support application wide static variables called GLOBALs.
To declare GLOBAL variable you have to put
GLOBAL <varname> [ := <initValue> ]
before the 1-st function in compiled .prg module and use -n compiler
switch. In xHarbour GLOBAL variables cannot be declared inside function
body. If user wants to use GLOBAL variable in different .prg module
then he has to add declaration
GLOBAL EXTERNAL <varname>
to his code before the 1-st function in compiled .prg module and use
-n compiler switch. Also, GLOBAL EXTERNAL declaration cannot be used
in function body. Unlike other variables GLOBALs declared in xHarbour
reserve used names so they cannot be used in the same module in local
function declarations, f.e. xHarbour cannot compile code like:
GLOBAL var
GLOBAL EXTERNAL var2
func F1( var )
return var * 2
func F2()
FIELD var2
return var2
due to name conflicts. In general users should be careful using the same
names for different type of variables in xHarbour.
GLOBAL variables in xHarbour need static link time bindings so they
do not work with dynamically loaded PCODE functions from .hrb files
or shared libraries (.dll, .so, .sl, .dyn, ...). Just like STATICs
they cannot be accessed by macro compiler.
Harbour does not support GLOBALs.
Fonte:https://github.com/vszakats/harbour-cor ... b-diff.txt
►Harbour 3.x | Minigui xx-x | HwGui◄
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pense nas possibilidades abstraia as dificuldades.
Não corrigir nossas falhas é o mesmo que cometer novos erros.
A imaginação é mais importante que o conhecimento. (Albert Einstein)
- JoséQuintas
- Administrador

- Mensagens: 20267
- Registrado em: 26 Fev 2007 11:59
- Localização: São Paulo-SP
GLOBAL e GLOBAL EXTERNAL
Na época entendi que seria igual variável pública, mas que poderia ser usada em multithread.
Exatamente esse foi meu interesse.
Mas já falamos disso em outro tópico.
Eu usei funções.
Não precisa declarar variável, e o compilador avisa se o nome estiver errado.
Acaba sendo mais seguro.
Até pensei em declarar como classe, mas aí o compilador não vai avisar se errar o nome.
Ainda mais que meu computador está pedindo um teclado novo há bastante tempo, e de vez em quando as teclas falham e o teclado precisa de uma chacoalhada..... rs
Se não fosse a compilação -w3 -es2...... rs
Exatamente esse foi meu interesse.
Mas já falamos disso em outro tópico.
Eu usei funções.
Código: Selecionar todos
FUNCTION AppVersao( xValue )
STATIC x
IF xValue != NIL
x := xValue
ENDIF
RETURN x
Acaba sendo mais seguro.
Até pensei em declarar como classe, mas aí o compilador não vai avisar se errar o nome.
Ainda mais que meu computador está pedindo um teclado novo há bastante tempo, e de vez em quando as teclas falham e o teclado precisa de uma chacoalhada..... rs
Se não fosse a compilação -w3 -es2...... rs
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"
https://github.com/JoseQuintas/

