Welcome!

ColdFusion Authors: Yakov Fain, Maureen O'Gara, Nancy Y. Nee, Tad Anderson, Daniel Kaar

Related Topics: ColdFusion

ColdFusion: Article

Five Cool Things I've Done with ColdFusion

Mailing labels, bar codes, credit cards, and graphing

I'm at my best when I'm challenged. In my consulting business I tend to gravitate towards small businesses with delusions of grandeur. I want to be the one to help them realize their vision and turn their delusion into reality. Looking back, this has been an interesting week. I thought I'd share some of the interesting things I've done and how ColdFusion helped make them possible.

Monday: Bar Codes
I've been working over the past year to Web enable an MS Access based scheduling system. One item of the application generates attendance cards with a bar code on it for all users. When a user shows up for a class, that user will scan in, and the information is used to track attendance. The client wanted to be able to generate the attendance cards (with bar codes) from the Web. How do you do that?

First, you have to realize what bar codes are. They are just text, or data of some sort, that looks like a bunch of parallel lines. If you don't know what I mean, just flip over your copy of ColdFusion: The Complete Reference, and you'll find one. (Or you can look at any book or CD). These bar codes are generated using a special font. The client provided me with the font, named "3 of 9 Barcode." A simple Web search will reveal many places where you can get this font. I recommend downloading it straight from the source at www.squaregear.net/fonts/free3of9.shtml.

Now you're probably thinking that since you have the font name, you can just use the HTML font tag like this: <font name="3 of 9 Barcode">My Bar Code</font>

And you don't even have to use ColdFusion, right? Well, you're on the right track, but things aren't that simple. The first mistake is that you need to put an asterisk (*) before and after the text you want to be able to scan as a bar code. Even with that tidbit of information, you still aren't in the clear. For this approach to work, the bar code font must be installed on the client computer.

When you use a font in HTML like that, that font must be installed on the client computer (not the server), or else a default font is used. The resulting bar code won't scan if it's generated using Helvetica or Times New Roman. (You can trust me on that one.) This font is not a standard font installed on most users computers. Expecting it to be isn't a realistic expectation for Web development. Most people don't have uses for Bar Code fonts in their daily activities. Getting the bar code font installed on all relevant clients of your system would bring you back to the old days of client/server technology where you have to walk through a big dark office building with fluorescent lighting and spend months installing things so the requirements change by the time you're finished with the roll out. There must be a better way, right? Yes!

The answer is to use the ColdFusion Report Builder to generate the attendance cards with bar codes. First, install the bar code font on your development machine and on your production (and/or testing) server. Then, create a new report (or open an existing report). Create a field and give it an expression something like this:

"*" & barcodedata & "*"

In the properties dialog, you should see the 3 of 9 Barcode font listed in the Font name list, as shown in Figure 1. Select that font and your field will look like a bar code. Above the font selection, there is another option for "embedded font." Be sure to select true for this option. Normally, you wouldn't want to embed fonts in a PDF because it makes the overall file size larger, but then you have to ensure that the client computer has the font installed, or it will default itself. Since we don't want to make sure that the client computer has the bar code font installed (for reasons discussed earlier), we embedded it here.

To test the bar codes, you have to scan them. I used a CueCat. The CueCat company has a long disastrous history which results in CueCat scanners being an extremely cheap buy on eBay. Perform a Web search for all the gory details; they are beyond the scope of this article.

Tuesday: Mailing Labels
The mid-week point brought another challenge from above. A client wanted to be able to generate mailing labels. Doing this sort of task with HTML is grueling, tedious, and prone to errors. Especially since different browsers can display the same HTML code in different ways. HTML is not designed for print, and forcing what is on screen to line up with what is on your label sheet is going to be the cause some serious headaches. So, what are the options?

I turned once again to my new best friend, the CF Report Builder. The nice man, Dean, at cfreport.org (no last name is known, but I get the impression he works for Adobe) has created a label wizard for the ColdFusion Report Builder. You can download the wizard at www.cfreport.org/index.cfm?mode=entry&entry=38BBAD81-3048-2D03-0A777CDC2FB60D74. You'll need to have at least 7.01 of the Report Builder installed (and I recommend getting the 7.02 update). In my case, I already had the wizard installed. Since I don't remember installing it, it may have been included in the 7.02 update of the Report Builder. Check your install and you may not have to worry about manually downloading and installing the wizard.

You can find out if you have the label wizard installed by selecting File ‡ New. You should see the Label Creation Wizard as an option in the new dialog, as shown in Figure 2. Select the label creator wizard and click next.

You'll see the first step in the Label Creation Wizard, as shown in Figure 3. Select the label template you want to use. Most labels are based on some form of Avery label template (My client asked for 5160). Select that and click next.

Now you have to define the query fields you want to use to display information on your label, as shown in Figure 4. I manually entered them (The query builder button didn't work for me). Click the next button

The final step in the report builder is to define the layout of your label. Double-click the elements in the left window, and they'll be entered in the right window. The right window is an expression window, but you don't have to worry about writing an expression, because when you click the finish button, text (such as commas) will automatically be escaped when creating the finished template. Save your template and you're good to go.

The last step in the Report Builder is just to run the report using the cfreport tag. Your template will look something like this:

<cfquery name="Getusers" datasource="myDSN">
select firstName, LastName, State, City,. Zip
from users
</cfquery>

<cfreport format="PDF" template="LabelReport.cfr" query="Getusers">
</cfreport>

Your query will most likely be different, depending on the information you want to print on a label, but you should be able to apply these concepts to your own development.

Wednesday: Credit Card Swipes
One of my clients runs an e-commerce business, and the site implementation is about as classic as an on-line shopping cart can come. The client is in the process of opening up a retail store, and I spent some time modifying the shopping cart to accommodate retail transactions. The biggest difference between retail transactions and Web-based transactions is that you have a credit card to swipe. Swiped cards get a much better merchant rate than Internet or phone orders received, so that is an added benefit of the retail store vs. the Internet store.

The client provided me with a USB credit card swiper so that I could test the process. As far as the computer is concerned, the swiper is not much different than a keyboard; you just get a bunch of data in one scan instead of having to type it out manually. The scanned data is sent to the active program running on your machine. This can be notepad (which is great for testing) or the active form field on a Web browser. I used the latter to integrate into their Web based shopping cart.

The data contained on a credit card consists of the card number, some bank routing information, the customer's name, and other miscellaneous information. More details on the specifics of the credit card swipe data are at http://money.howstuffworks.com/credit-card1.htm. To process the credit card data you don't need to know the specifics of what it is. The PayFlow Pro Web API has a field for sending swipe data, so it's easy to send it off the transaction and receive information back just as you would a normal Web transaction. I would expect that most payment processors have a similar option.

Thursday: Processing Bar Codes and Credit Card Swipes
Now that the bar codes were generated, the client wanted to be able to process scanned bar codes in the Web browser. The CueCat, like other bar code readers, operates in the same manner that the credit card scanner does. When you swipe a card or scan a bar code, the scanned (or swiped) information goes to the active screen. If you have a Web browser open, it will go to the selected form field. To start the input page, first we'll need the form:

<form action="BarCodeSCanner.cfm" method="post" name="BarCodeScanner" id="BarCodeScanner">
Scanned Info: <input type="text" name="ScannedInfo">
</form>

This is a form that will submit back onto itself. The form has one input field, with no submit button. For attendance purposes in the scheduling system, the scan had to be as painless as possible without any user interaction, so the form is submitted through JavaScript.

How does the browser know we've scanned something? How do we know when to submit? The answer is through the use of a JavaScript timer. The timer is a JavaScript that counts down from some number to 0. When it reaches 0, it checks whether there is data in the ScannedInfo field (or not) and then submits the form if there is.

I used the JavaScript code located at www.mcfedries.com/JavaScript/timer.asp as a base for this. (Much thanks to Paul McFedries' for his assistance). For space reasons, I'll refrain from copying the full script here. There are four variables to take into account:

  • Secs: The secs variable specifies how many clock ticks until the timer reaches 0. This will count down from the initial value to 0.
  • Delay: This is the amount of milliseconds before the timer checks its next status. 1000 milliseconds are equal to one second, so that is the default.
  • TimerID: The timerID is a variable internal to the script. It specifies when the next clock tick will occur.
  • TimerRunning: The timerRunning variable is a Boolean value that tells us whether the timer is running or not. For all intents and purposes, it is internal to the script and you don't need to worry about it.

    There are three functions that make up the timer:

  • InitializeTimer: The initialize timer function sets the secs variable, stops the timer (if currently running), and then starts the timer.
  • StopTheClock: The stop the clock function runs some script to prevent the clock from running.
  • StartTheTimer: The StartTheTimer function is the meat of the execution. It counts down from the clock tick and executes certain code if the count down is done, or moves onto the next clock tick. Of these three functions, it is the StartTheTimer function that needs a more in depth examination.
function StartTheTimer(){
   if (secs==0){
    StopTheClock()
    if (document.BarCodeScanner.ScannedInfo.value != ''){
     document.BarCodeScanner.submit();
     } else {
      InitializeTimer();
     }

    }else {
     secs = secs - 1
     timerRunning = true
      timerID = self.setTimeout("StartTheTimer()", delay)
   }
}

More Stories By Jeffry Houser

Jeffry is a technical entrepreneur with over 10 years of making the web work for you. Lately Jeffry has been cooped up in his cave building the first in a line of easy to use interface components for Flex Developers at www.flextras.com . He has a Computer Science degree from the days before business met the Internet and owns DotComIt, an Adobe Solutions Partner specializing in Rich Internet Applications. Jeffry is an Adobe Community Expert and produces The Flex Show, a podcast that includes expert interviews and screencast tutorials. Jeffry is also co-manager of the Hartford CT Adobe User Group, author of three ColdFusion books and over 30 articles, and has spoken at various events all over the US. In his spare time he is a musician, old school adventure game aficionado, and recording engineer. He also owns a Wii. You can read his blog at www.jeffryhouser.com, check out his podcast at www.theflexshow.com or check out his company at www.dot-com-it.com.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@ThingsExpo Stories
The definition of IoT is not new, in fact it’s been around for over a decade. What has changed is the public's awareness that the technology we use on a daily basis has caught up on the vision of an always on, always connected world. If you look into the details of what comprises the IoT, you’ll see that it includes everything from cloud computing, Big Data analytics, “Things,” Web communication, applications, network, storage, etc. It is essentially including everything connected online from hardware to software, or as we like to say, it’s an Internet of many different things. The difference ...

ARMONK, N.Y., Nov. 20, 2014 /PRNewswire/ --  IBM (NYSE: IBM) today announced that it is bringing a greater level of control, security and flexibility to cloud-based application development and delivery with a single-tenant version of Bluemix, IBM's platform-as-a-service. The new platform enables developers to build ap...

Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world.
An entirely new security model is needed for the Internet of Things, or is it? Can we save some old and tested controls for this new and different environment? In his session at @ThingsExpo, New York's at the Javits Center, Davi Ottenheimer, EMC Senior Director of Trust, reviewed hands-on lessons with IoT devices and reveal a new risk balance you might not expect. Davi Ottenheimer, EMC Senior Director of Trust, has more than nineteen years' experience managing global security operations and assessments, including a decade of leading incident response and digital forensics. He is co-author of t...
The major cloud platforms defy a simple, side-by-side analysis. Each of the major IaaS public-cloud platforms offers their own unique strengths and functionality. Options for on-site private cloud are diverse as well, and must be designed and deployed while taking existing legacy architecture and infrastructure into account. Then the reality is that most enterprises are embarking on a hybrid cloud strategy and programs. In this Power Panel at 15th Cloud Expo (http://www.CloudComputingExpo.com), moderated by Ashar Baig, Research Director, Cloud, at Gigaom Research, Nate Gordon, Director of T...
Explosive growth in connected devices. Enormous amounts of data for collection and analysis. Critical use of data for split-second decision making and actionable information. All three are factors in making the Internet of Things a reality. Yet, any one factor would have an IT organization pondering its infrastructure strategy. How should your organization enhance its IT framework to enable an Internet of Things implementation? In his session at Internet of @ThingsExpo, James Kirkland, Chief Architect for the Internet of Things and Intelligent Systems at Red Hat, described how to revolutioniz...
Technology is enabling a new approach to collecting and using data. This approach, commonly referred to as the "Internet of Things" (IoT), enables businesses to use real-time data from all sorts of things including machines, devices and sensors to make better decisions, improve customer service, and lower the risk in the creation of new revenue opportunities. In his General Session at Internet of @ThingsExpo, Dave Wagstaff, Vice President and Chief Architect at BSQUARE Corporation, discuss the real benefits to focus on, how to understand the requirements of a successful solution, the flow of ...
The security devil is always in the details of the attack: the ones you've endured, the ones you prepare yourself to fend off, and the ones that, you fear, will catch you completely unaware and defenseless. The Internet of Things (IoT) is nothing if not an endless proliferation of details. It's the vision of a world in which continuous Internet connectivity and addressability is embedded into a growing range of human artifacts, into the natural world, and even into our smartphones, appliances, and physical persons. In the IoT vision, every new "thing" - sensor, actuator, data source, data con...
"BSQUARE is in the business of selling software solutions for smart connected devices. It's obvious that IoT has moved from being a technology to being a fundamental part of business, and in the last 18 months people have said let's figure out how to do it and let's put some focus on it, " explained Dave Wagstaff, VP & Chief Architect, at BSQUARE Corporation, in this SYS-CON.tv interview at @ThingsExpo, held Nov 4-6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
Focused on this fast-growing market’s needs, Vitesse Semiconductor Corporation (Nasdaq: VTSS), a leading provider of IC solutions to advance "Ethernet Everywhere" in Carrier, Enterprise and Internet of Things (IoT) networks, introduced its IStaX™ software (VSC6815SDK), a robust protocol stack to simplify deployment and management of Industrial-IoT network applications such as Industrial Ethernet switching, surveillance, video distribution, LCD signage, intelligent sensors, and metering equipment. Leveraging technologies proven in the Carrier and Enterprise markets, IStaX is designed to work ac...
"There is a natural synchronization between the business models, the IoT is there to support ,” explained Brendan O'Brien, Co-founder and Chief Architect of Aria Systems, in this SYS-CON.tv interview at the 15th International Cloud Expo®, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
C-Labs LLC, a leading provider of remote and mobile access for the Internet of Things (IoT), announced the appointment of John Traynor to the position of chief operating officer. Previously a strategic advisor to the firm, Mr. Traynor will now oversee sales, marketing, finance, and operations. Mr. Traynor is based out of the C-Labs office in Redmond, Washington. He reports to Chris Muench, Chief Executive Officer. Mr. Traynor brings valuable business leadership and technology industry expertise to C-Labs. With over 30 years' experience in the high-tech sector, John Traynor has held numerous...
Bit6 today issued a challenge to the technology community implementing Web Real Time Communication (WebRTC). To leap beyond WebRTC’s significant limitations and fully leverage its underlying value to accelerate innovation, application developers need to consider the entire communications ecosystem.
The 3rd International @ThingsExpo, co-located with the 16th International Cloud Expo - to be held June 9-11, 2015, at the Javits Center in New York City, NY - announces that it is now accepting Keynote Proposals. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices - computers, smartphones, tablets, and sensors - connected to the Internet by 2020. This number will continue to grow at a rapid pace for the next several decades.
The Internet of Things is not new. Historically, smart businesses have used its basic concept of leveraging data to drive better decision making and have capitalized on those insights to realize additional revenue opportunities. So, what has changed to make the Internet of Things one of the hottest topics in tech? In his session at @ThingsExpo, Chris Gray, Director, Embedded and Internet of Things, discussed the underlying factors that are driving the economics of intelligent systems. Discover how hardware commoditization, the ubiquitous nature of connectivity, and the emergence of Big Data a...
Almost everyone sees the potential of Internet of Things but how can businesses truly unlock that potential. The key will be in the ability to discover business insight in the midst of an ocean of Big Data generated from billions of embedded devices via Systems of Discover. Businesses will also need to ensure that they can sustain that insight by leveraging the cloud for global reach, scale and elasticity.
SYS-CON Events announced today that Windstream, a leading provider of advanced network and cloud communications, has been named “Silver Sponsor” of SYS-CON's 16th International Cloud Expo®, which will take place on June 9–11, 2015, at the Javits Center in New York, NY. Windstream (Nasdaq: WIN), a FORTUNE 500 and S&P 500 company, is a leading provider of advanced network communications, including cloud computing and managed services, to businesses nationwide. The company also offers broadband, phone and digital TV services to consumers primarily in rural areas.
SYS-CON Events announced today that IDenticard will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. IDenticard™ is the security division of Brady Corp (NYSE: BRC), a $1.5 billion manufacturer of identification products. We have small-company values with the strength and stability of a major corporation. IDenticard offers local sales, support and service to our customers across the United States and Canada. Our partner network encompasses some 300 of the world's leading systems integrators and security s...
IoT is still a vague buzzword for many people. In his session at @ThingsExpo, Mike Kavis, Vice President & Principal Cloud Architect at Cloud Technology Partners, discussed the business value of IoT that goes far beyond the general public's perception that IoT is all about wearables and home consumer services. He also discussed how IoT is perceived by investors and how venture capitalist access this space. Other topics discussed were barriers to success, what is new, what is old, and what the future may hold. Mike Kavis is Vice President & Principal Cloud Architect at Cloud Technology Pa...
Cloud Expo 2014 TV commercials will feature @ThingsExpo, which was launched in June, 2014 at New York City's Javits Center as the largest 'Internet of Things' event in the world. The next @ThingsExpo will take place November 4-6, 2014, at the Santa Clara Convention Center, in Santa Clara, California. Since its launch in 2008, Cloud Expo TV commercials have been aired and CNBC, Fox News Network, and Bloomberg TV. Please enjoy our 2014 commercial.