Terapad
Created with the free version of Terapad, ads can be removed from $14.15 a month Easy Website Creation Sign Up Now

Content

Order and simplicity...

IBMLogo.jpg Tuesday, 24 July 07 - 01:13 PM (GMT -05:00)
By David Rowswell in RPG snippets

My friend Kevin says:

Don't you just love when there is inherent natural order and symmetry in things

d test                            d   inz(*sys)      
d  yy                            2  0 overlay(test:3)
d  mm                            2  0 overlay(test:6)
d  dd                            2  0 overlay(test:9)

 

Email this  |  Submit to digg  |  Add to del.icio.us  |  Permalink  |  Leave a comment  


Need your RPG program to wait?

IBMLogo.jpg Wednesday, 11 July 07 - 03:02 PM (GMT -05:00)
By David Rowswell in RPG snippets
A tip from my friend, Kevin:
Need your program to wait (perhaps you've monitored a record lock and want to wait 15 seconds for it to clear).? You could code a DOW loop for some god awful huge (10i0) value and let the system chug away counting, but that wastes cycles someone else could be using.  You could use QCMDEXC and code a DLYJOB.  Or you can use the C library function sleep (or its twin brother usleep - which uses microseconds instead of seconds) 
h option(*nodebugio:*srcstmt) dftactgrp(*no) actgrp(*new) bnddir('QC2LE')
d sleep           pr            10u 0 extproc('sleep')                  
d   seconds                     10u 0 value                             
c                   callp     sleep(15)                                 
c                   eval      *inlr = *on
                               
h option(*nodebugio:*srcstmt) dftactgrp(*no) actgrp(*new) bnddir('QC2LE')
d usleep          pr            10u 0 extproc('usleep')                  
d   seconds                     10u 0 value                             
c                   callp     usleep(15000000)                                 
c                   eval      *inlr = *on
                               
 
Oh, by the way, you might have noticed that sleep (and usleep) have a return value. 
If the sleep is interrupted (by a ENDJOB, ENDSBS, or PWRDWNSYS request) the
return value tells how much longer it wanted to sleep. 
This way, you can code and test if the return value is not 0 and end your program.
 
c                   if        sleep(15) <> 0          
c*                    sleep aborted by job end request
c                   endif
                             
..and what dreams does a program dream while it sleeps?
Email this  |  Submit to digg  |  Add to del.icio.us  |  Permalink  |  View 1 comment  


... More items are available in our News Archive