Ilansu
1st August 2002, 13:26
Another question .

Can I control more then one timer on the same session ??
I'm trying to use two timers on a session .
Each timer should activate a different function .
before.program:
timer1=set.timer(5000)
timer2=set.timer(10000)

choice.interrupt:
on.choice:
if (timer1 was activated) then
run.timer1.function()
else
if (timer2 was activated) then
run.timer2.function()
endif
endif
I tried the next.event() ,peek.event() etc' did any one have any success in doing that ?

Thanks
Ilan S

Ilansu
7th August 2002, 16:41
Hallo Again .


Any one have any idea ???

I need to activate 2 Timers and activate different actions .

Ilan S

mark_h
7th August 2002, 17:27
I have not used timers so I can not help with your question. Maybe if you explained what you are trying to accomplish, then someone may have a solution that does not involve timers.


Mark

Ilansu
8th August 2002, 01:01
Mark hi .

I'm trying to make an automatic refresh of 2 tables in different times.

Timps3101m000 uses a timer to make an automatic refresh of mps data.

What I need is to make the same thing but with 2 different timers that will make an update on 2 different tables .
The set.timer(time interval) returns a timer id ,and when it reaches the time interval it activates the choice.interrup section.
In that section I’m executing a baan function which makes an update on a table .
The timer then starts again etc’.
What I need is to use 2 timers in order to activate 2 different functions , and I can’t use 1 timer because the update each update is independent.
So , I need to be able to identify the timer which activated the interrupt by using the
Timer id.

This is the sample that I posted in the question :

before.program:
timer1.id=set.timer(7000)
timer2.id=set.timer(10000)

choice.interrupt:
on.choice:
if (timer1.id was activated) then
automatic.update.table.1()
endif
if (timer2.id was activated) then
automatic.update.table.2()
endif

Thanks for the reply

I hope my question is more clearer.

Ilan S

Gerhard Wandl
5th February 2003, 17:42
hello,

try something like this:


declaration:
long timerid1
long timerid2
long event(EVTMAXSIZE)

form.1: |or before.program:
init.form:
timerid1=set.timer(3000)
timerid2=set.timer(5000)

choice.interrupt:
on.choice:
next.event(event)
if evt.type(event)=EVTTIMEREVENT then
if evt.timer.id(event)=timerid1 then
refresh.display1()
endif
if evt.timer.id(event)=timerid2 then
refresh.display2()
endif
endif

gw

jaapzwaan
6th February 2003, 11:19
Gerhard,

I don't think it will work. When a timer goes off, the 4GLE receives a EVTTIMEREVENT and calls the choice.interrupt section. So far so good.
WHat you propose for this section is reading the next event. This is no longer the same event that the 4GLE received. It might even take some time before the next.event() function returns. I doubt if this event is an EVTTIMEREVENT. If it isn't, this event is simply ignored.
Note that it is always dangerous to program your own next.event statement in a 4GL script: you're catching an event that you probalbyl cannot handle.

The original event data is (unfortunately) not available in this choice section.

I have an alternative solution:

Create a 3GL program that sets the timers and enters an event loop. In this event loop you can find the timer.id as explained in the previous post. Based on this timer.id, do an export of a variable and fire a new timer event to your 4GL session.


In your 4GL session, in the before.program section, start this 3GL. (note that the parent of this 3GL is the 4GL session) and declare an external variable that will be set by the 3GL.
In the choice interrupt section, you now have the id of the timer available in the external variable and you don't have to catch your own events.

I hope this is clear to you.

Regards,
Jaap Zwaan

Gerhard Wandl
6th February 2003, 11:39
hmm ... i just tried it on a display form (no input-fields, no updates, ...) and there it works ... i dont know why, but it works! :-)

for creating 3gl-programms my knowlegde is to less :-(( but perhaps, i will learn here more and more and more ... :-)

jaapzwaan
6th February 2003, 15:30
It might seem to work, but you just ignore events that are sent after the EVTTIMEREVENT that are not of type EVTTIMEREVENT. Also the first EVTTIMEREVENT is ignored, because you start waiting for the next event to happen.
If your timers do fire a lot of events and it is not an error that half of them is not handled, then it works.
BUt if you want to catch each and every timer event, it is not correct.

Although you're using a display session, also other commands might slip through and are ignored. You might even have to press the "exit" button several times before the window closes. This is because of your "next.event" command that ignores all other events.

BTW: 3GL programming is as easy as creating a DLL; you only have to add a function called main to it.

Regards,
Jaap Zwaan

günther
23rd November 2004, 08:34
It might seem to work, but ...
Jaap,

I totally agree with you. But at the moment I have a programming project that would be easy, if I could "enhance" the standard 4GL event handler so that I could receive events that are not handled there.
The other way (programming 3GL) requires a lot of work if the session requires the look-and-feel of standard 4GL session. Any ideas?

günther
23rd November 2004, 08:44
... Can I control more then one timer on the same session??...


I think your problem could be solved in another way. Use one timer with a much higher resolution (say every second), and decide by your own, which function to call in that situation, eg.

declaration:
long timer
long counter

before.program:
timer=set.timer(1000)
counter=0

choice.interrupt:
on.choice:
counter = counter + 1
if counter \ 5 = 0 then
run.timer1.function()
endif
if counter \ 7 = 0 then
run.timer2.function()
endif
I
Note, that it is possible that one timer interrupt "fires" two function calls (counter = 35, 70 etc in my example).

Günther