Hi,

Mindaugas Kavaliauskas wrote:
homework.prg (test module):
PROC main()
  ? netio_connect()
  ? NETIO_PROCEXISTS("HB_HRBLOAD")
  ? NETIO_PROCEXISTS("HELLO")
  ? NETIO_PROCEXECW("HB_HRBLOAD", HB_MEMOREAD("homework2.prg"))
  ? NETIO_PROCEXISTS("HELLO")
  ? NETIO_FUNCEXEC("HELLO")
RETURN

Unfortunately test code prints:
.T.
.T.
.F.
and application hangs up.

Sorry. It was a simple typo, should be:
   ? NETIO_PROCEXECW("HB_HRBLOAD", HB_MEMOREAD("homework1.hrb"))
                                                        ^ ^^^
This method works!

BTW, results for this test are:
C:\harbour\contrib\hbnetio\tests>homework.exe

.T.
.T.
.F.
.T.
.T.
Hello, World! :)
C:\harbour\contrib\hbnetio\tests>homework.exe

.T.
.T.
.T.
.T.
.F.
NIL
C:\harbour\contrib\hbnetio\tests>homework.exe

.T.
.T.
.F.
.T.
.T.
Hello, World! :)
C:\harbour\contrib\hbnetio\tests>homework.exe

.T.
.T.
.T.
.T.
.F.
NIL

I.e. every second time existing function is destroyed by unsuccessful overload. I'm not sure (not tested the details) if it is a bug in runner.c or some strange side effect, like: the second time code s_hHrb := HB_HRBLOAD("...") is called, HB_HRBLOAD() fails because Hello() already exists. So, HB_HRBLOAD() returns empty value and destroys the last pointer to loaded hrb module in static variable. The next time module does not clashes with existing functions, so, it's loaded again.

Modification of homework1.prg solves the problem:
STATIC s_hHrb
INIT PROC LoadHello()
IF EMPTY(s_hHrb)
#pragma __streaminclude "homework2.hrb"|s_hHrb := HB_HRBLOAD(%s)
ENDIF
RETURN


Regards,
Mindaugas
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to