Does anyone know what this program produces as output?
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. NUMBERS.
000300 AUTHOR. TEEBEE.
000400****************************************************************
000500* Simply transfer the present program to your favorite *
000600* mainframe computer, compile it, link it and submit some *
000700* appropriate JCL to run it. Its output tells the answer. *
000800****************************************************************
000900 ENVIRONMENT DIVISION.
001000 CONFIGURATION SECTION.
001100 OBJECT-COMPUTER. IBM-370.
001200 SOURCE-COMPUTER. IBM-370.
001300 DATA DIVISION.
001400 WORKING-STORAGE SECTION.
001500 01 THE-NUMBERS.
001600 10 FILLER USAGE IS COMP-1 VALUE -.24093455E+04.
001700 10 FILLER USAGE IS COMP-1 VALUE -.55439222E-47.
001800 10 FILLER USAGE IS COMP-1 VALUE -.33044246E-54.
001900 10 FILLER USAGE IS COMP-1 VALUE -.15622514E-50.
002000 10 FILLER USAGE IS COMP-1 VALUE .90854859E+00.
002100 10 FILLER USAGE IS COMP-1 VALUE -.27585575E-47.
002200 10 FILLER USAGE IS COMP-1 VALUE -.48936378E-36.
002300 10 FILLER USAGE IS COMP-1 VALUE .53763199E+00.
002400 10 FILLER USAGE IS COMP-1 VALUE .21482344E+74.
002500 10 FILLER USAGE IS COMP-1 VALUE .76006532E+00.
002600 10 FILLER USAGE IS COMP-1 VALUE -.22917763E-71.
002700 10 FILLER USAGE IS COMP-1 VALUE -.15607424E-50.
002800 01 THE-ANSWER REDEFINES THE-NUMBERS PIC X(48).
002900 PROCEDURE DIVISION.
003000 DISPLAY THE-ANSWER
003100 GOBACK.
003200 END PROGRAM NUMBERS.
My retired COBOL programmer friends tell me it produces some text (?) but as a total COBOL newbie (I can program in Delphi and Python, amongst others) I'm struggling.
Kind regards, I'm probably being dim.
Jim
COMP-1 and confusion
-
- Posts: 4
- Joined: Sat Jul 10, 2010 3:55 pm
- Skillset: limited in cobol, that's why i'm here
- Referer: google
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: COMP-1 and confusion
I would suggest you follow the indtructions in the comments in the ID Section. You can use a PC Cobol compiler. You should also look up the maual for REDEFINES and COMP-1
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Posts: 4
- Joined: Sat Jul 10, 2010 3:55 pm
- Skillset: limited in cobol, that's why i'm here
- Referer: google
Re: COMP-1 and confusion
Thanks, but assuming I am just stupid and lazy, (and can't work a cobol compiler - I HAVE TRIED!) could someone just run this through a compiler for me!
-
- Global moderator
- Posts: 3006
- Joined: Fri Apr 18, 2008 11:25 pm
- Skillset: tso,rexx,assembler,pl/i,storage,mvs,os/390,z/os,
- Referer: www.ibmmainframes.com
Re: COMP-1 and confusion
... but assuming I am just stupid and lazy, ...
then doing anything on your behalf would be just a useless waste of time
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Global moderator
- Posts: 3025
- Joined: Sun Jul 04, 2010 12:13 am
- Skillset: JCL, PL/1, Rexx, Utilities and to a lesser extent (i.e. I have programmed using them) COBOL,DB2,IMS
- Referer: Google
- Location: Pushing up the daisies (almost)
Re: COMP-1 and confusion
Anyway, there are 2 compile error messages - DISPLAY... and GOBACK should start in 'area b'
On the PC it displays a load of garbage but on the mainframe it displays a message in English. I think that if I cut and pasted the PC output to a file then one of my editors could be persuaded to read the file in EBCDIC rather than ASCII and I might then get the correct message.
It is all to do with how you interpret the bit patterns - you enter them as numerics and read them as text.
On the PC it displays a load of garbage but on the mainframe it displays a message in English. I think that if I cut and pasted the PC output to a file then one of my editors could be persuaded to read the file in EBCDIC rather than ASCII and I might then get the correct message.
It is all to do with how you interpret the bit patterns - you enter them as numerics and read them as text.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
Regards
Nic
-
- Posts: 4
- Joined: Sat Jul 10, 2010 3:55 pm
- Skillset: limited in cobol, that's why i'm here
- Referer: google
Re: COMP-1 and confusion
okay, I'm prepared to understand this, but do you mean the english output is a readable string? If so, what string? If not, can you post the unreadable text and I'll have a go at translating it!
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: COMP-1 and confusion
Code: Select all
Congratulations. Your answer is 'Big Blue Iron'.
If you use a PC compiler, you almost certainly will not get this result, which is based upon EBCDIC not ASCII. This can be done with any character string by doing something like (warning -- this is not tested code):
Code: Select all
05 WS-TEXT PIC X(80) VALUE 'This is a test'.
05 WS-C1-VARS REDEFINES WS-TEXT.
10 WS-C1-DATA OCCURS 20 USAGE COMP-1.
-
- Posts: 4
- Joined: Sat Jul 10, 2010 3:55 pm
- Skillset: limited in cobol, that's why i'm here
- Referer: google
Re: COMP-1 and confusion
Thank you so much for this! I've been trying for ages!
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: COMP-1 and confusion
Understanding this programs requires a good understanding of the internal storage formats for PIC X and USAGE COMP-1 variables. The same thing could be done on a PC COBOL compiler, but the data values would be completely different.
-
- Posts: 1
- Joined: Mon Jul 26, 2010 12:41 am
- Skillset: HLASM, COBOL, Java
- Referer: Google alret for COBOL
Re: COMP-1 and confusion
I was able to compile, link, and execute this test COBOL program on my Windows Vista system using zCOBOL which is an open source portable mainframe COBOL compiler which generates HLASM mainframe assembler which is then assembled and executed running z390 which is open source portable mainframe assembler and emulator.
However, I first had to apply PTF 1126 to correct parsing error for floating point constants. There were 2 problems: the - exponent was being translated to _ and the unnessary + exponent was not being corrently handled. With these corrections, zcobol generted a valid HLASM assembler program which assembled and executed with the following display log:
15:00:07 numbers EZ390 START USING z390 V1.5.01ex2 ON J2SE 1.6.0_20 07/25/10
EZ390I Copyright 2008 Automated Software Tools Corporation
EZ390I z390 is licensed under GNU General Public License
EZ390I program = w:\work\z390\numbers.390
EZ390I options = SYS390(+zcobol\z390)
Congratulathons¢ Yotr answeq is 'Bif Blue Iron'¢
EZ390I instructions/sec = 2200
EZ390I total errors = 0
15:00:07 numbers EZ390 ENDED RC= 0 SEC= 0 MEM(MB)= 20 IO=185 INS=143
Notice the result is readable as zcobol and z390 do operate in EBCDIC default environment on Windows and LInux and execute all the problem state z/Architecture instructions. However there are a few characters that are off by a single bit. The differences are probably due to J2SE emulation of floating point not using enough guard digits. RPI 1124 was about the same sort of issue raised by another z390 user recently. For more on zcobol and z390 including previous presentations at SHARE visit www.z390.org.
However, I first had to apply PTF 1126 to correct parsing error for floating point constants. There were 2 problems: the - exponent was being translated to _ and the unnessary + exponent was not being corrently handled. With these corrections, zcobol generted a valid HLASM assembler program which assembled and executed with the following display log:
15:00:07 numbers EZ390 START USING z390 V1.5.01ex2 ON J2SE 1.6.0_20 07/25/10
EZ390I Copyright 2008 Automated Software Tools Corporation
EZ390I z390 is licensed under GNU General Public License
EZ390I program = w:\work\z390\numbers.390
EZ390I options = SYS390(+zcobol\z390)
Congratulathons¢ Yotr answeq is 'Bif Blue Iron'¢
EZ390I instructions/sec = 2200
EZ390I total errors = 0
15:00:07 numbers EZ390 ENDED RC= 0 SEC= 0 MEM(MB)= 20 IO=185 INS=143
Notice the result is readable as zcobol and z390 do operate in EBCDIC default environment on Windows and LInux and execute all the problem state z/Architecture instructions. However there are a few characters that are off by a single bit. The differences are probably due to J2SE emulation of floating point not using enough guard digits. RPI 1124 was about the same sort of issue raised by another z390 user recently. For more on zcobol and z390 including previous presentations at SHARE visit www.z390.org.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 3
- 5837
-
by sergeyken
View the latest post
Sat Dec 10, 2022 2:30 am
-
- 5
- 2614
-
by sergeyken
View the latest post
Thu Feb 25, 2021 8:19 pm
-
-
Moving High-Values from Comp-3 - COBOL Ver 6.4
by girik1001 » Thu Jul 20, 2023 12:08 pm » in IBM Cobol - 1
- 3861
-
by sergeyken
View the latest post
Thu Jul 20, 2023 6:38 pm
-
-
- 1
- 1720
-
by sergeyken
View the latest post
Fri Mar 26, 2021 11:59 pm