putmsg and PUTMSG in modules

nduvnjak
Posts: 40
Joined: Wed Feb 06, 2008 3:45 pm

putmsg and PUTMSG in modules

Post by nduvnjak »

If I have the script called "mainscript" that calls a module, another script "mymodule", like this:

<uses mymodule>
<a name=main>
...
<mymodule>
...

It appears that I can't use PUTMSG setting nor putmsg error handler in "mymodule"???

When I tried to include <PUTMSG print off> in "mymodule", compiler reported the error, that setting can't be used in modules.
Also if I define the <a name=putmsg> function in "mymodule", apparently the execution never goes there.

How can I catch the errors in "mymodule"?

Obviously I have the reason to do it there, because as the name indicates, that is where I can write some custom code, while "mainscript" is not "mine".

thank you all
User avatar
Kai
Site Admin
Posts: 1272
Joined: Tue Apr 25, 2000 1:27 pm

putmsg and PUTMSG in modules

Post by Kai »

Only one <putmsg> function ever gets called; that function doesn't change if the execution locale moves to another module. You'd have to rewrite the current <putmsg> function (presumably in "mainscript") to buffer messages into global variables (perhaps when a global flag is set), and check/flush that buffer whenever you're in a "mymodule" function.

We've been planning on adding a way to dynamically change the <putmsg> function that gets called, and/or allowing a module to set a <putmsg> function. Some priority/queueing issues need to be worked out though, eg. if both the main-script caller and the module want to catch messages.