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 





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

Comments

Popular posts from this blog

Spatial Data Management For GIS and Data Scientists

  Videos of the lectures taught in Fall 2023 at the University of Tennessee are now available as a YouTube playlist. They provide a complete overview of the concepts of GeoSpatial science using Google Earth Engine, PostgresSQL GIS , DuckDB, Python and SQL. https://www.i-programmer.info/news/145-mapping-a-gis/16772-spatial-data-management-for-gis-and-data-scientists.html

Microsoft Goes All Out On Educating Developers

  What better way to lure devs into the platform than to provide clear how-to instructions and deep educational material? Over the last couple of years, but especially during 2023, Microsoft has pumped up its educational facilities on . NET. For instance, it has released a number of self-paced projects we here at I Programmer have covered, such as: https://www.i-programmer.info/news/89-net/16857-microsoft-goes-all-out-on-educating-developers.html