Did you know you can use a single code base for multiple incompatible MV DBMS platforms? Most developers only care about coding to a single platform but many of us support many platforms. Those who do support multiple platforms have their own preferred way of maintaining their code.
Some developers have a completely unique code base for each platform. Some developers put all platform-specific blocks of code into separate include items. We use XBASIC as part of our development toolkit, and there is a single code base with most code in-line for all supported DBMS products.
Here is an example, where Unidata supports the UNASSIGNED() function but all other platforms use the opposite ASSIGNED() function:
IF UNASSIGNED(NEBULA.INITIALIZED) THEN
IF NOT(ASSIGNED(NEBULA.INITIALIZED)) THEN
NEBULA.INITIALIZED = 1
The code within both !IF/!END blocks is uncommented. XBASIC gets the target platform and comments out code for all others. In the above example, this means one of the IF statements will be commented and the other will be compiled, this creating a valid IF/THEN/END block.
After we run XBASIC on source it gets copied to the target platform where it’s compiled. Changes are made on the target system until the code works. Then all changes are ported back to the original code base, and platform-specific code is surrounded by !IF/!END blocks as required. Then we XBASIC, copy, compile, and test all over again until we’re satisfied that the functionality is consistent with all other platforms.
The default XBASIC code looks for #IF and #END, but I changed it to !IF/!END so that I can test-compile code. #IF/#END will cause compilation to always fail unless I use XBASIC first, but !IF/!END will allow a program to compile if the rest of the syntax is correct for the current platform.
XBASIC was written by Kevin King at Precision Software and is available for free along with documentation here.
For larger blocks of code we have a single subroutine that gets called by all platforms, NRND.DBMS.SUBS. In this code the target platform is identified and a platform-specific subroutine is called, named NRND.DBMS.SUBS.PPP, where PPP is the platform code. Since the platform-specific subroutines don’t compile on systems other than their target, the object code for the subroutines is not present in any platform other than the target. For example: only the QM system will have NRND.DBMS.SUBS.QM.