× 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.



Hi Albert,

On Thu, 4 Oct 2001, York, Albert wrote:

> Can anyone tell me why the program below doesn't work? The program compiles
> and runs but doesn't delay at all.

I don't know why your code doesn't work -- but theres something odd going
on here --  usleep() isn't mentioned in the ILE C/400 Run-time reference.

Also, I find that your program compiles, even when I don't bind to the
QC2LE binding directory, which is odd...  I wonder what procedure it's
actually calling?

At any rate -- here's a way to do a usleep() in RPG, without needing to
call the usleep function:


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

     D microsleep      PR            10I 0
     D  parm_usec                    10I 0 value

     c                   eval      *inlr = *on

     c                   if        microsleep(30000000) < 0
     c                   eval      Msg = 'error'
     c                   dsply                   msg              50
     c                   endif

     c                   return


      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
      *  microsleep -- this emulates the usleep() function available
      *    on most UNIX system
      *
      *    parm_usec = number of microseconds to sleep.
      *
      *   returns 0 upon success, -1 upon failure.
      *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P microsleep      B
     D microsleep      PI            10I 0
     D  parm_usec                    10I 0 value

     D select          PR            10I 0 ExtProc('select')
     D  nfds                         10I 0 value
     D  readfds                        *   value
     D  writefds                       *   value
     D  exceptfds                      *   value
     D  timeout                        *   value

     D p_timeval       s               *
     D timeval         DS                  based(p_timeval)
     D   tv_sec                      10I 0
     D   tv_usec                     10I 0

     D size            s             10I 0
     D rc              s             10I 0

     c                   eval      size = %size(timeval)
     c                   alloc(e)  size          p_timeval
     c                   if        %error
     c                   return    -1
     c                   endif

     c                   eval      tv_sec = 0
     c                   eval      tv_usec = parm_usec
     c                   eval      rc= select(0:*NULL:*NULL:*NULL:p_timeval)

     c                   dealloc(e)              p_timeval

     c                   return    rc
     P                 E




As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.