exit from a multiple loop DO



IBM's Command List programming language & Restructured Extended Executor

exit from a multiple loop DO

Postby samb01 » Wed Oct 06, 2021 1:04 pm

Hello, i would like to exit the first do if PLATEAU = A, or if PLATEAU = B
The first DO is in the line


 DO J = 1 TO DS2.0  
 


If i use the commande EXIT, i would exit from the DO just before but not the first DO (i don't know if i make me anderstood...)


     "EXECIO * DISKR IN2 (FINIS STEM DS2."                
        DO J = 1 TO DS2.0                                
          IND01 = INDEX(DS2.J,'SCF0350I')                
          IF IND01 <> 0 THEN                              
          DO                                              
            IND02 = INDEX(DS2.J,'401-')                  
            IF IND02 <> 0 THEN                            
              DO                                          
                 PLATEAU = A                              
              END                                        
            ELSE                                          
              DO                                          
                 PLATEAU = B                              
              END                                        
          END                                            
        END                                              
"EXECIO * DISKR IN (FINIS STEM DS."                      
  DO I = 1 TO DS.0                                        
 


Thank's for your help.
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: exit from a multiple loop DO

Postby willy jensen » Wed Oct 06, 2021 1:11 pm

Use LEAVE to exit the current DO, EXIT exits the program.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: exit from a multiple loop DO

Postby samb01 » Wed Oct 06, 2021 2:52 pm

Hello,

it's not the current do but the do before and before. I you have a look thre are 3 do.
If i lsten to you i would do that :


"EXECIO * DISKR IN2 (FINIS STEM DS2."                
        DO J = 1 TO DS2.0                                
          IND01 = INDEX(DS2.J,'SCF0350I')                
          IF IND01 <> 0 THEN                              
          DO                                              
            IND02 = INDEX(DS2.J,'401-')                  
            IF IND02 <> 0 THEN                            
              DO                                          
                 PLATEAU = A    
                   LEAVE    
              END                                        
            ELSE                                          
              DO                                          
                 PLATEAU = B  
                   LEAVE                          
              END                                        
          END                                            
        END                                              
"EXECIO * DISKR IN (FINIS STEM DS."                      
  DO I = 1 TO DS.0                                        
 

 


but i will get out of this DO :


           DO                                          
                 PLATEAU = B  
                   LEAVE                          
              END              
 


But i want to leave this DO


  DO J = 1 TO DS2.0                                
 
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: exit from a multiple loop DO

Postby willy jensen » Wed Oct 06, 2021 5:43 pm

Ok, since J is the controlling variable for that outer loop, you can use LEAVE J.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: exit from a multiple loop DO

Postby Pedro » Wed Oct 06, 2021 10:14 pm

re: " LEAVE J"

Wow! I am excited because I did not know you could do that.
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: exit from a multiple loop DO

Postby willy jensen » Wed Oct 06, 2021 10:21 pm

you can also do ITERATE J.
it's all in the manual ;)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: exit from a multiple loop DO

Postby sergeyken » Wed Oct 06, 2021 11:01 pm

I would improve the clarity of the code.
The habit to do so may simplify your life significantly in the future.

"EXECIO * DISKR IN2 (FINIS STEM DS2."                
Do J = 1 To DS2.0                                
   IND01 = Pos( 'SCF0350I', DS2.J )                
   If IND01 <> 0 Then Do                            
      IND02 = Pos( '401-', DS2.J )                  
      If IND02 <> 0 Then                            
         PLATEAU = A    
      Else                                          
         PLATEAU = B  
      Leave J                          
   End /* IND01 */
End J


Another option

"EXECIO * DISKR IN2 (FINIS STEM DS2."                
Do J = 1 To DS2.0                                
   IND01 = Pos( 'SCF0350I', DS2.J )                
   If IND01 = 0 Then
      Iterate J                /* next line now */                          
   IND02 = Pos( '401-', DS2.J )                  
   If IND02 <> 0 Then                            
      PLATEAU = A    
   Else                                          
      PLATEAU = B  
   Leave J                 /* all found, exit loop */
End J
Javas and Pythons come and go, but JCL and SORT stay forever.
User avatar
sergeyken
 
Posts: 408
Joined: Wed Jul 24, 2019 10:12 pm
Has thanked: 6 times
Been thanked: 40 times

Re: exit from a multiple loop DO

Postby samb01 » Mon Oct 11, 2021 6:07 pm

Hello Sergeyken and thank's for your help.
I like this code because it dosen't have to end the code if the word SCF0350I dosen't exist.


"EXECIO * DISKR IN2 (FINIS STEM DS2."                
Do J = 1 To DS2.0                                
   IND01 = Pos( 'SCF0350I', DS2.J )                
   If IND01 = 0 Then
      Iterate J                /* next line now */                          
   IND02 = Pos( '401-', DS2.J )                  
   If IND02 <> 0 Then                            
      PLATEAU = A    
   Else                                          
      PLATEAU = B  
   Leave J                 /* all found, exit loop */
End J
 
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time

Re: exit from a multiple loop DO

Postby Pedro » Thu Oct 14, 2021 3:52 am

Can you provide a sample input file?
Pedro Vera
User avatar
Pedro
 
Posts: 684
Joined: Thu Jul 31, 2008 9:59 pm
Location: Silicon Valley
Has thanked: 0 time
Been thanked: 53 times

Re: exit from a multiple loop DO

Postby samb01 » Thu Oct 14, 2021 1:29 pm

Hello :


 CPU1      2021286  09:57:34.62             ISF031I CONSOLE OPC ACTIVATED
 CPU1      2021286  09:57:34.62            -F EMCSCF,DEV,DIS,VOL(CSYS01)
 CPU1      2021286  09:57:34.63             SCF0350I  C103(CSYS01) ONLINE     EMC-000297000402-C100-0000A7-01-03
 CPU1      2021286  09:57:34.63             SCF0356I DEVICE DISPLAY VOLUME COMMAND COMPLETED.
 
samb01
 
Posts: 427
Joined: Mon Nov 16, 2009 7:24 pm
Has thanked: 1 time
Been thanked: 0 time


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post