Still learning COBOL. I'm using visual studio code and a few extensions for
COBOL. I did not find an extension that reformats the code. Code blocks
editor has options for formatting C & Java. Is there a COBOL formatter
available?
You tell vscode to reformat either a file or a block and it will do an appropriate left alignment, possibly also reformat clauses and phrases.
There are also special cases, for example if there is enough place it may align subscripts, refmod and/or TO/GIVING/...
some IDEs for other languages have a feature that will indent the code to a standard. Of course the proper thing to do is learn and do it yourself. It is a helpful way to learn too.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
GnuCOBOL uses both standard formatted code and free form. I am a dinosaur (Pariah) and like the formatted way. Mr. Coen, from the above post, has two programs that are extremely useful. One to convert to formatted and one to convert to free style. These are not IDE's but programs to run on your Cobol source code.
You can view his formatting programs HERE .
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure how many people have tried it, my initial experiments went well, in the small, but IBM offers a Z Open Editor extension for vscode. It has an experimental formatter.
You need to tweak a zcodeformat.yaml(or .json, .yaml preferred) file for preferences.
There are limits to the went well . IBM COBOL does not know all the things that GnuCOBOL knows (like >>SOURCE FORMAT directives). But that might be the simplistic zcodeformat.yaml file I'm using.
Even if the code formatter does not match personal tastes, the extension also ships with a bundle of handy code fragments for COBOL, and REXX and PL/I and ...) accessible from the Insert Snippet command palette. Meant for z/OS COBOL the fragments are not always GnuCOBOL drop in, but they'll be very close.
From the extension marketplace, (recommend VSCodium over VSCode, but both have these in the catalogs) search for "IBM Z" to get a list of contributions.
VSCodium https://vscodium.com is built from the same core source tree as VSCode, without additions of Branding (and telemetry gathering) that ships with VSCode from Microsoft. Similar to the all free Chromium and less free Google Chrome release builds.
Have good,
Blue
Last edit: Brian Tiffin 2023-10-22
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure how many people have tried it, /my initial experiments went
well, in the small/, but IBM offers a Z Open Editor extension for
vscode. It has an experimental formatter.
You need to tweak a /zcodeformat.yaml/(or .json, .yaml preferred) file
for preferences.
There are limits to the /went well/ . IBM COBOL does not know all the
things that GnuCOBOL knows (like |>>SOURCE FORMAT| directives). But
that might be the simplistic zcodeformat.yaml file I'm using.
V16 is available but the whole document section is typical IBM it doe
sNOT mention what the tool does only details of the tool.
I.E., what does it change in a Cobol source file, what does it expect as
input and what is the output.
Not sure how many people have tried it, /my initial experiments went
well, in the small/, but IBM offers a Z Open Editor extension for
vscode. It has an experimental formatter.
You need to tweak a /zcodeformat.yaml/(or .json, .yaml preferred) file
for preferences.
There are limits to the /went well/ . IBM COBOL does not know all the
things that GnuCOBOL knows (like |>>SOURCE FORMAT| directives). But
that might be the simplistic zcodeformat.yaml file I'm using.
As far as I know all of their compiler only use FIXED.
They are very slow in keeping up with some standard changes but possibly
due to the limitations of PDS / PDSE record control in that record size
of 80 fixed is easy to support and record of up to 255 not so much.
BUT, I have never tried to create such a format.
Regardless I am sure it would not be that difficult to do so. How long
has FREE format been around ?
A long time.
Mickey, thanks for the answer. I using gnucobol 3.1.2.0. I tried to compile as follows
cobc -x changeformat.cbl
I get these errors. Do you have any tips for these errors?
changeformat.cbl:106: error: syntax error, unexpected Literal
changeformat.cbl: in paragraph 'convert-to-fixed':
changeformat.cbl:578: warning: IF without imperative statement used [-Wdialect]
John
Last year, a user asked for help formatting cobol programs. I and Arnold helped him with 3 programs that format cobol programs. Search for the discussion beautify. The discussion went on for 7pages. I wrote 3 programs and Arnold wrote one program.
Arnold's program is called BEAUTIFY. When he got too busy to continue with the project, I took his program and did some modifications to it. I renamed the modified program TESTIT.COB. This program formats code to standards which are similar in many production shops. I suggest renaming it back to BEAUTIFY.
My programs are;
QWKFIX5 which splits up code to individual lines when there are multiple sentences on one line. This was for a special case and not used much.
COBOLSEQ Which has options to sequence col 1-6, convert lower to upper case, number procedure names of un-sequenced names, and a few other things. There is a readme for this.
IFALIGN which was intended to align IF statements with their END-IF statements. It does alignment on some other statements too. There is a readme for this program. This program makes a good frontend to BEAUTIFY.
All four of these programs process FIXED format COBOL code.
If you go to page 7 of 7 of the posts, and work your way backwards, you can get the latest versions of these programs.
The way I use these programs is to run COBOLSEQ to convert to uppercase, seq col 1-6, put program ID into 73-80, number procedure names. Then run IFALIGN and finally BEAUTIFY or TESTIT if you did not rename TESTIT back to BEAUTIFY. When done, the final output will have blank sequence numbers and IDs on lines added to the code. That makes changes easy to find.
Keep in mind that these programs were still in development at the time of the posts.
If you are interested, I would be happy to give my two-bits worth of help.
Michael :-)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
John
Last year, a user asked for help formatting cobol programs. I and Arnold
helped him with 3 programs that format cobol programs. Search for the
discussion beautify. The discussion went on for 7pages. I wrote 3 programs
and Arnold wrote one program.
Arnold's program is called BEAUTIFY. When he got too busy to continue with
the project, I took his program and did some modifications to it. I renamed
the modified program TESTIT.COB. This program formats code to standards
which are similar in many production shops. I suggest renaming it back to
BEAUTIFY.
My programs are;
QWKFIX5 which splits up code to individual lines when there are multiple
sentences on one line. This was for a special case and not used much.
COBOLSEQ Which has options to sequence col 1-6, convert lower to upper case,
number procedure names of un-sequenced names, and a few other things. There
is a readme for this.
IFALIGN which was intended to align IF statements with their END-IF
statements. It does alignment on some other statements too. There is a
readme for this program. This program makes a good frontend to BEAUTIFY.
All four of these programs process FIXED format COBOL code.
If you go to page 7 of 7 of the posts, and work your way backwards, you can
get the latest versions of these programs.
The way I use these programs is to run COBOLSEQ to convert to uppercase, seq
col 1-6, put program ID into 73-80, number procedure names. Then run IFALIGN
and finally BEAUTIFY or TESTIT if you did not rename TESTIT back to
BEAUTIFY. When done, the final output will have blank sequence numbers and
IDs on lines added to the code. That makes changes easy to find.
Keep in mind that these programs were still in development at the time of
the posts.
If you are interested, I would be happy to give my two-bits worth of help.
To John and those interested in COBOLSEQ.COB new version 1.9.
A fix was made to the convert to uppercase routine. When an * > also had quoted comments on the same line, the routine did not handle correctly.
While I was at it, I added support for procedure names with 4 digit prefixes. This is now available when SWITCH-H-ON -h command line option is on.
They are handled thusly.
If a -SECTION line 005-SECTION precedes the paragraph, then;
A procedure named 1234-MAIN will be sequenced in position 2-4 keeping position 1 unchanged. So, a new sequenced name would be 1005-MAIN. A procedure name A123-MAIN would be changed to A005-MAIN.
The -SECTION record will apply to the positions 2-4.
This allows for you to group your names using either an alpha or numeric first digit.
When switch -H is active, 3 digit prefixed procedure names are ignored for processing. When -H is not on, 4 digit prefixed procedure names are ignored.
To John and those interested in COBOLSEQ.COB new version 1.9.
A fix was made to the convert to uppercase routine. When an * > also had quoted comments on the same line, the routine did not handle correctly.
While I was at it, I added support for procedure names with 4 digit prefixes. This is now available when SWITCH-H-ON -h command line option is on.
They are handled thusly.
If a -SECTION line 005-SECTION precedes the paragraph, then;
A procedure named 1234-MAIN will be sequenced in position 2-4 keeping position 1 unchanged. So, a new sequenced name would be 1005-MAIN. A procedure name A123-MAIN would be changed to A005-MAIN.
The -SECTION record will apply to the positions 2-4.
This allows for you to group your names using either an alpha or numeric first digit.
When switch -H is active, 3 digit prefixed procedure names are ignored for processing. When -H is not on, 4 digit prefixed procedure names are ignored.
John
If you are monitoring your posts, I have some copy book procedures that I use a lot. They are mostly dealing with getting things from the command line. There are basically routines to get override file names for hard coded files. Routines to get what I call switches to control program flow. Like perform a particular routine depending on a switch being on or off. Also routines that handle the STATUS of file processing. These routines are written so that switches and files may be in any order.
I have updated many of the copy books I commonly use. If you downloaded my program COBOLSEQ.COB, You should use these updated copy books and recompile COBOLSEQ.
I have a program, QWKFIX.COB that I frequently use as a starting point for new programs. And a program named QWKFIX-TEST.COB that demonstrates the use of some of these copy books.
You said you are still learning COBOL, so I thought these things will show you what I have learned about GnuCobol on windows.
Unfortunately, I tend to code in Streight line style rather that structured style, so there would be plenty of gripes about my programming. Back in the 60's, when I learned COBOL, I was proven that straight line code was more efficient that structured do to the repeated return to the beginning of code to decide where in the program to continue executing. This was important for programs that run for an hour or more. In those days, computer time was bought by the minute. Of course, this does not matter now when running on a windows device.
Anyway, unpack the attached 7-zip file where you have COBOLSEQ.COB. That is if you got it.
If you are not interested, I will but out.
Thanks for the update. I did download COBOLSEQ.COB. I will update the copybooks and compile. I will test. I will also check out QWKFIX-TEST.COB too. I appreciate you suggestions so don't butt out 😊
If you are monitoring your posts, I have some copy book procedures that I use a lot. They are mostly dealing with getting things from the command line. There are basically routines to get override file names for hard coded files. Routines to get what I call switches to control program flow. Like perform a particular routine depending on a switch being on or off. Also routines that handle the STATUS of file processing. These routines are written so that switches and files may be in any order.
I have updated many of the copy books I commonly use. If you downloaded my program COBOLSEQ.COB, You should use these updated copy books and recompile COBOLSEQ.
I have a program, QWKFIX.COB that I frequently use as a starting point for new programs. And a program named QWKFIX-TEST.COB that demonstrates the use of some of these copy books.
You said you are still learning COBOL, so I thought these things will show you what I have learned about GnuCobol on windows.
Unfortunately, I tend to code in Streight line style rather that structured style, so there would be plenty of gripes about my programming. Back in the 60's, when I learned COBOL, I was proven that straight line code was more efficient that structured do to the repeated return to the beginning of code to decide where in the program to continue executing. This was important for programs that run for an hour or more. In those days, computer time was bought by the minute. Of course, this does not matter now when running on a windows device.
Anyway, unpack the attached 7-zip file where you have COBOLSEQ.COB. That is if you got it.
Still learning COBOL. I'm using visual studio code and a few extensions for
COBOL. I did not find an extension that reformats the code. Code blocks
editor has options for formatting C & Java. Is there a COBOL formatter
available?
What do you mean by reformatting ?
mod edit for some reply-to
Last edit: Brian Tiffin 2023-10-22
You tell vscode to reformat either a file or a block and it will do an appropriate left alignment, possibly also reformat clauses and phrases.
There are also special cases, for example if there is enough place it may align subscripts, refmod and/or TO/GIVING/...
I don't see an option on a shortcut menu for the full menu named reformat. Where do I find this?
some IDEs for other languages have a feature that will indent the code to a standard. Of course the proper thing to do is learn and do it yourself. It is a helpful way to learn too.
GnuCOBOL uses both standard formatted code and free form. I am a dinosaur (Pariah) and like the formatted way. Mr. Coen, from the above post, has two programs that are extremely useful. One to convert to formatted and one to convert to free style. These are not IDE's but programs to run on your Cobol source code.
You can view his formatting programs HERE .
Not sure how many people have tried it, my initial experiments went well, in the small, but IBM offers a Z Open Editor extension for vscode. It has an experimental formatter.
You need to tweak a zcodeformat.yaml(or .json, .yaml preferred) file for preferences.
There are limits to the went well . IBM COBOL does not know all the things that GnuCOBOL knows (like
>>SOURCE FORMAT
directives). But that might be the simplistic zcodeformat.yaml file I'm using.https://www.ibm.com/docs/en/developer-for-zos/15.0?topic=code-experimental-formatting-cobol-source
Even if the code formatter does not match personal tastes, the extension also ships with a bundle of handy code fragments for COBOL, and REXX and PL/I and ...) accessible from the Insert Snippet command palette. Meant for z/OS COBOL the fragments are not always GnuCOBOL drop in, but they'll be very close.
From the extension marketplace, (recommend VSCodium over VSCode, but both have these in the catalogs) search for "IBM Z" to get a list of contributions.
VSCodium https://vscodium.com is built from the same core source tree as VSCode, without additions of Branding (and telemetry gathering) that ships with VSCode from Microsoft. Similar to the all free Chromium and less free Google Chrome release builds.
Have good,
Blue
Last edit: Brian Tiffin 2023-10-22
On 22/10/2023 15:30, Brian Tiffin wrote:
They never learn !
On 22/10/2023 15:30, Brian Tiffin wrote:
They are very slow in keeping up with some standard changes but possibly
due to the limitations of PDS / PDSE record control in that record size
of 80 fixed is easy to support and record of up to 255 not so much.
BUT, I have never tried to create such a format.
Regardless I am sure it would not be that difficult to do so. How long
has FREE format been around ?
A long time.
Mickey, thanks for the answer. I using gnucobol 3.1.2.0. I tried to compile as follows
cobc -x changeformat.cbl
I get these errors. Do you have any tips for these errors?
changeformat.cbl:106: error: syntax error, unexpected Literal
changeformat.cbl: in paragraph 'convert-to-fixed':
changeformat.cbl:578: warning: IF without imperative statement used [-Wdialect]
John, perhaps you have an older version. If Chucks fix does not work down load the attached.
John
at line 106, add the word VALUE before the literal.
after line 575 (which is a comment) add the following line
continue
======> I think that those two changes should fix your compile errors.
Yep, that fixed both errors. Thank you !
-----Original Message-----
From: discussion@gnucobol.p.re.sourceforge.net
discussion@gnucobol.p.re.sourceforge.net On Behalf Of Chuck H.
Sent: Friday, September 15, 2023 6:14 PM
To: [gnucobol:discussion] cobol@discussion.gnucobol.p.re.sourceforge.net
Subject: [gnucobol:discussion] Are COBOL code formatters available?
John
at line 106, add the word VALUE before the literal.
after line 575 (which is a comment) add the following line
continue
======> I think that those two changes should fix your compile errors.
Are COBOL code formatters
available?
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/gnucobol/discussion/cobol/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
John
Last year, a user asked for help formatting cobol programs. I and Arnold helped him with 3 programs that format cobol programs. Search for the discussion beautify. The discussion went on for 7pages. I wrote 3 programs and Arnold wrote one program.
Arnold's program is called BEAUTIFY. When he got too busy to continue with the project, I took his program and did some modifications to it. I renamed the modified program TESTIT.COB. This program formats code to standards which are similar in many production shops. I suggest renaming it back to BEAUTIFY.
My programs are;
QWKFIX5 which splits up code to individual lines when there are multiple sentences on one line. This was for a special case and not used much.
COBOLSEQ Which has options to sequence col 1-6, convert lower to upper case, number procedure names of un-sequenced names, and a few other things. There is a readme for this.
IFALIGN which was intended to align IF statements with their END-IF statements. It does alignment on some other statements too. There is a readme for this program. This program makes a good frontend to BEAUTIFY.
All four of these programs process FIXED format COBOL code.
If you go to page 7 of 7 of the posts, and work your way backwards, you can get the latest versions of these programs.
The way I use these programs is to run COBOLSEQ to convert to uppercase, seq col 1-6, put program ID into 73-80, number procedure names. Then run IFALIGN and finally BEAUTIFY or TESTIT if you did not rename TESTIT back to BEAUTIFY. When done, the final output will have blank sequence numbers and IDs on lines added to the code. That makes changes easy to find.
Keep in mind that these programs were still in development at the time of the posts.
If you are interested, I would be happy to give my two-bits worth of help.
Michael :-)
Hey Michael,
Thanks for the information. It sounds useful. I will check it out.
Thanks,
John
-----Original Message-----
From: discussion@gnucobol.p.re.sourceforge.net
discussion@gnucobol.p.re.sourceforge.net On Behalf Of Michael F Gleason
Sent: Monday, September 18, 2023 8:04 PM
To: [gnucobol:discussion] cobol@discussion.gnucobol.p.re.sourceforge.net
Subject: [gnucobol:discussion] Are COBOL code formatters available?
John
Last year, a user asked for help formatting cobol programs. I and Arnold
helped him with 3 programs that format cobol programs. Search for the
discussion beautify. The discussion went on for 7pages. I wrote 3 programs
and Arnold wrote one program.
Arnold's program is called BEAUTIFY. When he got too busy to continue with
the project, I took his program and did some modifications to it. I renamed
the modified program TESTIT.COB. This program formats code to standards
which are similar in many production shops. I suggest renaming it back to
BEAUTIFY.
My programs are;
QWKFIX5 which splits up code to individual lines when there are multiple
sentences on one line. This was for a special case and not used much.
COBOLSEQ Which has options to sequence col 1-6, convert lower to upper case,
number procedure names of un-sequenced names, and a few other things. There
is a readme for this.
IFALIGN which was intended to align IF statements with their END-IF
statements. It does alignment on some other statements too. There is a
readme for this program. This program makes a good frontend to BEAUTIFY.
All four of these programs process FIXED format COBOL code.
If you go to page 7 of 7 of the posts, and work your way backwards, you can
get the latest versions of these programs.
The way I use these programs is to run COBOLSEQ to convert to uppercase, seq
col 1-6, put program ID into 73-80, number procedure names. Then run IFALIGN
and finally BEAUTIFY or TESTIT if you did not rename TESTIT back to
BEAUTIFY. When done, the final output will have blank sequence numbers and
IDs on lines added to the code. That makes changes easy to find.
Keep in mind that these programs were still in development at the time of
the posts.
If you are interested, I would be happy to give my two-bits worth of help.
Michael :-)
Are COBOL code formatters
available?
Sent from sourceforge.net because you indicated interest in
https://sourceforge.net/p/gnucobol/discussion/cobol/
To unsubscribe from further messages, please visit
https://sourceforge.net/auth/subscriptions/
Here's a link to a late page in that thread:
https://sourceforge.net/p/gnucobol/discussion/cobol/thread/a37c539dc5/?limit=25&page=4#d652
To John and those interested in COBOLSEQ.COB new version 1.9.
A fix was made to the convert to uppercase routine. When an * > also had quoted comments on the same line, the routine did not handle correctly.
While I was at it, I added support for procedure names with 4 digit prefixes. This is now available when SWITCH-H-ON -h command line option is on.
They are handled thusly.
If a -SECTION line 005-SECTION precedes the paragraph, then;
A procedure named 1234-MAIN will be sequenced in position 2-4 keeping position 1 unchanged. So, a new sequenced name would be 1005-MAIN. A procedure name A123-MAIN would be changed to A005-MAIN.
The -SECTION record will apply to the positions 2-4.
This allows for you to group your names using either an alpha or numeric first digit.
When switch -H is active, 3 digit prefixed procedure names are ignored for processing. When -H is not on, 4 digit prefixed procedure names are ignored.
Michael :-)
To John and those interested in COBOLSEQ.COB new version 1.9.
A fix was made to the convert to uppercase routine. When an * > also had quoted comments on the same line, the routine did not handle correctly.
While I was at it, I added support for procedure names with 4 digit prefixes. This is now available when SWITCH-H-ON -h command line option is on.
They are handled thusly.
If a -SECTION line 005-SECTION precedes the paragraph, then;
A procedure named 1234-MAIN will be sequenced in position 2-4 keeping position 1 unchanged. So, a new sequenced name would be 1005-MAIN. A procedure name A123-MAIN would be changed to A005-MAIN.
The -SECTION record will apply to the positions 2-4.
This allows for you to group your names using either an alpha or numeric first digit.
When switch -H is active, 3 digit prefixed procedure names are ignored for processing. When -H is not on, 4 digit prefixed procedure names are ignored.
Michael :-)
John
If you are monitoring your posts, I have some copy book procedures that I use a lot. They are mostly dealing with getting things from the command line. There are basically routines to get override file names for hard coded files. Routines to get what I call switches to control program flow. Like perform a particular routine depending on a switch being on or off. Also routines that handle the STATUS of file processing. These routines are written so that switches and files may be in any order.
I have updated many of the copy books I commonly use. If you downloaded my program COBOLSEQ.COB, You should use these updated copy books and recompile COBOLSEQ.
I have a program, QWKFIX.COB that I frequently use as a starting point for new programs. And a program named QWKFIX-TEST.COB that demonstrates the use of some of these copy books.
You said you are still learning COBOL, so I thought these things will show you what I have learned about GnuCobol on windows.
Unfortunately, I tend to code in Streight line style rather that structured style, so there would be plenty of gripes about my programming. Back in the 60's, when I learned COBOL, I was proven that straight line code was more efficient that structured do to the repeated return to the beginning of code to decide where in the program to continue executing. This was important for programs that run for an hour or more. In those days, computer time was bought by the minute. Of course, this does not matter now when running on a windows device.
Anyway, unpack the attached 7-zip file where you have COBOLSEQ.COB. That is if you got it.
If you are not interested, I will but out.
Michael :-)
Michael,
Thanks for the update. I did download COBOLSEQ.COB. I will update the copybooks and compile. I will test. I will also check out QWKFIX-TEST.COB too. I appreciate you suggestions so don't butt out 😊
John
-----Original Message-----
From: discussion@gnucobol.p.re.sourceforge.net discussion@gnucobol.p.re.sourceforge.net On Behalf Of Michael F Gleason
Sent: Thursday, October 19, 2023 10:03 PM
To: [gnucobol:discussion] cobol@discussion.gnucobol.p.re.sourceforge.net
Subject: [gnucobol:discussion] Are COBOL code formatters available?
John
If you are monitoring your posts, I have some copy book procedures that I use a lot. They are mostly dealing with getting things from the command line. There are basically routines to get override file names for hard coded files. Routines to get what I call switches to control program flow. Like perform a particular routine depending on a switch being on or off. Also routines that handle the STATUS of file processing. These routines are written so that switches and files may be in any order.
I have updated many of the copy books I commonly use. If you downloaded my program COBOLSEQ.COB, You should use these updated copy books and recompile COBOLSEQ.
I have a program, QWKFIX.COB that I frequently use as a starting point for new programs. And a program named QWKFIX-TEST.COB that demonstrates the use of some of these copy books.
You said you are still learning COBOL, so I thought these things will show you what I have learned about GnuCobol on windows.
Unfortunately, I tend to code in Streight line style rather that structured style, so there would be plenty of gripes about my programming. Back in the 60's, when I learned COBOL, I was proven that straight line code was more efficient that structured do to the repeated return to the beginning of code to decide where in the program to continue executing. This was important for programs that run for an hour or more. In those days, computer time was bought by the minute. Of course, this does not matter now when running on a windows device.
Anyway, unpack the attached 7-zip file where you have COBOLSEQ.COB. That is if you got it.
If you are not interested, I will but out.
Michael :-)
Attachments:
Are COBOL code formatters available?
Sent from sourceforge.net because you indicated interest in < https://sourceforge.net/p/gnucobol/discussion/cobol/ https://sourceforge.net/p/gnucobol/discussion/cobol/>
To unsubscribe from further messages, please visit < https://sourceforge.net/auth/subscriptions/ https://sourceforge.net/auth/subscriptions/>