MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Dummy variable in COBOL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
[bond]
Beginner


Joined: 31 Dec 2002
Posts: 28
Topics: 6

PostPosted: Wed Mar 05, 2003 9:54 am    Post subject: Dummy variable in COBOL Reply with quote

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
View user's profile Send private message
[bond]
Beginner


Joined: 31 Dec 2002
Posts: 28
Topics: 6

PostPosted: Wed Mar 05, 2003 11:32 am    Post subject: Reply with quote

Mod, pls delete this thread.

thanks
_________________
“In war, resolution; in defeat, defiance; in victory, magnanimity” ~ Winston Churchill
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12358
Topics: 75
Location: San Jose

PostPosted: Wed Mar 05, 2003 12:00 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
slade
Intermediate


Joined: 07 Feb 2003
Posts: 266
Topics: 1
Location: Edison, NJ USA

PostPosted: Wed Mar 05, 2003 1:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
[bond]
Beginner


Joined: 31 Dec 2002
Posts: 28
Topics: 6

PostPosted: Wed Mar 05, 2003 1:45 pm    Post subject: Reply with quote

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 Smile).
_________________
“In war, resolution; in defeat, defiance; in victory, magnanimity” ~ Winston Churchill
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group