View previous topic :: View next topic |
Author |
Message |
[bond] Beginner

Joined: 31 Dec 2002 Posts: 28 Topics: 6
|
Posted: Wed Mar 05, 2003 9:54 am Post subject: Dummy variable in COBOL |
|
|
Code: | DIVIDE a BY b GIVING c REMAINDER d |
I have 'a', 'b' and 'd' already declared in the program. However, I do not need 'c' anywhere in the program. So, do I have to declare 'c' in working-storage just for the DIVIDE clause ? Is there a concept of a dummy variable in COBOL ?
Apparently, the program does a lot of calculations and this was just one example. I'l have to declare a lot of variables otherwise !
thanks _________________ “In war, resolution; in defeat, defiance; in victory, magnanimity” ~ Winston Churchill |
|
Back to top |
|
 |
[bond] Beginner

Joined: 31 Dec 2002 Posts: 28 Topics: 6
|
Posted: Wed Mar 05, 2003 11:32 am Post subject: |
|
|
Mod, pls delete this thread.
thanks _________________ “In war, resolution; in defeat, defiance; in victory, magnanimity” ~ Winston Churchill |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12377 Topics: 75 Location: San Jose
|
Posted: Wed Mar 05, 2003 12:00 pm Post subject: |
|
|
Bond,
I don't know why you have decided to delete this topic but I think it is a good question.
Since you are interested in only the remainder portion from the division , you can use the numeric intrinsic function REM . This will avoid the declaration of variable C.
Code: |
DIVIDE a BY b GIVING c REMAINDER d
|
The same thing can be done as follows:
Code: |
COMPUTE D = FUNCTION REM(A B)
|
In the above case the variable D will have the remainder when A is divided by B.
Hope this helps...
cheers
kolusu |
|
Back to top |
|
 |
slade Intermediate
Joined: 07 Feb 2003 Posts: 266 Topics: 1 Location: Edison, NJ USA
|
Posted: Wed Mar 05, 2003 1:43 pm Post subject: |
|
|
Hi Bond,
To avoid declaring clones of "c" (e.g. c1, c2, etc.) for each computation, you could re-use "c" each time. It will be overlaid with each use.
Jack |
|
Back to top |
|
 |
[bond] Beginner

Joined: 31 Dec 2002 Posts: 28 Topics: 6
|
Posted: Wed Mar 05, 2003 1:45 pm Post subject: |
|
|
wow ! thanks for that piece of info, kolusu. I thought that the question was too basic to ask over here (on second thoughts maybe it is ). _________________ “In war, resolution; in defeat, defiance; in victory, magnanimity” ~ Winston Churchill |
|
Back to top |
|
 |
|
|