For Programmers: Free Programming Magazines  


Home > Archive > Cobol > October 2007 > Use a string to access a variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Use a string to access a variable
moonman

2007-10-12, 6:23 am

Hello everyone

I'm a total newbie in Cobol.

I have a case that I'm trying to figure out, and was wondering if someone out there had some info for me if it was a total bullshit trying that in Cobol.

I have number of variables that all have the same name except for a numerator in the end of the var name. And I wanted to see if it was possible to generate string in a "for" loop and use that string to access a variable that has the same name as the string I generate.

example...

if I have those variables...

01 VAR-1 PIC X(6).
01 VAR-2 PIC X(6).
01 VAR-3 PIC X(6).

then I whould like to something like this...

PERFORM TEST AFTER VARYING counter FROM
1 BY 1 UNTIL counter = 3

* generate string from a string prefix and a numb postfix
string 'VAR-' counter

* and then use this string to set something in the
* VAR-1, VAR-2 and VAR-3

END-PERFORM.

Hope someone understands my problem and hope even more someone knows how to end my missery :-)

Best regards
D.Moon
moonman

2007-10-22, 8:59 am

Anyone know if this is possible ??
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com