View previous topic :: View next topic |
Author |
Message |
prasad_kdd Beginner
Joined: 22 Aug 2005 Posts: 6 Topics: 4 Location: hyderabad
|
Posted: Wed Oct 05, 2005 10:49 pm Post subject: what are the advantages of initializing variables wit value |
|
|
hi,
i would like to know what are the advantages and disadvantages of setting variable values in the working storage section with 'value clause' and initializing them in the procedure division.
which one is more efficient and also could you please provide me any link which helps this topic.
Thanks,
prasad.P _________________ prasad.Polisetti |
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Wed Oct 05, 2005 11:03 pm Post subject: |
|
|
I don't think it will affect efficiency. If you don't initialize then also it will be set some default values, say low values. |
|
Back to top |
|
 |
prasad_kdd Beginner
Joined: 22 Aug 2005 Posts: 6 Topics: 4 Location: hyderabad
|
Posted: Wed Oct 05, 2005 11:59 pm Post subject: |
|
|
hi ,
thanks for the reply but i would like to know the advantages and disadvantages also .can u please provide me any link or tutorial that would help me out. _________________ prasad.Polisetti |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Oct 06, 2005 3:06 am Post subject: |
|
|
Prasad,
I just consider that as a feature provided to the developer - to save his time in moving the values individually in the Procedure division - increasing the number of lines !!!.
As far as efficiency is considered, there will not be any difference b/w Value Clause and moving values, since anyway your program is going to do an internal move when it encounters the VALUE Clause.
Thanks,
Phantom |
|
Back to top |
|
 |
prasad_kdd Beginner
Joined: 22 Aug 2005 Posts: 6 Topics: 4 Location: hyderabad
|
Posted: Thu Oct 06, 2005 3:55 am Post subject: |
|
|
hi phantom,
thanx for the reply.But i would like to know that will there be any advantages in using the valus clause with cobol sub routines.And also i have seen in one book with program-id in the identification division we can give the 'initial' and 'common' option.could you pls explain me how this one will affect the performance of the progarm.
thanks
prasad.P _________________ prasad.Polisetti |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Thu Oct 06, 2005 4:45 am Post subject: |
|
|
Prasad kdd,
I think you are referring to this:
Quote: |
Setting a program to an initial state
Use the INITIAL attribute to specify that whenever a program is called, it is placed
in its initial state. If the program contains programs, these are also placed in their
initial states.
A program is in its initial state when the following has occurred:
v Data items having VALUE clauses are set to the specified value.
v Changed GO TO statements and PERFORM statements are set to their initial states.
v Non-EXTERNAL files are closed.
|
When you use VALUE Clause in these type of situations where the sub-program is set to its INITIAL state, the data items will be initialized to the specified value.
If a field does not have any VALUE clause then its contents are flushed and may have junk/low-values. So, the developer must take care to load proper values to these fields so that he doesn't end up in data Exception.
Kolusu, Do you think of any other case ?
Thanks,
Phantom |
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Oct 06, 2005 6:44 am Post subject: |
|
|
One initialize statement can do equivalent of 10 to 50 lines of codes.
I will say initializing makes life simple, both in developing and maintaining the code.
Also, I don't see any disadvantage. |
|
Back to top |
|
 |
|
|