Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lab 5 Question #90

Closed
seahopki12 opened this issue Apr 28, 2020 · 3 comments
Closed

Lab 5 Question #90

seahopki12 opened this issue Apr 28, 2020 · 3 comments

Comments

@seahopki12
Copy link

I am a little confused on this lab. Although I was able to compile the CBL0007J file with no errors, I still don't understand why the original source code would not be able to compile without errors. The only thing I did to get a no-error compile was remove the END-IF terminator at the end of the paragraph in question. That being said, documentation says that IF statements are explicitly terminated by using END-IF. What am I missing here?

Many thanks.

@binary-sequence
Copy link
Contributor

binary-sequence commented Apr 28, 2020

Explicit means being verbose about something. Implicit means omitting something because that something is expected or obvious.

If you notice, there is an implicit termination

       IS-STATE-VIRGINIA.
           IF USA-STATE = 'Virginia' THEN
              ADD 1 TO VIRGINIA-CLIENTS. <---- here, the period
           END-IF.

But, the compiler doesn't know what you want to achieve. For the compiler the implicit termination is enough, so it complains that the it END-IF is not necessary.

There are two ways of resolving that compiler error:

  1. You decide to use the implicit terminator (period is a sentence terminator that implicitly terminates IF)
  2. You decide to use the explicit terminator (END-IF, so you should remove the period at the end of previous line). END-IF is an explicit terminator, but it is only valid with a period END-IF.

@seahopki12
Copy link
Author

Ah...Totally missed the period sign. That's exactly what I needed to know. Thanks!

@sccosel
Copy link
Contributor

sccosel commented Apr 28, 2020

@pineconeman09 - My advice, get rid of ALL unnecessary periods. They are just not necessary any more. And, more good advice for those starting out:

  1. There should only be 2 periods per paragraph, 1 at the end of the paragraph name, and 1 on a blank line of its own at the end of the paragraph.
  2. Always use GOBACK instead of STOP-RUN.
  3. No need to use PERFORM THRU or EXIT paragraphs.
  4. No need to use GOTOs. Use an IF statement and CONTINUE to check the (88-level) value of LASTREC to conditionally execute the PERFORM. Or, since you will only use 1 period within a paragraph, NEXT SENTENCE will take you to the end of the paragraph.
  5. A READ or WRITE paragraph should be limited to just a READ of a file or WRITE of a record. Optionally, one group MOVE statement. The purpose of this type of paragraph is to be versatile enough to be able to perform it multiple times from different parts/areas of your program.
  6. Never use NOT or only in very obvious, simple usage.

@paulnewt paulnewt closed this as completed May 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants