I'm learning about cobol alone and when I was coding my first code I had some doubts.
I'm using GnuCOBOL v2.2 at websites (TutorialsPoint and JDoodle) and I didn't understand how I can put inputs by comand window. Do anyone know how do it at these websites ?
Other thing is about how to clean terminal, when I use "DISPLAY WINDOW ERASE" I have that error message: "140: warning: GRAPHICAL WINDOW is not implemented". Do I need to use any library or exist any other comand ?
One more doubt: function integer-of-date do not convert that it proposes, the output is coming zero just. Code is below:
WORKING-STORAGE SECTION.
77 DATA1 PIC 9(006).
77 DATA2 PIC 9(006).
77 INTEIRO-1 PIC 9(008).
77 INTEIRO-2 PIC 9(008).
77 DIAS PIC 9(005).
PROCEDURE DIVISION.
ACCEPT DATA1 FROM DATE
SET DATA2 TO 930217
MOVE FUNCTION INTEGER-OF-DATE (DATA1) TO INTEIRO-1 *> wrong convertion?
MOVE FUNCTION INTEGER-OF-DATE (DATA2) TO INTEIRO-2
COMPUTE DIAS = INTEIRO-2 - INTEIRO-1
DISPLAY X"0A"DATA1 " " DATA2
SET INTEIRO-1 TO FUNCTION INTEGER-OF-DATE(DATA1)
DISPLAY INTEIRO-1 " " INTEIRO-2
DISPLAY "DIAS: " DIAS
The output of that code is:
180516 930217
00000000 00000000
DIAS: 00000
Answering the integer-of-date question
FUNCTION INTEGER-OF-DATE(ccyymmdd)
You need to use full 4 digit years in a PIC 9(8)
field for this function.
ACCEPT FROM DATE
returns a PIC 9(6)
, and there is now an
ACCEPT FROM DATE YYYYMMDD
form that returns a PIC 9(8)
.