ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

monitor loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • monitor loop

    using the monitor opcode to loop on a locked
    dataarea until the lock is released or until
    the cows come home

    PHP Code:

           
    //  

         
    d alreadylocked   s               n
         d cmdstring       s            256
         d cmdlength       s             15  5
         d somefield       s              5  0

         D Locked          C                   00202

           
    //
           //  external calls
           //

         
    d $command        pr                  extpgm('QCMDEXC')
         
    d   command                    256
         d   Length                      15  5

          
    /Free

            
    //--------------------------------------------------------
            // MAIN PROGRAM
            //--------------------------------------------------------

             
    cmdstring 'ALCOBJ OBJ((LBIFIL/BRC01LOCK *DTAARA *EXCL))';
             
    cmdlength =  %len(%trim(cmdstring));

             
    dou Alreadylocked = *off;
             
    monitor;
             
    AlreadyLocked = *off;
             
    $command(cmdstringcmdlength);
             
    On-error Locked;
              
    somefield =  %Status;
              
    AlreadyLocked = *on;
             
    endmon;
             
    enddo;

             *
    inlr = *on;



          /
    End-Free 
    Attached Files
    All my answers were extracted from the "Big Dummy's Guide to the As400"
    and I take no responsibility for any of them.

    www.code400.com

  • #2
    Re: monitor loop

    Minor addition:

    PHP Code:
    If CowsAreHome
    Goto Exit
    EndIf
    Exit       
    Tag 
    Yeah, i know - fixed format required. But to be able to use a GOTO and an INDICATOR, its worth it !

    Comment


    • #3
      Re: monitor loop

      Moooo! ........
      All my answers were extracted from the "Big Dummy's Guide to the As400"
      and I take no responsibility for any of them.

      www.code400.com

      Comment


      • #4
        Re: monitor loop

        Originally posted by arrow483 View Post
        Minor addition:

        PHP Code:
        If CowsAreHome
        Goto Exit
        EndIf
        Exit       
        Tag 
        Yeah, i know - fixed format required. But to be able to use a GOTO and an INDICATOR, its worth it !
        Arrow,

        Please! Are you guys kidding me?! Subprocedures are required!

        PHP Code:
        If NOTCowsAreHome );
           If 
        SeachForCowsSucessfull <> TRUE;
              
        CallStatePolice = *ON;
              
        PoliceHelpNeededCallStatePolice );
        Else;
              
        GotoBedAndSleepSoundly;
        EndIf; 
        By the way, the only reason I'm on here is my better half is out of town. What's your excuses for being here in the evening?

        Having fun, typing slowly,
        MdnghtPgmr
        "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

        Comment


        • #5
          Re: monitor loop

          im a big geek!
          All my answers were extracted from the "Big Dummy's Guide to the As400"
          and I take no responsibility for any of them.

          www.code400.com

          Comment


          • #6
            Re: monitor loop

            Jamie,1

            I guess that makes me one too! Break out the adult beverages!

            Slurping away,
            MdnghtPgmr
            "Tis better to be thought a fool then to open one's mouth and remove all doubt." - Benjamin Franklin

            Comment


            • #7
              Re: monitor loop

              I have to say my wife is also out....and Im finding this Vista to be more difficult as
              I go..... The Cisco VPN client I have wont connect.....and it triggered some kind of non-compatability error which I couldnt clear...had to restore from restore point.........YEEHA! what fun Im having now ....Guess Ill be on the phone with CISCO all day tomorow
              All my answers were extracted from the "Big Dummy's Guide to the As400"
              and I take no responsibility for any of them.

              www.code400.com

              Comment


              • #8
                Re: monitor loop

                Not to doubt anyone, but does this method of trapping an error outside of the RPG program work? I used to think it did until I worked with it and found that I had to import the exception to capture something that went bad with a QCMDEXC call. I found that Monitor only handled errors internal to the program.

                Does that make sense? Is it correct?
                Your friends list is empty!

                Comment


                • #9
                  Re: monitor loop

                  you are correct .... the qcmdexc actually ends with error 202
                  (Called program or procedure failed; halt indicator)
                  not :
                  00431 Data area previously locked by another program
                  00432 Data area locked by program in the same process
                  Last edited by FaStOnE; April 5, 2007, 01:31 PM. Reason: Spell Check
                  All my answers were extracted from the "Big Dummy's Guide to the As400"
                  and I take no responsibility for any of them.

                  www.code400.com

                  Comment

                  Working...
                  X