wickedhasem.blogg.se

Cobol file read
Cobol file read







  1. #Cobol file read windows 10
  2. #Cobol file read Pc

Change the file definition to BINARY SEQUENTIAL with record size of pic x(01).

cobol file read cobol file read

This would let you count the bytes as they go by. It did exactly as we had hoped and we eventually released it as an end user utillity.īased on this, you COULD just tell the file it has 1 byte records and read each byte as a binary sequential.

#Cobol file read Pc

My first exposure to MFCobol had users ending up with corrupt files all the time and we needed a way to know what was wrong quickly, so I leveraged this fact and basically parsed the files looking for certain features, such as a x'0A' (UNIX) or a CR/LF which would tell us that someone FTP'd a file from PC to LINUX using binary transfer. Wonderful thing about cobol on unix/linux/pcs is for the most part they do not check the file structure they assume you were bright enough to tell the program what the file was, and in the case of a complicated file such as a an MFCobol B-Tree index embedded in the file, the file header will do the rest. Just in case you still don't know how many bytes you have, try this:

#Cobol file read windows 10

I'm running MicroFocus ACUCOBOL-GT on Windows 10 myself. I guess this will be time-consuming when the number of lines is large, but at least you got your line lengths.Īs Bill Woodger already mentioned, since you didn't provide additional details, I had to make some assumptions. SOME-COUNTER will contain the line length, assuming no NUL values are present in the file. IF NOT (YOUR-RECORD(SOME-COUNTER : 1) = LOW-VALUES) PERFORM VARYING SOME-COUNTER FROM 72 BY -1 UNTIL (SOME-COUNTER < 0) When the number of bytes read is smaller than the record size, the bytes at the end of the record are left unchanged. Then read the next record that will move the number of bytes read to the record. However, you can calculate the number of bytes read by counting the number of characters written to the record.įirst, initialize the file record to LOW-VALUES. Apparently, bytes are instantly stored into a record described by a file descriptor in your FILE SECTION. I don't know exactly which vendors support it (possibly almost all), but at least it works with ACUCOBOL.Īs far as I know, there is no feedback on the number of bytes read by the execution of the READ statement.

cobol file read

Now for each read, the record length is stored into SOME-LINE-LENGTH: READ SOME-FILE NEXT RECORD RECORD VARYING 40 TO 80 DEPENDING ON SOME-LINE-LENGTH. As mentioned in the comments, it actually is possible to get the number of characters (bytes) read, indeed with the RECORD VARYING DEPENDING ON clause: ENVIRONMENT DIVISION.









Cobol file read