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

REXX Function: Output coming out when Function is done.


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

New User


Joined: 11 Oct 2012
Posts: 5
Location: USA

PostPosted: Fri Oct 12, 2012 2:32 am
Reply with quote

Code:

/* REXX */                                                     
/* trace i  */                       
/*                                                             


TICKETNUMBER=TICKET_NUMBER()                                     
SAY TICKETNUMBER                                                 
exit                                                             
                                                                 
TICKET_NUMBER:                                                   
     TICKET_LENGTH_CHECK= 0                                     
    SAY "What is the ticket number?"                             
  PULL TICKET_ENTRY_NUMBER                                       
     TICKET_NUMBER_CHECK=DATATYPE(TICKET_ENTRY_NUMBER,'N')       
     if TICKET_NUMBER_CHECK == 1 then do                         
       if WORDLENGTH(TICKET_ENTRY_NUMBER,1) = 1                 
       then TICKET_LENGTH_CHECK= 1                               
       if TICKET_NUMBER_CHECK =¬1 && TICKET_LENGTH_CHECK =¬1,   
       then                                                     
          do                                                     
          TICKETNUMBER=TICKET_NUMBER(TICKET_ENTRY_NUMBER)       
              return TICKET_ENTRY_NUMBER                         
          end                                                   
       else                                                     
          do                                                     
              return TICKET_ENTRY_NUMBER                         
          end                                                   
      end                                                       
     else RETURN DATACHECK_ERROR(NUMBERS TICKET_NUMBER())       
                                                                 
QUIT:                                                           
                                                                 
  say "CRITICAL ERROR -> Press Q to quit immediately or"         
  say "press any key to restart function"                       
    pull ERR_SEL                                                 
      if ERR_SEL = Q then exit                                   
     else return 0                                               

 DATACHECK_ERROR:                                                     
                                                                     
   PARSE ARG DATATYPE FUNCTION_NAME                                   
     SAY "You used the wrong DATATYPE, please enter" DATATYPE         
   RETURN FUNCTION_NAME                                               
                                                                     
 ERROR_CHECK:                                                         
                                                                     
   PARSE ARG myarg section part                                       
                                                                     
   if section = 1 then                                               
     do                                                               
      CALL QUIT                                                       
     end                                                             
   if part = 1 then say "You entered in a non number "               
     SAY "ERROR in" myarg "function. Returning you to that function" 
   RETURN TICKET_NUMBER()                                             


I am building this code to automate some things I have to do.

My problem is when I a user issues the wrong datatype, I have the code go into the DATACHECK ERROR Function. I get no output as it returns back into the main function. once the user enters in the correct datatype and the code finishes, all the Say's come out at the end of the program.
i.e

Quote:
What is the ticket number? e

What is the ticket number? e

What is the ticket number? e

What is the ticket number? e

What is the ticket number? 2

You used the wrong DATATYPE, please enter NUMBERS
You used the wrong DATATYPE, please enter NUMBERS
You used the wrong DATATYPE, please enter NUMBERS
You used the wrong DATATYPE, please enter NUMBERS
2




I would like to have the say come out as soon as the user goes into the function.

Any idea?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Oct 12, 2012 3:44 am
Reply with quote

don' t You feel thatYou made things a bit too complicated ?
why call ticket_number recursively ?
that' s the reason for the message delay

describe the requirement, looks that the code can be made much more simple

here is a snippet which will ask for a <ticket number>
letting the user attempt five time

Code:
TICKETNUMBER=TICKET_NUMBER()
SAY TICKETNUMBER
exit

TICKET_NUMBER: procedure
    text = "What is the ticket number?"
    say text
    text = "wrong input - What is the ticket number?"
    pull numb
    do  i = 1 to 5 while ( length(numb) \= 1 | datatype(numb) \= "NUM" )
        say text
        PULL numb
    end
    if  i > 5 then do
        say "too many attempts"
        exit
    end
    return numb
Back to top
View user's profile Send private message
jrlsage

New User


Joined: 11 Oct 2012
Posts: 5
Location: USA

PostPosted: Fri Oct 12, 2012 8:35 pm
Reply with quote

Thanks for the quick reply:


I am using this EXEC to build Ticket information for our auditors, something to make our programmers work a little faster.

The requirements of this program (eventually) will be building all the information for these tickets, organize the information, and then using JCL to email the results to the programmer for simple copy and paste.

---------------------

I wanted to see if I could get the error detection outside the function to use in any other function I create in this EXEC, sort of a one stop shop.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Fri Oct 12, 2012 9:21 pm
Reply with quote

did anybody consider that using line mode input and output is NOT user friendly
and is quite outdated as interface ?

did anybody consider using ISPF panels for data entry and navigation?

when using ISPF panels simple validations can be done in the panel itself
the script will get control back only with valid data

furthermore ALL the needed data can be collected by a SINGLE panel and a single user interaction
Back to top
View user's profile Send private message
jrlsage

New User


Joined: 11 Oct 2012
Posts: 5
Location: USA

PostPosted: Fri Oct 12, 2012 11:35 pm
Reply with quote

So ISPF Panels are the way to go here?


Also, looking at this by a REXX perspective. Would pushing and pulling the output work?

Just curious.
Back to top
View user's profile Send private message
Pedro

Global Moderator


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

PostPosted: Fri Oct 12, 2012 11:51 pm
Reply with quote

Quote:
So ISPF Panels are the way to go here?

Yes

Quote:
Would pushing and pulling the output work?

It is not clear what you mean.

What happened when you tried it?
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Sat Oct 13, 2012 12:01 am
Reply with quote

why push/pull

ISPF / REXX interface takes care of all the variable handling

suppose that You have a REXX variable named VAR1

when a panel is displayed , if it contains an output field named VAR1, the variable content will be displayed

if the panel contains an input field named VAR2
when Rexx will be back in control the REXX variable VAR2 will contain the data typed in by the user
Back to top
View user's profile Send private message
jrlsage

New User


Joined: 11 Oct 2012
Posts: 5
Location: USA

PostPosted: Fri Oct 19, 2012 1:42 am
Reply with quote

Thanks -

I saw a forum post on how to build panels.

Ill proceed with that.

I appreciate the effort to putting me on the right path. icon_smile.gif
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Oct 19, 2012 2:58 am
Reply with quote

D o not use a forum post to educate yourself in writng ISPF panels - use the Dialog Developer's Guide and Reference (SC34-4821-09)
Back to top
View user's profile Send private message
jrlsage

New User


Joined: 11 Oct 2012
Posts: 5
Location: USA

PostPosted: Fri Oct 19, 2012 9:10 pm
Reply with quote

Oh yeah, the post pointed me to that and a bunch of manuals to help me on my quest.

Thanks icon_cool.gif
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 Compile Several JCL JOB Through one r... CLIST & REXX 4
No new posts Running REXX through JOB CLIST & REXX 13
No new posts Error to read log with rexx CLIST & REXX 11
No new posts isfline didnt work in rexx at z/OS ve... CLIST & REXX 7
No new posts run rexx code with jcl CLIST & REXX 15
Search our Forums:

Back to Top