Information Technology Reference
In-Depth Information
print-year ,
all based on the current date. If you move down to the line
work-date = date
you will see how this will be accomplished. This line has another keyword
date
which represents today's date in the format yyyymmdd. Thus if today is September 10,
2001, the field
date
will have the value
20010910.
Note that not only do we not have to define this variable, we actually couldn't if we tried.
What this statement does is assign the variable
work-date ,
which we have defined as
character (8)
the value of the field
date .
This is done by the equal sign, which takes whatever is on the right side (today's date in
this case) and moves it to the field on the left side. Note that when this move is done, both
fields will have a value of
20010910.
It's more like a copy than a move. You have seen the equal sign before but there it was
used as a logical operator in conjunction with the
if .
In this line and a few others in the program, this symbol is used as an assignment operator
as it gives a field a value. We have another assignment in the line
print-month = work-date (5:2)
which moves the two characters in work-date starting in the fifth position to
print-month .
This is
09,
which happens to be the month. You can then see that
work-date (7:2)
turns out to be the two characters in
work-date
starting in position 7, which are
10,
which is the day. The statement after that takes two characters starting at position 3 or
01,
which is the last two digits of the year. So the four statements of our program after the
last define statement get today's date and format the date on the main heading line as
09/10/01.
Tomorrow it will be
09/11/01,
Search WWH ::




Custom Search