HMG 3.1.5. Variable Problem

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

radohabjan
Posts: 94
Joined: Mon Nov 30, 2009 7:17 am
Location: Slovenia
Contact:

HMG 3.1.5. Variable Problem

Post by radohabjan » Mon Aug 05, 2013 3:05 pm

Hello Friend,

I have big problem with variables in new version 3.1.5..
All variables in sub procedures are not defined (variable test), but variables in main procedure is OK. In 3.0.46 works perfect.
See the code:

Code: Select all


#include "hmg.ch"

PROCEDURE Main
SET LANGUAGE TO SLOVENIAN
REQUEST HB_CODEPAGE_SLWIN
HB_CDPSELECT("SLWIN")
test1="Q"
DEFINE WINDOW Win_1  AT 0,0 WIDTH 540 HEIGHT 460 MAIN
ON KEY ESCAPE ACTION Win_1.Release
 Define Button Button_4
 Row   300
 Col   80
 Caption 'Test'
 Action test()
 End Button
END WINDOW
Win_1.Center
Win_1.Activate
RETURN

procedure test
test="W"
DEFINE WINDOW Win_2  AT 0,0 WIDTH 540 HEIGHT 460 MODAL
ON KEY ESCAPE ACTION Win_2.Release
 Define Button Button_4
 Row   300
 Col   80
 Caption 'Test Variable'
 Action test1()
 End Button
END WINDOW
Win_2.Center
Win_2.Activate
RETURN

procedure test1()
msginfo(test1)
msginfo(test)
return

Variable test is not defined.

br Rado

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Aug 05, 2013 3:31 pm

I have tested your code and I also noted there are diferance in 3.0.46 and 3.1.4 with last version 3.1.5. I do not know if is Harbour behaviou or HMG. But if you try this:

Code: Select all

#include "hmg.ch"

PROCEDURE Main
/* SET LANGUAGE TO SLOVENIAN
REQUEST HB_CODEPAGE_SLWIN
HB_CDPSELECT("SLWIN") */
Public test1:="Q"

DEFINE WINDOW Win_1  AT 0,0 WIDTH 540 HEIGHT 460 MAIN
ON KEY ESCAPE ACTION Win_1.Release
 Define Button Button_4
 Row   300
 Col   80
 Caption 'Test'
 Action test()
 End Button
END WINDOW
Win_1.Center
Win_1.Activate
RETURN

procedure test
Public test2:="W"

DEFINE WINDOW Win_2  AT 200,100 WIDTH 540 HEIGHT 460 MODAL
ON KEY ESCAPE ACTION Win_2.Release
 Define Button Button_4
 Row   300
 Col   80
 Caption 'Test Variable'
 Action test1()
 End Button
END WINDOW
// Win_2.Center
Win_2.Activate
RETURN

procedure test1()
msginfo(test1)
msginfo(test2)
return
Then it will work, but need to change private for public declaration of variables.

The strange is between versions 3.1.4 and 3.1.5 in this case.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Aug 05, 2013 3:40 pm

Now with this patch, it is also working for your example ! :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
Location: Araruama-RJ, Brazil

Post by Amarante » Mon Aug 05, 2013 7:13 pm

Português:
Depois que instalei a versão 3.1.5 passei a ter erros quando declaro parametros em uma função. :?
Estas variáveis declaradas como PARAMETERS devem ser reconhecidas como publicas por outras procedures no módulo, como está documentado no Clipper NG, mas não estão. :shock:
O mais estranho é que fiz alguns testes simples e funcionaram, mas quando compilo um programa que funciona bem na 3.1.4 o mesmo falha na 3.1.5. :cry:
Também notei comportamento estranho em janelas modal, por exemplo, em uma função rodando embaixo do 3.1.4 executo uma janela modal e logo após executo uma msginfo, quando rodo embaixo do 3.1.5 simplesmente após a janela modal a msginfo não funciona, simplesmente nada acontece. Estranho... Voltei para a 3.1.4 onde tudo está funcionando ok. :mrgreen:

Google Translator:
After I installed version 3.1.5 I started to have errors when I declare parameters in a function. :?
These variables declared PARAMETERS must be recognized as public by other procedures in the module, as documented in Clipper NG, but are not. :shock:
The strange thing is that I did some simple tests and worked, but when I compile a program that works well in 3.1.4 the same failure 3.1.5. :cry:
I also noticed strange behavior in modal windows, for example, a function running under the 3.1.4 run a modal window and after I perform a msginfo when road under the 3.1.5 just after the msginfo modal window does not work, simply nothing occurs. Strange ... I went back to 3.1.4 where everything is working ok. :mrgreen:

User avatar
esgici
Posts: 4363
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 245 times
Been thanked: 91 times
Contact:

Post by esgici » Mon Aug 05, 2013 8:18 pm

Amarante wrote:...
After I installed version 3.1.5 I started to have errors when I declare parameters in a function. :?
Please clarify, what "errors" you are about ?
These variables declared PARAMETERS must be recognized as public by other procedures in the module, as documented in Clipper NG, but are not.
Sorry, but it seems that you are wrong; please look at attached image captured from Clipper NG.
PARAMETER.JPG
What kind will be variable declared by PARAMETER statement ?
PARAMETER.JPG (77.72 KiB) Viewed 2333 times
...just after the msginfo modal window does not work, simply nothing occurs. Strange ... I went back to 3.1.4 where everything is working ok. :mrgreen:
Message problem may be related to this subject.

Happy HMG'ing :D
Viva INTERNATIONAL HMG :D

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Aug 05, 2013 8:55 pm

De fato Amarante, havia problemas com respeito as citações suas, pois a instrução do Dr. Soto de colocar como comentário a linha 49 do arquivo C:\hmg.3.1.5\SOURCE\h_windows.prg, então deixa-a assim:

// #define ALLOW_ONLY_ONE_MESSAGE_LOOP

Depois disso, grave o arquivo e execute o C:\hmg.3.1.5\BuildLib.bat. Recompile o programa e verifique se persistem os mesmos erros e relate pra gente aqui.

---

It is a fact Amarante, there were problems regarding your citations, as the instruction of Dr. Soto to put as a comment line 49 of file C:\hmg.3.1.5\SOURCE\h_windows.prg, then let it lije this:

// # define ALLOW_ONLY_ONE_MESSAGE_LOOP

After that, save the file and run the C:\hmg.3.1.5\ BuildLib.bat file. Recompile your program and check if it is contining with the same mismatches and report to us here.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
Location: Araruama-RJ, Brazil

Post by Amarante » Mon Aug 05, 2013 9:02 pm

esgici wrote:
Amarante wrote:...
After I installed version 3.1.5 I started to have errors when I declare parameters in a function. :?
Please clarify, what "errors" you are about ?
Tonight (I'm in Brazil) will be publishing a job here in the forum (hopefully) that I think will be useful to all and where it may be clearer what is happening in 3.1.5, please wait.
These variables declared PARAMETERS must be recognized as public by other procedures in the module, as documented in Clipper NG, but are not.
Sorry, but it seems that you are wrong; please look at attached image captured from Clipper NG.
My fault, where I wrote public read private

User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil
Has thanked: 100 times
Been thanked: 177 times

Post by Pablo César » Mon Aug 05, 2013 9:04 pm

Amarante wrote:My fault, where I wrote public read private
Yeah Esgici is correct. But any way these problems seems is also affected by that patch of Dr. Soto, please try and revert.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein

User avatar
Amarante
Posts: 182
Joined: Fri Apr 27, 2012 9:44 pm
Location: Araruama-RJ, Brazil

Post by Amarante » Mon Aug 05, 2013 9:07 pm

Português:
Obrigado Pablo César, vou recompilar a h_windows.prg e testar.

Google Translate:
Thanks Pablo César, will recompile h_windows.prg and test.

User avatar
srvet_claudio
Posts: 1957
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 31 times
Been thanked: 124 times
Contact:

Post by srvet_claudio » Mon Aug 05, 2013 11:38 pm

This is the line of all the problems of HMG.3.1.5
// #define ALLOW_ONLY_ONE_MESSAGE_LOOP

This macro makes that HMG works as would a normal C program in Windows with a single loop of messages, but HMG is Clipper programming style not is C programming. I'll try to explain with a simple example:

Code: Select all

#include "hmg.ch"

PROCEDURE Main
PRIVATE var1 := 100

   DEFINE WINDOW Win_1  AT 0,0 WIDTH 300 HEIGHT 300 MAIN
      @ 50, 50 Button Button_1 Caption 'Test' Action test()
   END WINDOW
   Win_1.Center
   Win_1.Activate
RETURN


PROCEDURE Test
PRIVATE var2 := 200
   MsgDispVar ("One")  ---> this work Ok

   DEFINE WINDOW Win_2  AT 0,30 WIDTH 200 HEIGHT 200 MODAL
      @ 50, 50 Button Button_1 Caption 'Test' Action MsgDispVar ("Tow")  //  ---> this not work with a single message loop
   END WINDOW
   Win_2.Center
   Win_2.Activate
RETURN


PROCEDURE MsgDispVar (Title)
   MsgInfo (ListCalledFunctions (), Title)
   MsgDebug (var1, IF(TYPE("var2")<>"U", Var2, NIL))
RETURN
With multiple loops message every time you activate a window, the program stop at that point and waiting for user response and thus simulates what would READ clause in Clipper when running on DOS.

With a single message loop the activate a window, not stop the execution of the program and the procedure continues.
In this case the Win_2.Activate is equivalent to Win_2.Show as in C.
Is for this razon that second call of MsgDispVar() not work well, because Test() procedure is finish and var2 not exist.
Compare the result of ListCalledFunctions() with a single and with a multiple message loop and see diference.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

Post Reply