Those of you who have followed our writings (ramblings?) for a while know that we have a kind of love-hate relationship with CL. The syntax, while effective for commands, just feels clunky and unnatural when used for an entire program. Back in the pre-RPG IV days we would begrudgingly call CL programs to do the stuff that we just couldn't do in RPG. But as RPG IV evolved, and the number of system APIs increased, there was less and less that we couldn't do directly in RPG. Combine that with the fact that CL effectively stagnated for many years and there was little to convince us otherwise, hard as CL aficionados such as Bruce Vining and Jim Sloan tried to convince us.
But things have changed. Under the stewardship of Guy Vig, CL has been given a new lease on life with enhancements in many areas. It started back in OS/400 V5R3 with additions to the types of variables that could be defined, new looping and control structures, increases in the number of files that could be declared and more. The enhancements continued in V5R4 with the addition of subroutines and enhancements to data definition that effectively provided a form of data structure (DS) definition. Since having to use string/substring operations to fake out DS definitions was one of our pet peeves in CL, this was a big step forward. IBM i 6.1 continued the forward movement with the addition of INCLUDE, the equivalent of RPG's /COPY. It also finally added a CLOSE command--now you can actually close a file that has been opened in the CL program and open another (or the same) file in the program without performing unnatural acts.
Now with the latest round of PTFs to 7.1 a number of our remaining frustrations have been addressed and we really have been forced to start to take more notice of this IBM i stalwart. To use this new CL functionality on a 7.1 system, PTF SI49061 must be loaded and applied*. Note that support is _not_ going to be PTF'd to the 6.1 or 5.4 releases, but you will be able to compile CL code that uses these new functions on your 7.1 system by specifying the appropriate target release (TGTRLS) value.
These latest enhancements provide some major upgrades to CL's string handling capabilities. Even better, because they are almost identical in name and operation to their RPG equivalents, there's nothing much new to learn. The new functions are:
%CHECK - Check Characters
%CHECKR - Check Reverse
%SCAN - Scan for Characters
%TRIM - Trim Characters at Edges
%TRIML - Trim Leading Characters
%TRIMR - Trim Trailing Characters
These new built-ins can be used wherever CL would permit the use of an expression of the same type. For example %CHECK can be used in an IF or WHEN command. %TRIM (and its variants) can be used directly in a character expression (e.g., CHGVAR VAR(&ADDRESS) VALUE(%TRIM(&STREETNAME) *BCAT %TRIM(&CITY)) ) or to set the value of any command parameter that permits expressions (i.e. ,the parameter is specified as EXPR(*YES) ). You can get more details on the %TRIMx functions here and on the %CHECKx and %Scan functions here.
We understand more enhancements are planned for CL in the future, but nobody will actually tell us what they are yet so we'll all have to wait. What is clear though is that the days of CL as a stagnant, unchanging language are over and that we really need to start paying more attention to it.
Many thanks to Guy and the CL team!
* Note: The %Trim functions were actually snuck in via PTF back in October 2012 but went largely unnoticed.
But things have changed. Under the stewardship of Guy Vig, CL has been given a new lease on life with enhancements in many areas. It started back in OS/400 V5R3 with additions to the types of variables that could be defined, new looping and control structures, increases in the number of files that could be declared and more. The enhancements continued in V5R4 with the addition of subroutines and enhancements to data definition that effectively provided a form of data structure (DS) definition. Since having to use string/substring operations to fake out DS definitions was one of our pet peeves in CL, this was a big step forward. IBM i 6.1 continued the forward movement with the addition of INCLUDE, the equivalent of RPG's /COPY. It also finally added a CLOSE command--now you can actually close a file that has been opened in the CL program and open another (or the same) file in the program without performing unnatural acts.
Now with the latest round of PTFs to 7.1 a number of our remaining frustrations have been addressed and we really have been forced to start to take more notice of this IBM i stalwart. To use this new CL functionality on a 7.1 system, PTF SI49061 must be loaded and applied*. Note that support is _not_ going to be PTF'd to the 6.1 or 5.4 releases, but you will be able to compile CL code that uses these new functions on your 7.1 system by specifying the appropriate target release (TGTRLS) value.
These latest enhancements provide some major upgrades to CL's string handling capabilities. Even better, because they are almost identical in name and operation to their RPG equivalents, there's nothing much new to learn. The new functions are:
%CHECK - Check Characters
%CHECKR - Check Reverse
%SCAN - Scan for Characters
%TRIM - Trim Characters at Edges
%TRIML - Trim Leading Characters
%TRIMR - Trim Trailing Characters
These new built-ins can be used wherever CL would permit the use of an expression of the same type. For example %CHECK can be used in an IF or WHEN command. %TRIM (and its variants) can be used directly in a character expression (e.g., CHGVAR VAR(&ADDRESS) VALUE(%TRIM(&STREETNAME) *BCAT %TRIM(&CITY)) ) or to set the value of any command parameter that permits expressions (i.e. ,the parameter is specified as EXPR(*YES) ). You can get more details on the %TRIMx functions here and on the %CHECKx and %Scan functions here.
We understand more enhancements are planned for CL in the future, but nobody will actually tell us what they are yet so we'll all have to wait. What is clear though is that the days of CL as a stagnant, unchanging language are over and that we really need to start paying more attention to it.
Many thanks to Guy and the CL team!
* Note: The %Trim functions were actually snuck in via PTF back in October 2012 but went largely unnoticed.
Connect With Us: