Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Length 1

Status
Not open for further replies.

poliv

Programmer
Jun 3, 2000
48
US
How can I get the field length, in Lyant RM/COBOL-85 ?
 
Poliv,

can you give some more information ? I'm not familiar with Lyant RM?COBOL-85, but as far as i know COBOL doesn't support variable length fields (indentifiers), so the number of bytes an identifier occupies can always be worked out by its definition / picture.
 
RonaldB,

I have a field defined like PIC X(8), and this field is the name of a file that I want to create in Unixware, with an extension (PIC X(4)) giving by the program.
The problem is that if the length of the file name is less than 8, then an error occur in the command line of the Unixware, because the command line is incorrect.
EXAMPLE:
File Name: XPTO
File Extention: .TXT
Command Line: cp XPTO .TXT

I want it to be:
File Name: XPTO
File Extention: .TXT
Command Line: cp XPTO.TXT
 
Poliv,
Use the string command to construct your command line:
file-name pic x(8).
file-exten pic x(4).
command-line pic x(80) value spaces.
string "cp " delimited by size, file-name delimited by " ",
"." delimited by size,
file-exten delimited by space into command-line.
Call "unix" using command-line.
(The 'delimited by" phrase stops the transfer of bytes into the receiving field.)
 
Hi,

in modern COBOL there is the option

MOVE LENGTH OF <variable-name> TO <numeric-identifier>

Working with variable fields is also possible:

01 VARIABLE-FIELD.
03 FILLER OCCURS 1 TO 256 DEPENDING ON LENGTH-OF-VF
PIC X.
01 LENGTH-OF-VF PIC S9(4) COMP.

By changing the value of LENGTH-OF-VF you can change the length of VARIABLE-FIELD.

Let us know if this answer helps.
 
mrregan,
I already test your solution, and it works.
It was exactly what I want

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top