我正在编写虚拟时间机器我想回到评估一年的开始,但是使用自由格式时,我不能只说“ GO TO MAIN”我基本上希望程序说:您是否要评估其他年份?”如果是,请转到“主要”(没有,因为要写长文本,我使用自由格式)如果没有停止运行。
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.
您有什么想法吗?非常感谢:)
自由格式参考格式没有删除段落或GO TO
,因此您可以简单地添加这些段落就可以了。但我建议您有一个主要的逻辑,包括将循环作为循环并在某种情况下对代码进行结构化,在这种情况下:
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.