I am trying to convert a .png file into binary code in Visual COBOL. Here is what I have
IDENTIFICATION DIVISION.
PROGRAM-ID. ImageToBinary.
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT IMAGE-FILE ASSIGN TO 'image.jpg'
ORGANIZATION IS LINE SEQUENTIAL.
DATA DIVISION.
FILE SECTION.
FD IMAGE-FILE.
01 IMAGE-RECORD PIC X(1024).
WORKING-STORAGE SECTION.
01 WS-END-OF-FILE PIC X(1) VALUE 'N'.
01 WS-BINARY-DATA PIC X(1024).
01 WS-IMAGE-BUFFER PIC X(1024) OCCURS 100 TIMES.
01 WS-BUFFER-INDEX PIC 9(4) VALUE 1.
01 WS-IMAGE-SIZE PIC 9(9) VALUE 0.
PROCEDURE DIVISION.
BEGIN.
OPEN INPUT IMAGE-FILE.
PERFORM UNTIL WS-END-OF-FILE = 'Y'
READ IMAGE-FILE INTO IMAGE-RECORD
AT END
MOVE 'Y' TO WS-END-OF-FILE
NOT AT END
MOVE IMAGE-RECORD TO WS-BINARY-DATA
MOVE WS-BINARY-DATA TO WS-IMAGE-BUFFER(WS-BUFFER-INDEX)
ADD 1 TO WS-BUFFER-INDEX
ADD 1024 TO WS-IMAGE-SIZE
END-READ
END-PERFORM.
CLOSE IMAGE-FILE
DISPLAY "Image Size: " WS-IMAGE-SIZE " bytes"
DISPLAY "Binary data stored in WS-IMAGE-BUFFER."
STOP RUN.
This code, however, does not work. When I read the image file into IMAGE-RECORD, it is blank. I am using Visual COBOL v9 on a Windows 10 pro. Thanks in advance.