Sandy Blondino
8th October 2013, 23:10
Hello,
I have specific task I need to accomplish. I want a custom Baan session to run continuously checking a custom table for unprocessed records inserted from a barcode system.
I don't want to run it in a job because we've had trouble keeping the jobs running smoothly.
I want the session to run continuously checking for new records, then go to sleep for a while, then check for records again, etc.
Can I use the wait.and.activate and suspend functions in the session that I want to control?
Thanks for any ideas on this.
Sandy
bhushanchanda
8th October 2013, 23:24
Hi,
You can create a vb script which will call a dll in Baan. Execute this vb script using a scheduler say windows task scheduler.
Inside, your dll you can write whatever you want. There are a lot of ways to do that, you just need to chose the best for you.
Check all these threads:-
Thread 1 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=8872)
Thread 2 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=5882&highlight=bshell6.2)
Thread 3 (http://www.baanboard.com/baanboard/showthread.php?s=&threadid=5794&highlight=bshell6.2)
Thread 4 (http://www.baanboard.com/baanboard/showthread.php?t=64202)
Hope they give you some hint.
vahdani
9th October 2013, 10:53
Hi,
here is what I would do:
Make a main session (4 GL type 4) that basically only starts a subprocess (a 3GL script) which does the actual checking and processing.
In the main 4 GL session:
declaration:
long sub.process
before.program:
sub.process = activate("otcxxx9999")
choice.end.program:
if sub.process > 0 then
putvar(sub.process, "harakiri", true)
endif
Here the 3GL subprocess script:
extern domain tcbool harakiri
function main()
{
harakiri = false
while true
check.for.new.records()
suspend(10000) |10000 miliseconds = 10 seconds
if harakiri then
break
endif
endwhile
}
function check.for.new.records()
{
|check for new records an process any found
...
}
vahdani
10th October 2013, 16:33
Hi Sandy,
forget may last post! Here my latest try which needs no 3GL script. Create a type 4 Session with a display field "ticks" (domain tcmcs.long) and copy the following to the script.
The session calls the processing function continuously and can be stopped any time.
declaration:
extern long ticks
long g.alarm
|****************************** program section ********************************
before.program:
ticks = 0
|create analarm which calls choice.interrupt
g.alarm = set.alarm(1000)
|****************************** group section **********************************
group.1:
init.group:
get.screen.defaults()
choice.interrupt:
on.choice:
|alarm rings!
ticks = ticks + 1
display("ticks")
do.some.processing()
|create new alarm
g.alarm = set.alarm(1000)
functions:
function do.some.processing()
{
|check table records, etc.
|...
}
Sandy Blondino
10th October 2013, 17:57
Thanks for the ideas and code.
One question about using the set.alarm function.
How do you end the program gracefully, so that it's not in the middle of a record read or something?
Sandy
vahdani
10th October 2013, 18:22
Hi,
this is taken care of by the bshell. If you press the OK button the session first responds when no more code is running. This is also our daily experience. A long running session (print, etc.) can only be forced to stop by killing its process else you have to wait.