RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Is Debug Active Print E-mail
User Rating: / 0
Written by Chamara Withanachchi   

Extracted from RPG Cafe

Do you ever want some code to run only when the debugger is active? Here's a procedure you can call to find out:

Test program

 /copy indebug
    if inDebug();
       dsply ('The debugger is active');
       dsply ('The debugger is not active');

Member INDEBUG_PR containing the prototype

   /if not defined INDEBUG_INCLUDED
 D inDebug         pr              n   extproc('inDebug')

Member INDEBUG containing the procedure

 H nomain
  /copy indebug
 P inDebug         b                   export
 D inDebug         pi              n
 D QteRetrieveDebugAttribute...
 D                 pr                  extproc(
 D                                      'QteRetrieveDebugAttribute')
 D   attribute                   10a   const
 D   value                       10a   const
 D   errorcode                         likeds(qusec)
 D dummy           s             10a
  /copy qsysinc/qrpglesrc,qusec
         QUSBPRV = %size(QUSEC);
         QteRetrieveDebugAttribute ('*UPDPROD'  // pick any attribute
                                  : dummy
                                  : qusec);
         if  QUSBAVL > 0
         and QUSEI = 'CPF9541';
            return '0';  // job is not in debug mode
            return '1';  // job is in debug mode
 P inDebug         e
<Previous   Next>