IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

What is SET TO TRUE all about, anyway?


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Thu Dec 15, 2005 11:03 pm
Reply with quote

hi, friends,
plz send me the answer of the ques.
what is SET TO TRUE all about?


thanks in advance
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Dec 16, 2005 1:22 am
Reply with quote

Hi mijanurit,

The set to true is used with the use of level 88. see code below.

Code:


    05  ws-honor-student-sw     pic x    value 'N'
         88 honor-student                      value 'Y'


    if student-gpa > 3.5
    then
        set honor-student           to true
    end-if

is the same as

    if student-gpa > 3.5
    then
        set ws-honor-student-sw           to "Y"
    end-if



either way, ws-honor-student-sw value is 'Y'


Now you can code
Code:

   if honor-student
   then
       :
   end-if.

or

  if not honor-student
  then
      :
  end-if

instead of coding
  if ws-honor-student-sw = 'Y'
  then
     :
  end-if



One thing you must know about 88 level. your cannot say 'set to false'


If you have furthure questions, please let us know icon_smile.gif






[/code]
Back to top
View user's profile Send private message
iknow

Active User


Joined: 22 Aug 2005
Posts: 411
Location: Colarado, US

PostPosted: Fri Dec 16, 2005 7:16 am
Reply with quote

Hi mijanurit,

Check the answers for your query,

The SET verb is used for a number of unrelated functions in COBOL, so instead of dealing with it as a single topic, we will deal each format as we examine the construct to which it is most closely related.


Quote:
SET {ConditionName} ... TO TRUE



A Condition Name set to true when one of the condition values mentioned in its VALUE clause is moved into its associated data-item. But you can also set a Condition Name to true using the SET verb.

When the SET verb is used to set a Condition Name, the first condition value specified after the VALUE clause in the definition is moved to the associated data-item. Thus, the value of the associated data-item is changed.

So, any operation which changes the value of the data-item may change the status of the associated Condition Names, and any operation which changes the status of a Condition Name may change the value of its associated data-item.

It is not (at present) possible to set a condition name to False.

Using the SET verb with Sequential Files

The SET verb is most often used to set an end of file Condition Name when reading Sequential Files. The animation below demonstrates how to set up and use an end of file Condition Name.


Code:
DATA DIVISION.
FILE SECTION.
FD StudentFile.
01 StudentDetails.
   88  EndOfStudentFile  VALUE HIGH-VALUES.
   02  StudentId       PIC 9(7).
   02  StudentName.
       03 Surname      PIC X(8).
       03 Initials     PIC XX.
   02  DateOfBirth.
       03 YOBirth      PIC 9(4).
       03 MOBirth      PIC 9(2).
       03 DOBirth      PIC 9(2).
   02  CourseCode      PIC X(4).
   02  Gender          PIC X.

   .
   .
   .
     
PROCEDURE DIVISION.
Begin.
   OPEN INPUT StudentFile
   READ StudentFile
      AT END SET EndOfStudentFile TO TRUE
   END-READ
   PERFORM UNTIL EndOfStudentFile
      DISPLAY StudentId SPACE StudentName SPACE CourseCode
      READ StudentFile
         AT END SET EndOfStudentFile TO TRUE
      END-READ
   END-PERFORM
   CLOSE StudentFile
   STOP RUN.




In this example, the EndOfStudentFile Condition Name is attached to the StudentDetails record. When EndOfStudentFile is set to true, every character of the record is filled with HIGH-VALUES (the highest ASCII value the character can hold).


More examples

Example1:

The following declares a condition name, EOF-FLAG:

Quote:
01 READ-FLAG PIC 9.
88 EOF-FLAG VALUE 1.


The following SET statement uses the condition name EOF-FLAG:

Quote:
SET EOF-FLAG TO TRUE.


The SET statement above is equivalent to the following MOVE statement:

Quote:
MOVE 1 TO READ-FLAG
.




Example2:

You cannot set a condition name to FALSE, but you can define two
condition names, one for the true case and one for the false case. The
following example illustrates this:

Quote:
01 FIRST-TIME-FLAG PIC X VALUE "Y".
88 FIRST-TIME VALUE "Y".
88 FIRST-TIME-OFF VALUE "N".


The following example uses the SET statement on both condition names:

Quote:
IF FIRST-TIME
PERFORM INIT-SECTION
SET FIRST-TIME-OFF TO TRUE
END-IF



NOTE

In COBOL II the 88 levels can be set rather than moving their associated values to the related data item. (Web note: This change is not one of COBOL II's better specifications.)
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Reporting true size of dataset on tape JCL & VSAM 7
No new posts Evaluate true also true COBOL Programming 6
No new posts TRUE exit to a trigger a Job from CICS CICS 7
No new posts Which of the following is true in COBOL Mainframe Interview Questions 1
Search our Forums:

Back to Top