MEMVAR a
PROCEDURE Main
PRIVATE a := 20
Teste()
Inkey(0)
FUNCTION Teste()
LOCAL a := 10
? m->a
? a
RETURN Nil
Resultado na tela:
20
10
Usar variável com m-> não é a mesma coisa que declarar variável.
m-> é pra variáveis PRIVATE.
Interessante isso....
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.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)
Sim MEMVAR é pra declarar variáveis PUBLIC e PRIVATE.
E m->variavel é justamente pra pegar valor de PUBLIC/PRIVATE.
Sempre pensei que m-> indicava qualquer tipo de variável, mas é só pra PUBLIC/PRIVATE.
Na compilação -w3 -es2 isso fica bem claro, porque m-> acaba sendo similar a declarar como memvar.
No caso de rotinas de LIB, por exemplo, colocar m-> em tudo que é variável pode ter resultados imprevisíveis.
Aqui uso alias pra aquivos, e somente pra arquivos. arquivo->campo
Variáveis deixo sem nenhuma indicação, sempre declarando LOCAL ou MEMVAR pras exceções.
E declaração FIELDS não uso. A única exceção é na indexação: index on field->campo TAG tatu
Na indexação funciona usar arquivo->campo, mas isso deixa preso ao ALIAS, e nunca se sabe se poderemos usar alias diferente.
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/
FUNCTION Main()
LOCAL a
a := 10
m->a := 20
? a
? m->a
inkey(0)
Retorna 10, 20
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/
FUNCTION Main()
LOCAL a
a := 10
? a
? m->a
inkey(0)
RETURN Nil
E aqui.... dá erro de variável não existe no m->a
definitivamente m->variavel indica explicitamente variável diferente de LOCAL.
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/