COBOL
-
- Posts: 1
- Joined: Fri May 20, 2005 4:23 pm
COBOL
Is there a feature to the COBOL functionality that handles copybook - i.e. will the editor open or display copybooks appear in the program body?
There is nothing specific to COBOL, but the generic file handling in Zeus should be able to handle this.
The View, Open Include menu item which maps to the FileOpenInLine keyboard function tries to open any file contained on the current line. So if a copybook is a file, then place the cursor on the line containing the copyboook and use this menu or the keyboard function to load the copybook.
If this load reports an error in the status bar then it means that Zeus did not find a file name in the line of text, meaning the file name regular expression needs to be configured. The file name regular expression is used by this feature to identify a file name from any give line of code.
The file name regular expression is found in the general settings of the document type and there is information about writing regular exprssions on this forum or in the Zeus online help.
But if you have trouble getting this feature to work, just post some sample code showing what a line containing a copybook looks like and I will have a go at writing a suitable file name regular expression.
Cheers Jussi
The View, Open Include menu item which maps to the FileOpenInLine keyboard function tries to open any file contained on the current line. So if a copybook is a file, then place the cursor on the line containing the copyboook and use this menu or the keyboard function to load the copybook.
If this load reports an error in the status bar then it means that Zeus did not find a file name in the line of text, meaning the file name regular expression needs to be configured. The file name regular expression is used by this feature to identify a file name from any give line of code.
The file name regular expression is found in the general settings of the document type and there is information about writing regular exprssions on this forum or in the Zeus online help.
But if you have trouble getting this feature to work, just post some sample code showing what a line containing a copybook looks like and I will have a go at writing a suitable file name regular expression.
Cheers Jussi
In my version, 3.96, the View, Open Include menu item no longer exists. Has it been rendered obsolete or is it called something else now?
When I went to Options, Editor Options, Keyboard Mapping, Edit, and browsed thru the list of keyboard functions, I was able to locate FileOpenInLine. I tried that on a COBOL source file with the current line being a COPY statement referencing a file but received the message "No file was found within the current line or marked text region. Make sure the search path has been correctly specified." Ok, but where do I specify the search path? Document type is COBOL. Also, I'm thinking that I'll need a regular expression to correctly parse out the filename within the text on the line. Is that correct?
Here are some examples of valid COPY statements (the COBOL implementation of "including" files) for IBM mainframe (z/OS) COBOL:
and the statements may also be commented or conditional ('D' in column 7):
Also, columns 1-6 are ignored and used to flag lines with change dates or references.
Essentially to parse out the filename correctly, everything other than the word following the word "COPY" should be ignored; that word is the filename which then needs to suffixed with one of ".cob", ".cbl", ".cbk", ".cpy", or ".txt". So where do I add the regexp to do this? Thanks.
When I went to Options, Editor Options, Keyboard Mapping, Edit, and browsed thru the list of keyboard functions, I was able to locate FileOpenInLine. I tried that on a COBOL source file with the current line being a COPY statement referencing a file but received the message "No file was found within the current line or marked text region. Make sure the search path has been correctly specified." Ok, but where do I specify the search path? Document type is COBOL. Also, I'm thinking that I'll need a regular expression to correctly parse out the filename within the text on the line. Is that correct?
Here are some examples of valid COPY statements (the COBOL implementation of "including" files) for IBM mainframe (z/OS) COBOL:
Code: Select all
123456789012... <- column line
COPY RSPCODES.
061115 COPY EXCRESP2.
COPY RSPCODES REPLACING ==:== BY ==DB2==.
061115 COPY EXCRESP2 REPLACING ==:== BY ==IN2==.
Code: Select all
061115* COPY EXCRESP2 REPLACING ==:== BY ==IN2==.
061115D COPY EXCRESP2 REPLACING ==:== BY ==IN2==.
Essentially to parse out the filename correctly, everything other than the word following the word "COPY" should be ignored; that word is the filename which then needs to suffixed with one of ".cob", ".cbl", ".cbk", ".cpy", or ".txt". So where do I add the regexp to do this? Thanks.
This is now the View, File Open menu item.In my version, 3.96, the View, Open Include menu item no longer exists. Has it been rendered obsolete or is it called something else now?
There are several places to do this.Ok, but where do I specify the search path?
The first location is in the General section of the Document Type.
It can also be specified in the General section of the Workspace Options menu.
Finally if you use the General section of the Defaukt Document Type then all documents will share the search path.
The search path is a list of paths separated by a semi-colon for example: c:\projects;d:\framework;c:\system\include;
Looking at your examples, I'm not sure if there is a regular expression that can uniquely identify the file nameAlso, I'm thinking that I'll need a regular expression to correctly parse out the filename within the text on the line. Is that correct?

Code: Select all
COPY RSPCODES.
061115 COPY RXCRESP2.
COPY RSPCODES REPLACING ==:== BY ==DB2==.
061115 COPY EXCRESP2 REPLACING ==:== BY ==IN2==.

Code: Select all
Essentially to parse out the filename correctly, everything other than the word following the word "COPY" should be ignored; that word is the filename which then needs to suffixed with one of ".cob", ".cbl", ".cbk", ".cpy", or ".txt".

But luckily there is a macro alternative

The following macro should do the trick:
Code: Select all
-- Option 1: Let the FileOpenInLine function do the work
function my_file_open_one()
-- mark the current word
local result = MarkWordCurrent()
if result > 0 then
--
-- NOTE: If no file extension is provided then the FileOpenInLine will
-- use the extension of the current file as it's best guess.
--
-- try to open the file
FileOpenInLine()
else
message("Make sure the cursor is placed on the file name.")
beep()
end
end
-- Option 2: A more complex macro
function my_file_open_two()
-- get the text
local line_text = get_line_text()
if string.len(line_text) > 0 then
-- look the word copy + space + file name + a space or dot character
local i1, i2, copy, copy_book = string.find(line_text, "(COPY%s)(%w*)([%s\.]+)")
if copy_book ~= nil then
-- use the current document path
local path = macro_tag("$fdd")
-- now the copybook has a path
copy_book = path .. copy_book
-- try the different extensions
if file_open(copy_book .. ".cob") == 1 then
elseif file_open(copy_book .. ".cbl") == 1 then
elseif file_open(copy_book .. ".cbk") == 1 then
elseif file_open(copy_book .. ".cpy") == 1 then
elseif file_open(copy_book .. ".txt") == 1 then
else
message("Unexpected error opening " .. copy_book .. " copy book!")
beep()
end
else
message("No file was found on this line.")
beep()
end
else
message("Place the cursor on the line that contains the file.")
beep()
end
end
function key_macro()
-- macro only works for documents
local document = is_document()
if document > 0 then
-- here is one option
my_file_open_one()
-- here is another option
my_file_open_two()
else
message("This macro only works for document files!")
beep()
end
end
key_macro() -- run the macro
P.S. The macro option two hacks the path because the file_open does not use the search path but in the next Zeus patch I will make sure the file_open macro function uses the search path so this hack would not be required

With the latest Zeus patch the file_open macro function has been improved to now uses the search path:
http://www.zeusedit.com/forum/viewtopic.php?p=3234
Cheers Jussi
http://www.zeusedit.com/forum/viewtopic.php?p=3234
Cheers Jussi