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

How to make a variable as constant


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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
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
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts trying to make sense of keylists TSO/ISPF 11
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top