View previous topic :: View next topic
|
Author |
Message |
techslam
New User
Joined: 03 Dec 2010 Posts: 87 Location: India
|
|
|
|
Hi
Let's say I have following variable names :
Code: |
VARIABLE-1,
VARIABLE-2,
VARIABLE-3,
VARIABLE-4
|
Now within the COBOL program I want to do something like this :
A variable 'X' is defined with value equal to 1
And,
I perform this :
Code: |
MOVE VARIABLE-X = TEMP-VAR
|
Here X must be replaced with the value of X(that is, 1), so that value of VARIABLE-1 will be moved to TEMP-VAR.
Then I will increment the value of X by 1 and continue.
Can this be achieved using COBOL ?
Please guide me.
Any help is highly appreciated. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
First, look up the MOVE statement in the Cobol manual (see link at the top). Then look up OCCURS, subscripts and indexes. If you get stuck, there is a begginers forum available. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
Can this be achieved using COBOL ?
Please guide me.
Any help is highly appreciated. |
NO! ( not at least the way You asked )
unless ( I do not speak cobolese ) You can redefine the variables over an array
so that VAR1 corresponds to ARRAY(1)
VAR2 to ARRAY(2) and so on
at this point when You assign something to ARRAY(i) the You can also retrieve the value using VARi
but the whole thing does not make much sense. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
You need to learn that COBOL is a compiled language. As such, all variable references are fixed at compile time. There is no way, at run time, to modify COBOL code that has been compiled. You can use arrays as suggested by others to accomplish something similar to what you ask, but the direct answer to your question is that no, once the program has been compiled there is no way to change any source statements in any way, shape, style, or form. |
|
Back to top |
|
|
|