I am making a simple appointment program and I want to have a back function that allows the user to return back to the previous line. For example, the user typed in the wrong year and wanted to change it so they would need to have a back button to type it again. I was wondering if this can be accomplished by an IF-ELSE statement, but maybe there are other ways to accomplish this? Below is a part of the program.
MakeAppointment.
DISPLAY " "
DISPLAY "Year: "
ACCEPT YEAR
DISPLAY "Month: "
ACCEPT MONTH
DISPLAY "Day: "
ACCEPT DAYS
DISPLAY "NAME: "
ACCEPT NAME-CAP
MOVE FUNCTION UPPER-CASE(NAME-CAP) TO P-NAME
DISPLAY "CONTACT NUMBER: "
ACCEPT P-CONTACT
WRITE AppointmentRec
INVALID KEY DISPLAY "THIS SLOT IS NOT AVAILABLE."
END-WRITE.
EDIT: Sorry if my question wasn't clear, I want the program to do is to go back to DISPLAY "Year: "
from ACCEPT MONTH
if the user was not satisfied with the year that they have typed. Though I already had an
IF YEAR='B'EXIT PARAGRAPH
but the program messes up during the ACCEPT NAME-CAP
because I really need the name to always be capitalized. The date and contact are initialized as PIC X(). I'll also try and study Screen section and see if I can do it.
EDIT: New version of program
MakeAppointment.
DISPLAY " "
DISPLAY "Year: "
ACCEPT YEAR
IF YEAR='B'
EXIT PARAGRAPH
ELSE
DISPLAY "Month: "
ACCEPT MONTH
IF MONTH='B'
EXIT PARAGRAPH
ELSE
DISPLAY "Day: "
ACCEPT DAYS
IF DAYS='B'
EXIT PARAGRAPH
ELSE
DISPLAY "NAME: "
ACCEPT NAME-CAP
IF NAME-CAP='B'
EXIT PARAGRAPH
ELSE
MOVE FUNCTION UPPER-CASE(NAME-CAP) TO P-NAME
DISPLAY "CONTACT NUMBER: "
ACCEPT P-CONTACT
IF P-CONTACT='B'
EXIT PARAGRAPH
ELSE
WRITE AppointmentRec
INVALID KEY DISPLAY "THIS SLOT IS NOT AVAILABLE."
END-WRITE
END-IF
END-IF.