Web/CGI Example?

In regards to the Personal Edition of Visual COBOL - what features are supported for CGI programs? 

I have found the EXTERNAL-FORM and EXEC-HTML facilities.

EXEC HTML errors out for me. Using the command line so I can more easily copy the results into this note, here is an example: 

This source code:


Causes this error: 

paul@LNX1:~/web/cobsrc> cob -xo ../bin/CGI001 CGI001.cbl
CGI001.o: In function `CGI001':
CGI001.cbl:(.text 0x41d): undefined reference to `HTML'

The External Forms stuff works pretty well, but it feels a little old. Sending the entire form back each time a request happens isn't all that efficient either. 

Has anyone gotten this to work with say, XML or modern Ajax based screens? If so, do you have an example you would be willing to share? I normally send XML from Ajax screens and expect an XML reply. 



  • Verified Answer

    In order for the exec html statements to work you have to turn on the preprocessor directive:

    EHTML Preprocessor  

    EHTML is an integrated preprocessor provided with this system and designed to work closely with the Micro Focus COBOL Compiler. It identifies HTML embedded in COBOL code as delineated by EXEC HTML statements, and outputs the HTML to your Web server.

    To run the EHTML preprocessor, set the PREPROCESS Compiler directive to htmlpp using one of the following methods:

    Code a $SET statement before the first line in your COBOL program file using the following syntax :

    $SET preprocess(htmlpp) [EHTML-directive(s)] endp

    Where EHTML-directive(s) is one or more EHTML preprocessor directives.
    See EHTML Preprocessor Directives for more information


    I believe that this is the extent of what we have for the Linux/Unix systems for HTML support directly from COBOL.

    We do also support the use of XML through an integrated XML preprocessor which would allow you to assign an xml stream directly to the I-O of a cgi program so that you could pass xml messages back and forth.

    This is documented here:.

    For JVM COBOL you can code your web pages in Java and then call your COBOL programs directly as JVM code.

    Under the Visual COBOL for Visual Studio products there is also full support for creating ASP.NET web applications or web sites including the use of AJAX, etc.


  • Thanks Chris - I read the words "integrated processor" in the docs and immediately skipped over the rest of it to the example. (*sigh*)

    Works great if one turns it on!