IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to STOP infinite LOOP in REXX


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 4:03 pm
Reply with quote

Hi,

How to stop infinite loop. This is the rexx code

Code:
/****REX****/
num=1
do forever
 say 'number 'num
 num=num+1
end


How the number is running. to stop this .....

right now i am terminating the entire ISPF session. How to stop the infinite loop without doing that.....


Sushanth
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Mon Jan 05, 2009 4:18 pm
Reply with quote

having to terminate Your ISPF session is just the right punishment for sloppy coding icon_biggrin.gif

when testing it is usually a good practice to have an additional constraint on do statements in order to avoid endless loops

the sample You posted is just bad code
add some test to terminate the loop icon_cool.gif
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Mon Jan 05, 2009 4:21 pm
Reply with quote

Try your ATTN (Attention) key.

O.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 4:30 pm
Reply with quote

Enrico,

Got the PUNISHMENT. So many windows closed. The Sloppy Code i posted, is what i typed & executed. I was trying how to break infinte loop.
From the manual,
Quote:
When you suspect an exec is in an infinite loop, you can end the exec by
pressing the attention interrupt key, sometimes labeled PA1. You will then see
message IRX0920I. In response to this message, type HI for halt interpretation
and press the Enter key. If that doesn't stop the loop, you can press the
attention interrupt key again, type HE for halt execution, and press the Enter key.


Ofer, the ATTN gets me to the region selection screen. There, when i choose ISPF, Again i get into the loop. Then Again, i pressed ATTN key, went to the region selection and i had to takedown the ISPF session.

Any ideas how to run HI or HE commands, where to run the commands ?

Sushanth
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jan 05, 2009 4:38 pm
Reply with quote

If num > nnnnn THEN EXIT
Back to top
View user's profile Send private message
ofer71

Global Moderator


Joined: 27 Dec 2005
Posts: 2358
Location: Israel

PostPosted: Mon Jan 05, 2009 4:41 pm
Reply with quote

You may hit HI or HE in the prompt after you hit ATTN... icon_lol.gif

I assume you are working under TPX or some other session management system. IIRC, you will have to change the settings of ATTN in your session management product to make it available under TSO.

O.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 4:49 pm
Reply with quote

Ofer,

Its not working.......

Sushanth
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8796
Location: Welsh Wales

PostPosted: Mon Jan 05, 2009 4:52 pm
Reply with quote

Have you tried the Esc Key ?
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Mon Jan 05, 2009 5:04 pm
Reply with quote

Expat,

Another TAKEDOWN.

Sushanth
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Mon Jan 05, 2009 10:32 pm
Reply with quote

Try defining a SIGNAL ON HALT routine prior to starting your loop.
Back to top
View user's profile Send private message
sushanth bobby

Senior Member


Joined: 29 Jul 2008
Posts: 1020
Location: India

PostPosted: Tue Jan 06, 2009 10:49 am
Reply with quote

Pedro,

SIGNAL ON HALT before the loop.

Code:
/**** REXX ************************************/
/* LOOP FOREVER                               */
/**********************************************/
NUM=1                                           
SIGNAL ON HALT                                 
DO FOREVER                                     
   SAY 'NUMBER 'NUM                             
   NUM=NUM+1                                   
END                                             


Also another take down
ATTN & ESC keys didn't work.

Sushanth
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Tue Jan 06, 2009 10:18 pm
Reply with quote

Quote:
Try defining a SIGNAL ON HALT routine prior to starting your loop.


Please read my comment. I do not see where you defined a HALT routine in your program. If you do not understand, please read about SIGNAL in the rexx reference manual.
Back to top
View user's profile Send private message
genesis786

Active User


Joined: 28 Sep 2005
Posts: 210
Location: St Katherine's Dock London

PostPosted: Tue Jan 06, 2009 11:34 pm
Reply with quote

Hi Pedro I tried following code on my mainframe:

Code:

/* rexx */       
signal on halt   
do forever       
end             
exit             
halt:           
exit             


what key do i need to press to interrupt the program? I tried ctrl+c, Esc, PA1,PA2,PA3, all PF keys... is halt key system specific ?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19243
Location: Inside the Matrix

PostPosted: Wed Jan 07, 2009 12:14 am
Reply with quote

Hello,

Is one of those mapped as your ATTN key?

The info here may also help:
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ikj4a360/11.2.1.1?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10886
Location: italy

PostPosted: Wed Jan 07, 2009 12:32 am
Reply with quote

looks like this topic is getting into a loop icon_biggrin.gif
Back to top
View user's profile Send private message
Pedro

Global Moderator


Joined: 01 Sep 2006
Posts: 2593
Location: Silicon Valley

PostPosted: Wed Jan 07, 2009 1:31 am
Reply with quote

With IBM's PCOMM emulator, you would right click to see a popup of special keys, including Attention.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Run rexx with JCL Job CLIST & REXX 1
No new posts Run rexx in batch job CLIST & REXX 7
No new posts Does anyone know rexx for VSE CLIST & REXX 3
No new posts TSO ALLOC In REXX Needs Improvement JCL & VSAM 3
No new posts REXX/CMS How to place command console... CLIST & REXX 4
Search our Forums:

Back to Top