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

How to exitwhen you select option from panel???


IBM Mainframe Forums -> TSO/ISPF
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Thu Jul 10, 2014 12:56 am
Reply with quote

Hi guys,

Just got the question , i have the panel , in this panel have several option. There will be option said when you tpye X , the progrom will exit. How to do that ? Thanks

Code:
Option_ 
0  DEFAULTS                       
1  PREPARE       
2  TSO         
                                       
X  EXIT          - Exit primary menu   


My code :
Code:
uname=ARG(1)             
ADDRESS ISPEXEC         
"DISPLAY PANEL (panel2)"
rc=4                     
DO WHILE rc <> 0         
  SELECT                 
    WHEN c=1 THEN DO     
     rc=REXX4()         
    END                 
    WHEN C=2 THEN DO     
     rc=rexx1()         
    end                 
    WHEN C=x THEN DO     
   ?????????????????????
    END                 
    OTHERWISE           
    rc=4                 
    END                 
  END                   
END   
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Thu Jul 10, 2014 1:17 am
Reply with quote

Unsurprisingly, the keyword is exit.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu Jul 10, 2014 5:35 am
Reply with quote

Quote:
Unsurprisingly, the keyword is exit.

You can use any method to exit the DO loop. As another alternative, you can use a LEAVE instruction. See the rexx reference for more information.

Sorry to nitpick your code...

But the example assumes the user types X in the panel then presses Enter. The user should also be able to merely press F3, in which case your code should check for RC=8.

And it is not clear, but I think you want the DISPLAY to be inside of the DO loop so that it allows the user to serially select any of the options and when done, then press F3. As it is currently written, the panel is only shown once.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Thu Jul 10, 2014 6:39 am
Reply with quote

Pedro wrote:
Quote:
Unsurprisingly, the keyword is exit.

You can use any method to exit the DO loop. As another alternative, you can use a LEAVE instruction. See the rexx reference for more information.

I believe that the TS wanted to exit the progrom (sic), not just the DO loop.

And, yes, that code is not just not right, it's not even wrong. Presumably the TS will have a number of other questions to ask as he tests it.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 10, 2014 2:42 pm
Reply with quote

Akatsukami wrote:
And, yes, that code is not just not right, it's not even wrong. Presumably the TS will have a number of other questions to ask as he tests it.

jackzhang75, here are a few rules you should adopt before coming back with more questions:

1. Don't be lazy with variables names: To name the option field 'c' is bad. Later you will need a counter and you will call it 'c' as well, and you will end up with unreadable and undebuggable code.
How to give a long name to a 1 char field in the panel ?
Code:
)BODY
+Option:_Z+
)INIT
   .ZVARS = '(OPTION)'
As easy as that. There must be as many names in .ZVARS as you have Z's in the body.

2. Be consistent with names: if option is 1 you run rexx4, if option is 2 you run rexx1 ? Just add rexx2 for option 0 and you're all setup for a big mess.

3. Keep it simple: in 13 lines I do more than you do in 20 (although I didn't check my code)
Code:
uname=ARG(1)
Address ISPEXEC
Do Forever
   "DISPLAY PANEL(panel2)"
   If RC <> 0 Then Leave
   Select
      When Option = '0' Then Call Process_Opt_Defaults
      When Option = '1' Then Call Process_Opt_Prepare
      When Option = '2' Then Call Process_Opt_TSO
      Otherwise "SETMSG MSG(ISPP195)"
   End
End
Exit
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Thu Jul 10, 2014 4:12 pm
Reply with quote

Ooops, on my way back from lunch I just remembered I forgot this line:
Code:
      When Option = 'X' Then Leave
Why do I use LEAVE and not EXIT ?
Sometimes I do some stuff before and/or after the main process:
Code:
Call Prolog
Do Forever
   ...
End
Call Epilog
Exit
With LEAVE the "epilog" will be executed. Not with EXIT.
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Thu Jul 10, 2014 7:42 pm
Reply with quote

Firstly, i want to thanks you all to provided me really nice suggestion and solution.

Now i use MARSO solution , it works very well. I can press X and exit the progrom. To Marso , i not sure what's your first suggestion (code ) exactly means?

Code:
 )BODY
+Option:_Z+
)INIT
   .ZVARS = '(OPTION)'


Second question as Akatsukami said, i want to also press F3 to exit the progrom not just type X , how to make it ?
Code:
 uname=ARG(1)                     
 ADDRESS ISPEXEC                   
 DO FOREVER                       
 "DISPLAY PANEL (panel2)"         
   SELECT                         
     WHEN C='1' THEN REXX1()       
     WHEN C='2' THEN REXX2()       
     WHEN C='X' THEN LEAVE         
     OTHERWISE  SETMSG MSG(ISPP195)
   END                             
 END                               
 EXIT     


Thanks
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Thu Jul 10, 2014 7:50 pm
Reply with quote

Do not use FOREVER, but rather WHILE (RC¬=0). Also, I recommend that the DISPLAY service be invoked at the end of the DO loop, instead of at the beginning.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Thu Jul 10, 2014 11:10 pm
Reply with quote

Quote:
Do not use FOREVER, but rather WHILE (RC¬=0).


Based on the code in Jack's latest post, I think it should be: While (RC = 0).
rather than 'not equal'.
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Fri Jul 11, 2014 1:25 am
Reply with quote

hi , i got another question.
The same progrom , but i add another call for a function , it seems after running the funciton , the progrom just stop there not continue to display the panel , why? Thanks

MYARG=userid()
Code:
call [b]Function [/b]
 ADDRESS ISPEXEC                     
 DO FOREVER                         
 "DISPLAY PANEL (panel2)"           
   SELECT                           
     WHEN C ='1' THEN REXX1()       
     WHEN C ='2' THEN REXX2()       
     WHEN C ='X' THEN LEAVE         
     OTHERWISE  "SETMSG MSG(ISPP195)"
   END                               
 END                                 
 exit                               
Function :
XXXXXXXXXXXXXXXXX
Return  MYARG                             
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1787
Location: Bloomington, IL

PostPosted: Fri Jul 11, 2014 4:14 am
Reply with quote

You recognize that you should either invoke function as
Code:
variable = function()

or by
Code:
call function
variable = rc
?
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Fri Jul 11, 2014 7:54 pm
Reply with quote

Hi AKASTSUJAmi, Now i can call the function ,and the function working fine . My problem was after runing the function , the code seems not continue to next step and the progrom just exit with RC=0 .. I don't know what's wrong?
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Fri Jul 11, 2014 8:08 pm
Reply with quote

hi , i found the problem, something wrong in my function , I take off
ADDRESS ISPEXEC
"CONTROL ERRORS RETURN"
SIGNAL ON HALT
SIGNAL ON FAILURE
SIGNAL ON SYNTAX
ADDRESS TSO

in function , it works.. dont's know why
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Fri Jul 11, 2014 9:22 pm
Reply with quote

When you have this:
Code:
SIGNAL ON HALT
SIGNAL ON FAILURE
SIGNAL ON SYNTAX

You need to provide a subroutine called HALT, a subroutine called FAILURE, and a subroutine called SYNTAX.

My guess is that you have some kind of problem and rexx gives up because it cannot find the subroutine that you said you were going to provide. I am surprised there are no other messages.

The second line of your program should be:
Code:
TRACE('r')

And show us the trace.

note: the spelling is program, not progrom
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Jul 13, 2014 12:50 pm
Reply with quote

You must have something like this in your panel:
Code:
+Option:_C+
That is why you check for the value of 'C' in your rexx program.
If you want to give a better name to your variable, you have two options:
  1. just give a better name:
    Code:
    +Option:_Opt+
    but now the user can type up to 3 characters in the field. Sometimes it's not important, sometimes it is.
  2. Use .ZVARS:
    Code:
    +Option:_Z+
    followed by
    Code:
    )INIT
       .ZVARS = '(OPTION)'
    Each variable named 'Z' will be in fact named after what is found in the .ZVARS.
    That way, you keep the correct field length and you give a real name to the variable.

There is a better explanation and example here.
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 -> TSO/ISPF

 


Similar Topics
Topic Forum Replies
No new posts Preserve changes to ISPF Panel Variables TSO/ISPF 5
No new posts Inserting into table while open selec... DB2 1
No new posts Execute secondary panel of sdsf with ... CLIST & REXX 1
No new posts SCOPE PENDING option -check data DB2 2
No new posts OUTFIL with SAVE option DFSORT/ICETOOL 7
Search our Forums:

Back to Top