MC Press Online

Sunday, Jan 22nd

Last updateThu, 19 Jan 2017 7am

You are here: Home ARTICLES Programming


TechTip: Trees Are Good for Climbing and More

Aaron Bartell

The “tree” command can quickly show you the structure of an IFS directory, but it’s not installed in PASE by default. Learn how to get it.

Written by Aaron Bartell

My days are in large part spent in the PASE environment on IBM i. PASE is based on AIX, and both are Linux-like in their abilities, though PASE does not contain many commands and utilities that I'd consider on the "need" list. Sometimes I'm also doing things on Linux systems and get exposed to utilities and commands that I then desire to have on PASE. Such was the case the other day when I was writing my "PASE Intro" lab for COMMON Spring 2017. I needed to print out a directory listing of parent and child directories, and I knew the Linux “tree” command would foot the bill. Well, I quickly learned it didn't exist in PASE, so this article will convey the steps I took to get it onto PASE.

Read more ...

TechTip: DB2 Access for PHP

David Shirey

Last month, we looked at three ways you can access data files in PHP: mysql_*, mysqli_*, and the PDO API set. But there is one more option. Bet you can’t wait to see what it is.

Written by Dave Shirey  

One of the primary reasons for involving PHP in our otherwise pure RPG ILE /free world is to allow us to develop apps that have a GUI interface yet access data from our DB2 (or whatever) database.

Database access in PHP is done via an API set that contains the commands necessary to connect to your database (remember, PHP runs on the server while your database is probably local or at the very least not on the same server as PHP is running in) and then access and return the required information to the PHP program.

Read more ...

RPG Academy: Write Better Code - More on Commenting and Documenting Strategies

Rafael Victória-Pereira

This TechTip will continue to discuss the documentation topic, focusing on the tools that an RPG programmer has available and offering a few tips to help define a proper documentation strategy (even if you think you don’t need one).

Written by Rafael Victória-Pereira

One of my favorite things about “modern” languages is the self-documenting features that most of them have. For instance, Java has Javadoc, a documentation generator from Oracle Corporation that is designed to automatically produce documentation in HTML format from Java source code. The HTML format is used to add the convenience of being able to hyperlink related documents together. The “doc comments” format used by Javadoc is the de facto industry standard for documenting Java classes. Some Integrated Development Environments (IDEs), such as NetBeans and Eclipse, automatically generate Javadoc HTML code. There are a lot of file editors to assist the developer in producing Javadoc source and using the Javadoc information as internal references for the programmer. This made me wonder if we, RPG programmers, had been forgotten by IBM in this regard.

Read more ...

Practical SQL: Field Reference Files in DDL

Joe Pluta

SQL does field reference files, too!

Written by Joe Pluta

In a previous article, I discussed how naming conventions really help in database design and programming, and in so doing I touched upon the concept of the field reference file. Field reference files are an easy way to make sure your data elements are consistent, but I'll bet you didn't know you could use them in DDL as well. In this article, I'll show you how it's done.

Read more ...

SQL 101: Tools of the Trade - i Navigator’s Run SQL Scripts

A more “modern” alternative to STRSQL, discussed in the last two articles, is the i Navigator’s Run SQL Scripts tool. Let’s explore it together, shall we?

rafael victoria preiraWritten by Rafael Victória-Pereira

While STRSQL is a green-screen tool, Run SQL Scripts is part of the i Navigator package. You can access it by choosing the Run SQL Scripts option, either from the bottom-right pane of the i Navigator window after you’ve chosen the Databases tree node from the right panel, as shown in Figure 1, or by right-clicking the database name and choosing the respective option.

Read more ...

Practical RPG: Processing Stream Files, Part 2

In part 1, we processed a directory. In part 2, we process one file in that directory.

joe plutaWritten by Joe Pluta

Stream files are not database files.

While that statement is obvious to programmers, it's not always clear to the greater community. The end users, the folks whose jobs we are supposed to be supporting, use various forms of stream files to store their data, and they don't understand why we can't for example just "use this spreadsheet" as part of our application. And while that's an interesting philosophical discussion, as programmers we sometimes have to simply get things done, and that in turn means taking whatever data the user sent us. I've spent a lot of time over the years importing data primarily from Exceland more specifically from comma-delimited files. Two techniques exist: CPYFRMIMPF and parsing the data in RPG. CPYFRMIMPF is a completely different animal that perhaps can be covered another day. Today, I just want to talk about parsing a stream file.

Read more ...

RPG Academy: Write Better Code - Commenting and Documenting Strategies

Usually, programmers don’t comment their code appropriately, for a variety of reasons: “I don’t have the time,” “My code speaks for itself,” etc. Mostly, they simply hate doing it. Let me try to refute these excuses with practical strategies and tools.

 rafael victoria preiraWritten by Rafael Victória-Pereira

As I’ve said throughout this series, a procedure’s name and parameter list should be enough for the programmer to understand the objective of that piece of code. However, there are times when this is not enough: complex procedures, generic names, uninspired input/output parameter names…and the list goes on and on. The next section of this TechTip will help you in the process of creating proper documentation for your newly created procedures and functions, with a few tips of what you should and shouldn’t do.

Read more ...

TechTip: PDO for PHP

Why do we use PHP with an HTML web page? Lots of reasons, but data access is one of the most important, and PHP Data Objects (PDO) is, for me, the best way to do that.

david shireyWritten by David Shirey

There are lots of web languages out there, aren’t there? HTML5, JavaScript, PHP, CoyoTE. I actually don’t know if that last one exists, but given the number of special languages available for the web, I think I’ve got a 50-50 chance.


And increasingly, on the IBM i, we are being introduced toand find reasons to usemore and more of these languages. Each has its own list of things that it does well and things that it doesn’t.

Read more ...