Ted Holt
Ted Holt is the senior technical editor at The Four Hundred and editor of the former Four Hundred Guru newsletter at Guild Companies. Holt is Senior Software Developer with Profound Logic, a maker of application development tools for the IBM i platform, and contributes to the development of new and existing products with a team that includes fellow IBM i luminaries Scott Klement and Brian May. In addition to developing products, Holt supports Profound Logic with customer training and technical documentation.
-
Indicate Negative Numbers with Parentheses
January 11, 2006 Hey, Ted
Thank you for a newsletter with information that is always interesting and useful. I enjoyed reading about your IIF function. Here is a function I wrote a few years back on V5R1. It returns a numeric value edited for displaying or printing that includes parenthesis when the value is negative. Our accountants prefer that negative numbers appear within parenthesis. The value returned contains two decimals, as this function is primarily used for monetary amounts.
–Glenn T. Berg, programmer/analyst
It was good of Glenn to share his EditParens function with the rest of us. I don’t blame the bean counters
-
Properly Placed Procedures
January 4, 2006 Hey, Ted
I like your IIF function. As you stated, it would be nice to replace five lines of code with one. However, I don’t want to include all the subprocedure code in every program that uses IIF. Can you give instructions on how to make this a real function or service program?
–Armando
There’s nothing unfair about Armando’s request. When I wrote the article to which he refers, I focused on the function itself rather than how to implement it. I hear quite often from readers who want to use subprocedures, but they aren’t sure how to get started. Since
-
Find the Length of a Character String in CL, Take Two
December 7, 2005 Hey, Ted
Just yesterday, I was trying to determine the length of the value of a CL variable, so your tip today using the MSGDTA trick was helpful. I was thinking that IBM had added %TRIM and %LEN to the list of CL built-in functions (BIFs) that exist in recent releases, but I guess I was imagining this. Why hasn’t IBM done this, with all the other great enhancements to CL recently? Is there a way to add your own BIFs to CL by creating your own commands?
–Flagler
I have long advocated the creation of commands to extend the CL language,
-
Editing Numbers in CL, Take Two
November 30, 2005 Hey, Ted
I just read Cletus’ tip on the editing of numbers in CL procedures, called Editing Numbers in CL. I will add these techniques to my tool kit. As always, thanks for the great stuff. Here’s another method I’ve used to remove leading blanks from numbers in CL.
–Russ
Russ’s method uses a message description that has a four-byte binary variable. Here’s how it works. (This following code is mine, not his, so any mistakes are also mine.)
Let’s use the example from the previous article. Variable &CustOrders contains the number of orders that have been added to a database file.
-
Edit Spooled Files with SEU
November 9, 2005 Hey, Ted
I read your articles on spool file manipulation. (This refers to two articles: Reading Spool Files in RPG and Page 1 of X.) Actually, it’s even easier in SEU.
–Don Rima
If the name Don Rima sounds familiar to you, it should. Don is well known for his product reviews in the iSeries edition of eServer Magazine and as the president of the Washington Area Midrange iSeries user group. Here is Don’s technique for editing a spooled file with SEU (or any other source-code editor).
1. Create a program-described non-source physical file member (unless you already have a suitable
-
Those Stupid Quotation Marks!
October 26, 2005 Hey, Ted
I am attempting to use QCMDEXC to run Open Query File within an RPG IV program but the compiler generates errors RNF0312 (A right parenthesis is expected but is not found) and RNF5347 (An assignment operator is expected with the EVAL operation). Do you see anything wrong with my code?
–PG
Here’s the free-format RPG code PG sent me. (The file and field names have been changed to protect the guilty.)
@qcmdexec('OPNQRYF FILE((MYFILE)) QRYSLT('FLD *EQ %WLDCRD("*AA*")')');
PG is trying to select all records in file MYFILE that have AA anywhere in field FLD. PG’s problem is that he (she?) has
-
Find the Length of a Character String in CL
October 19, 2005 Hey, Ted
Numerous times over the years, I’ve seen this question: How can I find the length of the value in a CL variable? That is, how many characters are in a variable, ignoring trailing blanks? I needed the answer often enough myself that I created my own “clever” way to handle it years ago by creating a RTNLEN command. But I recently discovered an alternative that’s been around forever. It uses a single command, RTVMSG, and it works for character variables up to 512 bytes long.
Here’s an example:
dcl &myvar *char 256 value('Abcd') /* Can be max *CHAR(512) */ dcl
-
Odd Ways to Round Numbers
September 21, 2005 Hey, Ted
SQL’s ROUND function allows me to round to the nearest whole number. How can I round to the nearest half?
–Chad
The ROUND function accepts two arguments–a number to be rounded and the number of decimal positions to round to. If the second argument is zero, the first argument is rounded to a whole number. If the second argument is positive, the number is rounded right of the decimal point (i.e., to tenths, hundredths, thousandths, etc). If the second argument is negative, the first number is rounded left of the decimal point (to tens, hundreds, thousands, etc).
The following example
-
Great Minds Agree: It’s Good to Save Access Paths
September 14, 2005 Hey, Ted
In your article entitled “Avoid Changed Default Values,” I believe that you are providing a disservice to your readers with your answer. Your answer to the question centers around hard-coding a default IBM value in a CL command when it should have been to remind everyone to read the IBM Memo to Users before upgrading to a new release of the operating system.
I have just finished reviewing said document and on page 38, a change is documented. Furthermore, the information provided in the article is WRONG. IBM did not change the default value of the access path (ACCPTH)
-
Let’s See Those Command Parameters
August 31, 2005 Hey, Ted
I have a CL program that builds a command in a variable, which it passes to QCMDEXC for execution. If I run the program in a job that logs CL program messages, the job log contains a nearly useless message that tells me that the “CALL command contains parameters.” Is there a way for me to make the system show me the CL command that is being executed?
–Mitch
I share your frustration, Mitch. I know of nothing in the operating system that would make the job log show the command that is being executed. If you have access to