Add 1 to COBOL Forum

Discuss Add 1 to COBOL, COBOL, OpenCOBOL and More.
OpenCOBOL » Web and CGI »
OCHTML – using copybooks for HTML Add reply Post topic
Joined: 2010-11-01 03:08:07
Comments: 0


With advent of being able to use OpenCOBOL (OC) as cgi in an internet application Aoirthoir and I have been discussing making OCHTML copybooks. This thread is an attempt to get things started.
I’ve been thinking this over for quite awhile and think I have an idea to get started.
Making the WS is no issue as I have found when doing this as you can see over at example.

Essentially you can setup the following:

01 HTML_TAGS.
05 TAG_INPUT PIC x(07) VALUE "".

Each HTML TAG can be setup this way. You’ll see the method to my madness in a little while. Keep reading.

Since each tag can have many attributes in many combinations I though it would be more prudent to create another working storage for the attributes:

01 HTML_ATTRIBUTES.
05 A_ID                           PIC x(04) VALUE "ID= ".
05 A_NAME                    PIC x(06) VALUE "NAME= ".
05 A_CLASS                    PIC x(07) VALUE "CLASS= ".
05 A_TYPE                      PIC x(06) VALUE "TYPE= ".

Now what if you want an HTML Input like this:


.

You can do this by displaying directly:


DISPLAY "".

Or using the WS you can do:


DISPLAY TAG_INPUT, A_ID, QUOTE, "my_id", QUOTE
A_NAME, QUOTE, "my_name", QUOTE,
A_CLASS, QUOTE, "my_class", QUOTE,
A_TYPE, "text", CLOSE_INPUT.

That is a generic structure proposal. We can take it even further:

01 HTML_ATTRIBUTES.
05 A_ID.
10 FILLER PIC x(04) VALUE "ID= ".
10 FILLER PIC X(01) VALUE QUOTE.
10 ws_id PCI x(35) VALUE SPACES.
10 FILLER PIC X(01) VALUE QUOTE.
10 FILLER PIC X(01) VALUE SPACE.
05 A_NAME.
10 FILLER PIC x(06) VALUE "NAME= ".
10 FILLER PIC x(04) VALUE "ID= ".
10 FILLER PIC X(01) VALUE QUOTE.
10 ws_name PCI x(35) VALUE SPACES.
10 FILLER PIC X(01) VALUE QUOTE.
10 FILLER PIC X(01) VALUE SPACE.
05 A_CLASS.
10 FILLER PIC x(07) VALUE "CLASS= ".
10 FILLER PIC x(04) VALUE "ID= ".
10 FILLER PIC X(01) VALUE QUOTE.
10 ws_class PCI x(35) VALUE SPACES.
10 FILLER PIC X(01) VALUE QUOTE.
10 FILLER PIC X(01) VALUE SPACE.
05 A_TYPE.
10 FILLER PIC x(06) VALUE "TYPE= ".
10 FILLER PIC x(04) VALUE "ID= ".
10 FILLER PIC X(01) VALUE QUOTE.
10 ws_type PCI x(35) VALUE SPACES.
10 FILLER PIC X(01) VALUE QUOTE.
10 FILLER PIC X(01) VALUE SPACE.

Now you can do:

MOVE "my_id" to ws_id.
MOVE "my_name" to ws_name.
MOVE "my_class" to ws_class.
MOVE "text" to ws_type.
DISPLAY TAG_INPUT, A_ID, A_NAME, A_CLASS, A_TYPE, CLOSE_INPUT.

Thoughts? Comments? Praise, glory?

Creative Commons License This content is published under the Attribution-Share Alike 3.0 Unported license.

Report as:
Message (optional):

Close Form
Reply