View previous topic :: View next topic
|
Author |
Message |
jrlsage
New User
Joined: 11 Oct 2012 Posts: 5 Location: USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10891 Location: italy
|
|
|
|
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 |
|
|
jrlsage
New User
Joined: 11 Oct 2012 Posts: 5 Location: USA
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10891 Location: italy
|
|
|
|
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 |
|
|
jrlsage
New User
Joined: 11 Oct 2012 Posts: 5 Location: USA
|
|
|
|
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 |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2598 Location: Silicon Valley
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10891 Location: italy
|
|
|
|
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 |
|
|
jrlsage
New User
Joined: 11 Oct 2012 Posts: 5 Location: USA
|
|
|
|
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. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
jrlsage
New User
Joined: 11 Oct 2012 Posts: 5 Location: USA
|
|
|
|
Oh yeah, the post pointed me to that and a bunch of manuals to help me on my quest.
Thanks |
|
Back to top |
|
|
|