IBM i > DEVELOPER > GENERAL

QR Codes on IBM i


You may have noticed QR codes, the new phenomenon that seems pervasive lately. QR is short for Quick Response, and QR codes are in the bar-code family. To learn more, it might be best to head over to Wikipedia and take a quick read of the initial paragraph. On that page, you’ll also see a sample QR code that gives some visual details concerning how those many white and black blocks work together to hold information.

I didn’t pay QR codes much attention until my co-worker Jeff Skistad wrote a blog entry about them just recently. It was then that I started digging deeper to see what the fuss was about, and I subsequently installed a free Android app named Barcode Scanner, which works really well. The app uses the video capabilities of my phone to look for a QR code within any portion of the current viewing area. Once it gets a read on the reference points of the QR code it displays the text result to my screen. What’s crazy is I’ve been reading QR codes that are displaying right on my monitor! (Don’t ask me why that excites me; it just does.)

RPG Programmers Need QR Too

I see many potentials for QR codes. But what good is it to us RPG programmers unless they’re easy to create? I started looking for open-source Java solutions that could be ported to IBM i and subsequently have a RPG layer put over them and I quickly found the ZXing project on Google’s code site and subsequently downloaded it.

Dissecting ZXing

The ZXing project is delivered in a single ZIP file that has many different collections of folders for various implementations of ZXing including JavaSE (desktop edition), JavaME (mobile/micro edition), iPhone (ObjectiveC) and C#.NET. This isn’t a normal distribution of an open-source project so I had to do a little guessing and determined I would dig around in the JavaSE folder to see what I could find for example code. It turns out there weren’t really any good example programs, which surprised me, so I was back off to Google to see if others had a simple “hello world” type app I could get up and running quickly. Code Sample 1 shows what I eventually ended up with for a simple Java program that has example strings showing how to generate a variety of QR codes based a regular string values. As you can see, I’m declaring a variable named “text” as a String multiple times, but the last one is the only “live” line of code (two slashes before a line in Java means the same thing as in RPG; it’s a comment). I obtained several of these ideas from the ZXing wiki where they described the possibilities for Barcode Contents.

Aaron Bartell is Director of IBM i Innovation for Krengel Technology Inc. and an IBM Champion.


comments powered by Disqus

Advertisement

Advertisement

2017 Solutions Edition

A Comprehensive Online Buyer's Guide to Solutions, Services and Education.

Are You Multilingual?

Rational enables development in multiplatform environments

IBM Systems Magazine Subscribe Box Read Now Link Subscribe Now Link iPad App Google Play Store
IBMi News Sign Up Today! Past News Letters