A Sleepy RPG Program
April 1, 2009 Hey, Ted
Does RPG have anything equivalent to CL’s Delay Job (DLYJOB) command? I am working on an RF application, and I need to code a delay of a few seconds into my program. Besides using a do loop with a final value of 1,000,000,000,000, how can I cause a timed interval within an RPG program? –David Thanks to the wonders of the Integrated Language Environment, RPG has a way to delay a job a specific number of seconds. It’s called sleep. Sleep requires one 4-byte unsigned integer parameter–the number of seconds to delay–which must be passed by value. Here’s an example: H dftactgrp(*no) actgrp(*new) H option(*srcstmt:*nodebugio) H bnddir('QC2LE') D sleep pr 10u 0 extproc('sleep') D Interval 10u 0 value D t1 s z D t2 s z /free *inlr = *on; t1 = %timestamp(); sleep (10); t2 = %timestamp(); dump(a); Notice that you must make the program consult the QC2LE binding directory in order for the compiler to find the sleep procedure. The interval may not be exactly the one you specify, due to processing, but it will be close. Calling sleep will certainly be more accurate than counting to a trillion. –Ted
|