× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Wed, 26 Feb 2003, Andy Hautamaki wrote:
>
> I have a series of batch jobs that if they get a record lock on update will
> call a CLP program and pass it how long to do a DLYJOB and then after the
> 'Delay' my RPG programs will try to retrieve the record again.
>

Well... you could just do OVRDBF FILE(MYFILE) WAITRCD(xxx), and not have
to do a delay at all...  (Unless I don't understand your question
correctly)

> My question is, instead of doing this 'DLYJOB' from a CLP can it be done
> directly from within RPG? ........ API maybe????
>

If for some reason, you don't want to use the WAITRCD() method above,
here's a few ways of doing delays in an RPG program.   This is an actual
program that compiles and runs :)

     H DFTACTGRP(*NO) BNDDIR('QC2LE')

     D QcmdExc         PR                  extpgm('QCMDEXC')
     D   command                    200A   const
     D   length                      15P 5 const

     d cmd             s            200A
     D len             s             15P 5

     D select          PR            10I 0 extproc('select')
     D   max                         10I 0 value
     d   read                          *   value
     d   write                         *   value
     d   except                        *   value
     d   timeout                       *   value

     D tv              ds
     D   tv_sec                      10I 0
     D   tv_usec                     10I 0

     D sleep           PR            10U 0 extproc('sleep')
     D   seconds                     10U 0 value

     D usleep          PR            10I 0 extproc('usleep')
     D   microsecs                   10U 0 value

      *
      * QcmdExc can run just about any command that you
      * can type from the command-line, including DLYJOB
      *
     c     'one'         dsply
     c                   callp     QcmdExc('DLYJOB DLY(1)': 200)

      *
      * Or, if you're feeling nostalgic, here's another way to
      * call QCMDEXC
      *
     c     'two'         dsply
     c                   eval      cmd = 'DLYJOB DLY(1)'
     c                   eval      len = 200

     c                   call      'QCMDEXC'
     c                   parm                    cmd
     c                   parm                    len

      *
      * Another exciting way would be to use the select() API.
      * This has the advantage that you can wait for strange time
      * values... such as 1.8 seconds...
      *
     c     'three'       dsply
     c                   eval      tv_sec = 1
     c                   eval      tv_usec = 800000
     c                   callp     select(0: *NULL: *NULL: *NULL: %addr(tv))

      *
      *  Then, there's the ILE C runtime  (requires BNDDIR('QC2LE'))
      *
     c     'four'        dsply
     c                   callp     sleep(1)

      *
      *  Or, the ILE C runtime that can do things in microseconds
      *    (also requires BNDDIR('QC2LE'))
      *
     c     'five'        dsply
     c                   callp     usleep(1000000)

     c                   eval      *inlr = *on


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.