Tuesday, January 21, 2020

Creating A Registration Form for Emily School of Art

A few months ago, I created a website for Emily School of Art and now she asked me to design a registration form for her students.  This form was prepared with PHP, HTML and CSS and includes database creation with tables, connection to the database with mysqli, error flagging, SQL scripts to fill out the tables, etc.
I present below two screenshots of the registration form before and after someone registers.


Emily School of Art Student Registration Form








Registration Form after someone has signed in

Thursday, January 9, 2020

Painting a Micro Focus COBOL web Form by direct coding.


Painting a Micro Focus COBOL web form by direct coding

I developed a simple Micro Focus COBOL web form and started to paint it by adding a label, a button and a textbox to it.

First, I dragged a label from the Toolbox on to the form and changed the text property to COBOL Message.  The ID was given as lblCobolMessage.  This procedure worked fine.

Next, I dragged a button on to the form and changed the text property to Show Me.  The button ID was changed to btnShowMe.

At this point, the Intellisense function kicks in and freezes the computer.  Nothing worked.  So I had to sign off and sign on again to get back to the project.

Then, I dragged a textbox on to the form, clear the text property to blank and gave it an ID of txtShowMe.  Again, the Intellisense function kicks in and froze the computer.

At this point, I thought I should go into the Default.aspx file and enter the codes directly.  This is the code for the controls in this file:

-------------------------------------------------------------------------------

<%@ Page Title="Home Page" MasterPageFile="~/Site.master" AutoEventWireup="true"

    CodeBehind="Default.aspx.cbl" Inherits="WebApplication4._Default" %>



<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">

</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <h2>
        Welcome to Micro Focus COBOL ASP.NET!
    </h2>    
    <p> 
        To learn more about Micro Focus visit <a href="http://www.microfocus.com" title="Micro Focus Website">www.microfocus.com</a>.
    </p>
    <p> 
        <asp:Label ID="lblCobolMessage" runat="server" Text="COBOL MESSAGE"></asp:Label>
    </p>
    <p> 
        <asp:Button ID="btnShowMe" runat="server" Text="Show Me" 

OnClick="btnShowMe_Click" />
    </p>
    <p>
        <asp:TextBox ID="txtShowMe" runat="server" Text=" "></asp:TextBox>
    </p>
    <p> 
        &nbsp;</p> 
    <p> 
        You can also find documentation on Micro Focus COBOL at <a href="https://www.microfocus.com/support-and-services/documentation/"

            title="Micro Focus Documentation">Micro Focus > Support and Services > Support Resources > Documentation</a>.
    </p> 
</asp:Content>
--------------------------------------------------------------------------

Next, I double-clicked the button on the webform and add the following code in the procedure division.  Here is the code for the Default.aspx.cbl file:

-------------------------------------------------------------------------------
class-id WebApplication4._Default is partial     
               inherits type System.Web.UI.Page public.
       working-storage section.
           
       method-id Page_Load protected.
       local-storage section.
       procedure division using by value sender as object by value e as type EventArgs.
       
           goback.           
       end method.
              
       method-id btnShowMe_Click protected.
       procedure division using by value sender as object e as type System.EventArgs.

           move "Great Gatsby was here" to txtShowMe::Text
       end method.


       end class.
-----------------------------------------------------------------------------------------

Now Build the project and run it (Start without Debugging).

The webform should show up in the browser.

Hit the Show Me button.

The result should be "Great Gatsby was here".
-----------------------------------------------------------------------------------------
Author's Note:  This is a very simple project.  The objective was to show how to code for the controls on a webform if you encounter the Intellisense message.  Of course, a more complicated project can be developed but you may encounter the Intellisense function.  Just to clarify, I was using Windows 10, Visual Studio 19, and the latest version of Micro Focus Visual COBOL.

Sunday, December 29, 2019

Using OpenESQL Assistant with MicroFocus Visual COBOL and Visual Studio 2019

This blog outlines my efforts to use OpenESQL Assistant to create a native COBOL project that will extract data from a database with MicroFocus Visual COBOL and Visual Studio 2019.

(Note:  A native COBOL project is not the same as a .NET COBOL application).

A.  Create a native console COBOL project.

1.  From the Visual Studio menu, select File, New, Project.
2.  Select the console application template, and then click Next.
3.  Give the project a name, e.g. ConsoleApplication, and save in a a location e.g C:\ConsoleApplication.
4.  Click on Create.
5.  A new program, Program1.cbl will be created.  Do not delete any text in this program.

B.  Configure OpenESQL Assistant.

1. From the Visual Studio menu, select Tools, Options, MicroFocus, OpenESQL Assistant.
2. Change Type Global Variable to SQL TYPE (or standard), Mode to ODBC, Output Language to COBOL, generate EXEC SQL.
3. For the project, click on Project on the Visual Studio menu, scroll down to ConsoleApplicationProperties.
a. Select SQL (on left panel), ESQL Preprocessor, OpenESQL
b. Add directive, select DBMAN
c. Value ODBC for native.
d. Click OK

C. To start using OpenESQL Assistant

1. From the Visual Studio menu, select View, scroll down to MicroFocus SQL Tools, OpenESQL Assistant.
This will open the Assistant and point to a database.  In my case. it points to a sample database TESTSQL32.

D.  To create a new program using OpenESQL Assistant and the database.
1. Click on TESTSQL32 and select a table from the database.  In my case, I selected the employee table.
2.  Under Select Type of Query to create, click on SELECT(cursor). Then select the columns EmployeeID, Last Name, Position from the table.  These will be added to the Query.
3.  Click on Sort and move Last Name to the right column.  The result will sort the data to be extracted by Last Name.
4.  Click on Run Query to see the results.
(Note: Run Query is between Create New Query and Insert Query into project at the top left of the OpenESQL Assistant).

E.  Add this query into the COBOL Program, Program1.cbl

1.  Click on Auxiliary Code tab, scroll down to Generic SQL Program.  This will generate some sample code.
2. Click on Insert Query Into Program.  This will insert the generated code into the COBOL program, Program1.cbl
3.  Check the COBOL program that the generated code is inserted.  Check that you do not have two Working Storage Section and two Procedure Division.  Delete one of each found at the bottom of the program.
4.  In the OpenESQL Assistant, select Auxiliary Mode, Host Variable Declaration.  This will generate a copybook called Employee.cpy.  Click Save.  It will be saved in the project folder.
5.  Move back to the program, and place your cursor immediately before EXEC SQL END DECLARE.  Go back to the Assistant and click on Insert Query into program.
6.  Back in the program, right click on include employee statement and select Open "Employee.cpy" in a new window.  This will show the details of the table Employee.
7.  While in the program, place the cursor just before the EXEC SQL DISCONNECT.  Go back to the Assistant and click on Insert Into Program.

F.  Change the Display "ROW FOUND" and replace it with

DISPLAY
Employee-Employee-ID ' '
Employee-Last-Name ' '
Employee-Position

G.  Insert this after END-PERFORM:

STOP ' '
(Note:  This will hold the results on the console, otherwise it will appear and disappear in a flash).

H. Run the program

1.  From Visual Studio Menu, click on Build.  Hopefully, you will have a clean build with no errors.
2. Then Run the program.  Click on Debug, Start without debugging.

I.  The Results.

The results will show up on the console--just wait about 30 seconds.


REFERENCES:
Database Use, Chpt 15, pp.162-173.  MicroFocus Publication.  2015-2016.
Using the OpenESQL Assistant, Appendix II.  pp.276-289.  MicroFocus Publication, 2015-2016.


POSTSCRIPT.
In this exercise, I was using MicroFocus Visual COBOL and Visual Studio 2019.

In its Chpt 15, Database Use publication, MicroFocus described registering a database with ODBC as follows:
From the Windows Start Menu, Select all Programs, MicroFocus Visual COBOL, Data Tools, Data Connection, ODBC Data Source Administration , etc
However, on my version of MicroFocus Visual COBOL, there is no Data Tools.  Consequently, I could not use this method to connect to the sample Library database.

Maybe there is a way around this but I could not figure it out.

Dated: December 29, 2019.