I'm writing a Virtual Time Machine I want to go back to the beginning when a year is evaluated, but with free format I can't just say "GO TO MAIN" I basically want the program say: do you want to evaluate other years?" IF yes GO TO "MAIN" (that there isn't, because for writing long text I use free format) IF NO stop run.
ACCEPT INPUT1
IF INPUT1 = 1900
DISPLAY"London reaches 4,300,000 inhabitants"
DISPLAY"Paris reaches 2,000,000 inhabitants"
DISPLAY"From 14 May to 28 October, the 2nd Olympics will take place in Paris."
DISPLAY"In Great Britain, on 28 February, the Labour representation committee was founded, under the leadership of Ramsay McDonald (1866-1937), which united, within the new party, associations and unions of socialist orientation."
DISPLAY"Bernhard von Bülow succeeded the Prince of Hohenlohe, Chlodwig, as the new Chancellor of the German Reich (1900 - 1909)."
DISPLAY"The American Schools of Oriental Research is founded."
END-IF
DISPLAY "Do you want to analyze the events of other years??"
ACCEPT Q
IF Q = "Y" OR "YES" OR "y" OR "yes" OR "Yes" GO TO
ELSE DISPLAY "OK, GOOD JOB :)"
DISPLAY "I EXIT IN 3 SECONDS..."
CALL "CBL_OC_NANOSLEEP" USING "1000000000"
END-CALL
DISPLAY "I EXIT IN 2 SECONDS.."
CALL "CBL_OC_NANOSLEEP" USING "1000000000"
END-CALL
DISPLAY "I EXIT IN 1 SECOND."
CALL "CBL_OC_NANOSLEEP" USING "300000000"
END-CALL
STOP RUN.
Have you any ideas? Thanks a lot:)
Free-form reference-format did not drop paragraphs or GO TO
, therefore you could simply add those and are fine.
But I'd suggest to have a main logic including the loop as a loop and structure the code a bit, in this case:
MAIN SECTION.
PERFORM TIME-MACHINE UNTIL NOT (Q = "Y" OR "YES")
PERFORM ENDING-CINEMA
GOBACK.
*>
TIME-MACHINE SECTION.
ACCEPT INPUT1
IF INPUT1 = 1900
DISPLAY"London reaches 4,300,000 inhabitants"
DISPLAY"Paris reaches 2,000,000 inhabitants"
DISPLAY"From 14 May to 28 October, the 2nd Olympics will take place in Paris."
DISPLAY"In Great Britain, on 28 February, the Labour representation committee was founded, under the leadership of Ramsay McDonald (1866-1937), which united, within the new party, associations and unions of socialist orientation."
DISPLAY"Bernhard von Bülow succeeded the Prince of Hohenlohe, Chlodwig, as the new Chancellor of the German Reich (1900 - 1909)."
DISPLAY"The American Schools of Oriental Research is founded."
END-IF
DISPLAY "Do you want to analyze the events of other years??"
ACCEPT Q
INSPECT Q (1:3) CONVERTING "yes" to "YES"
CONTINUE.
*>
ENDING-CINEMA SECTION.
DISPLAY "OK, GOOD JOB :)"
DISPLAY "I EXIT IN 3 SECONDS..."
CONTINUE AFTER 1 SECOND *> for "old" GnuCOBOL use a call to "C$SLEEP" USING "1"
DISPLAY "I EXIT IN 2 SECONDS.."
CONTINUE AFTER 1 SECOND
DISPLAY "I EXIT IN 1 SECOND."
CONTINUE AFTER 1 SECOND
CONTINUE.