[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [open-cobol-list] tree data, embedding a language or string interpol

From: john Culleton
Subject: Re: [open-cobol-list] tree data, embedding a language or string interpolation?
Date: Sun, 17 Mar 2013 11:10:27 -0400

On Fri, 15 Mar 2013 17:41:11 -0400 Patrick
<address@hidden> wrote:

> With Jim's help I am working on a web application written in
> Cobol.  It will likely take me some time and I will do it in
> stages. The first stage is going to be an offline webpage
> generator and in doing so, the first obstacle is the templating
> engine. I will just upload static after it's done.
> Cobol is good for lots of things but in seems to me that at
> it's core it is Awk on steroids. It is really good for tabular
> data but what about tree data.  I can chop up a tree based
> webpage into "square snippets" but it would be nice to have
> other options. The best option is a way to parse HTML from
> Cobol but baring that string interpolation would solve the
> problem too.
> So for instance with "<title> $title </title>" the variable
> $title is inserted into the string, no need for concatenation.
> If Cobol does not support this, I was thinking of embedding
> another language that supports it.
> Python and Lua do not support this.  PHP and Perl do but I'd
> rather not Ruby, Tcl, Falcon and Vala support this.
> Ruby can interact with C but it's normally to extend Ruby.
> mruby is being designed to be embedded and will compete with
> Lua but it's not ready yet.
> I like Tcl and I like jimsh but Tcl is slightly quirky.  I
> don't know much about Flacon but Brian does and he already has
> samples of how to use it with Cobol Ditto for Vala
> Any feedback would be appreciated-Patrick

In my salad days I wrote an app that would cumulate costs up a
tree representation of a bill of material. The record groups of a
bill of material in those days consisted of a header record with
info about the assembly itself including cost followed by detail
records referencing each part or operation that went into that
assembly. The detail records often referenced a subassembly so
the whole shebang formed a logical tree structure. In 1969 or so
when I wrote this I did the whole thing with flat files but since
that time I have written other programs for cumulation using
indexed sequential files. One trick was to have a key to each
record consisting of a long primary key redefined as the current
assembly or part identifier and the sub part's identifier. Thus
one could navigate the tree either by  the primary key or the
subordinate key. 

02 main-key pic x10.  
02 sub-area redefines main-key.  
  03 primary-number pic x(5).  
  03 sub-number pic x(5).

This takes up 10 bytes total. main-key is the primary key (must
be unique) and primary-number and sub-number are alternate keys
that allow for duplication.

In a web page there are references to other pages and references
to css items in a separate file or files. It would not be to
dificult to decompose a page and its subordinate pages into a
tree structure as I have described it. Is that what you have in
mind? Or does tree structure mean something else to you?

For handling a statement like <title> foobar </title>

the string and unstring statements make this a piece of cake.

COBOL is not like AWK. COBOL is a file handling and data
manipulation language of immense power. Suggest you study some
real-world programs a while. The textbooks etc. define the nuts
and bolts but not how to put them together in a real-woorld
application.  Vince Coen's Applewood system is a good example to

-- John Culleton 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]