Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to make a variable as constant

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
vin12pr
Warnings : 1

New User


Joined: 14 Jun 2006
Posts: 56

PostPosted: Tue Feb 20, 2007 5:30 pm    Post subject: How to make a variable as constant
Reply with quote

Here is a scnerio...

I would set a value for a variable and i would like to keep that value through out the program.Even thouigh If i attempt to modify the value.The default value should not change.

For Ex: If i have set variable A to 6 ,it should remain 6 through out the program.Even if an attempt is made to modify the value(Lets say to 7) in the program,It should not change.


Is there any way to do this?

Thnx in advance!
Back to top
View user's profile Send private message

prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Tue Feb 20, 2007 5:37 pm    Post subject:
Reply with quote

Vin12,
unless an untill u change the value in the variable the value would not change icon_biggrin.gif u did not xpect this answer rite....

K assign the same value to an other variable(var2) and at the end re-assign the var2 to vaiable 1, this is a simple way of doin it.


Thamilzan.
Back to top
View user's profile Send private message
arindam111

New User


Joined: 29 Nov 2006
Posts: 27
Location: India

PostPosted: Tue Feb 20, 2007 6:00 pm    Post subject:
Reply with quote

ohh! COBOL doesn't support STATIC icon_sad.gif icon_sad.gif like in Java/C# icon_neutral.gif
Back to top
View user's profile Send private message
IQofaGerbil

Active User


Joined: 05 May 2006
Posts: 183
Location: Scotland

PostPosted: Tue Feb 20, 2007 9:46 pm    Post subject: Re: How to make a variable as constant
Reply with quote

If you don't want to modify the value then design your program such that you don't code a modify, is that too difficult or am I missing something?
Back to top
View user's profile Send private message
vin12pr
Warnings : 1

New User


Joined: 14 Jun 2006
Posts: 56

PostPosted: Wed Feb 21, 2007 1:03 pm    Post subject: Re: How to make a variable as constant
Reply with quote

Please consider the same case for a online program.....


Thanks,
Vinay
Back to top
View user's profile Send private message
smiley
Warnings : 1

New User


Joined: 08 Feb 2006
Posts: 27

PostPosted: Wed Feb 21, 2007 1:12 pm    Post subject:
Reply with quote

online cics program?? dont allow user to enter values to this field..keep that field protected.
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Wed Feb 21, 2007 2:20 pm    Post subject:
Reply with quote

Vinay,
As i told u b4 y dont u assign the value to an other variable and not tamper the same at at the end move the value of variable 2 to vaiable 1 it works with online also



Thamilzan.
Back to top
View user's profile Send private message
krishna_sureka

New User


Joined: 05 Sep 2006
Posts: 7
Location: Pune

PostPosted: Wed Feb 21, 2007 3:19 pm    Post subject:
Reply with quote

COBOL don't support startic/constant. So you hvae to use the workround with two variables as explained by prav_06 or USE FILLER. Using filler, will make sure that value will not get changed atleast by INITIALIZE.
But if you specifically try to change the value, It can get changed.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Moving values to a variable of copybo... Vignesh Sid COBOL Programming 6 Wed Sep 06, 2017 1:04 pm
No new posts Updating the Trailer count in variabl... satheshbabur DFSORT/ICETOOL 6 Wed Aug 30, 2017 9:49 pm
No new posts Move from Comp3 variable to Edited Va... sreekusr COBOL Programming 8 Thu Aug 10, 2017 4:20 pm
No new posts Can I traverse a STEM variable? chong.zhou CLIST & REXX 5 Wed May 31, 2017 3:54 pm
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us