Skip to main content

4GL's virtues (Part 1) Extensibility with C

One of 4GL's virtues is it's extensibility with C. You can call custom C programs from within 4GL code and pass values between them byval or byref.
Is there something that cannot be done by using 4GL? you need to interact with the OS? do you want do to something more advanced? Call C to the rescue.

A trivial example is generating random numbers, ie random - generic serial numbers. There is a session directive supported by Ingres that sets the seed so it makes it easy to fill a tablefield with random numbers (a part of a larger code sample follows) :


set random_seed


while rowno <= quantity do

loadtable cylki (sn = 'GE'+ varchar(random()));

rowno = rowno + 1;

endwhile;



Which loads a tablefield with as many SN's as the quantity variable directs.

But the set random_seed directive and the random function are supported on Ingres 2.6 onwards.What to do with older Ingres version? Replace functionality by calling a C program.

So the 4GL code now becomes :

while rowno <= quantity

callproc get_rnumber (byref(h_randno),rowno);

loadtable cylki (sn = 'GE'+varchar(h_randno));

rowno = rowno + 1;

endwhile;


And the get_rnumber C program :

#include
#include
#include

get_rnumber(unsigned int *randno,int rowno)
{
srand((unsigned int) time(0)+rowno);
*randno = rand();
}






Hence achieving the same functionality.
I think this is one of 4GL's greatest virtues : plug in ability

Comments

Popular posts from this blog

Insider's Guide To Udacity Android Developer Nanodegree Part 3 - Making the Baking App

Continuing to chart my experience of Udacity's Android Developer Nanodegree we step up in level, embarking on the advanced part of the super-course.
Completing project "Popular Movies" (see Part 2 of this series) signaled the end of "Android Developer". Now we are ready to tackle the second element of the program "Advanced Android Developer", a new class with a new syllabus and project. Continuing to chart my experience of Udacity's Android Developer Nanodegree we step up in level, embarking on the advanced part of the super-course.

Completing project "Popular Movies" (see Part 2 of this series) signaled the end of "Android Developer". Now we are ready to tackle the second element of the program "Advanced Android Developer", a new class with a new syllabus and project.

"Advanced Android Developer" is a mixed bag of self contained material and of coding seven different sample apps to learn about the…

JSON Feed - The New RSS?

SON Feed is a new take on the web syndication format, but unlike RSS and Atom it's in JSON, not XML. So what does it try to do better?

Mainly overcome the perils of XML; it's complex, heavyweight, difficult to parse and not in sync with the current trend wanting web data exchange happening almost exclusively in JSON document representation.

In contrast, JSON is easier to both write and parse, manipulate and consume, especially given that its data types are exact reflections of their native Javascript counterparts.
Devised by Brent Simmons, the original developer of the popular NetNewsWire and Manton Reece creator of Micro Blogs, both with a great background on publishing with RSS, it's a certainty that JSON Feed will emerge as a strong competitor to both Atom and RSS, being based upon their decade long experience on decentralized formats.

On top of that it also tries to tackle a few other issues plaguing RSS, mainly the lack of realtime client notification whe…

Grimoire Lab-GitHub - Stats On Steroids

Grimoire Lab is an open source toolkit built on Python, Elasticsearch and Kibana. It taps into GitHub's raw data through Perceval, a module designed for retrieving data from repositories related to software development.

Perceval forwards the data to another tool for filtering, the so called Sorting Hat, responsible for managing and merging identities that correspond to the same real person/commiter and potentially come from different sources, before finally rendering the data manageable and accessible through rich UI Kibiter dashboards. Kibiter, a fork of Kibana, is what enables the user to create and edit visualizations as well as perform queries facilitated by the underlying Elasticsearch REST APIs.

full article on i-programmer.info