Friday, August 15, 2014

Solved: Unable to open file 'FIREDAC.STAN.FACTORY.OBJ'

Today, I kept getting this error in Embarcadero C++ Builder XE6 when trying to compile a pretty large project:
[ilink32 Error] Fatal: Unable to open file 'FIREDAC.STAN.FACTORY.OBJ'
My project referred to a library that had FireDAC components, though I wasn't using any of them. My project uses DBX, not FireDAC, and VCL instead of FMX.

FireDAC.lib was in the project includes in my .cbproj file, so I had no idea what was wrong.

I finally found a fix: drop a FireDAC component (I used FDConnection) on a form. Save all, compile, and it worked. Then, I just deleted the FDConnection from the form and I was good to go.

Wednesday, July 16, 2014

Changing Fire Monkey (FMX) TextSettings at Run Time

One of my beefs with Embarcadero's C++ Builder is that it is so hard to find decent documentation or tutorials on how to do even the simplest things with their visual tools. This is especially true if you're developing in C++ instead of Delphi.

I experienced a pretty steep learning curve with Embarcadero's Visual Class Library (VCL) -- not because it is especially complicated, but because I couldn't find much good documentation for it.

Right now, I am building an FMX application, which is similar in a lot of ways to VCL. However, one thing has changed a lot: the styles are now driven by stylesheets.

For example, in VCL, it was relatively easy to change the font attributes of dynamically created elements at run time. Not so with FMX.

After several hours of fruitless googling, I still haven't figured out how to change my StyleLookup for a dynamically created TEdit. My custom style works fine for controls created at design time, but I'm apparently missing something from the picture.

After some trial and error, I did manage to come up with a solution that pretty closely replicates how text formatting worked in VCL. This obviously isn't ideal, but at this point, I will take what I can get and be happy to move on. The trick is to turn off the FontColor in your object's StyledSettings.

//Make ValueLabel to display output
TLabel * ValueLabel = new TLabel( this );
ValueLabel->Parent = VerifyMappingsScrollBox;
ValueLabel->Position->X = ValueLabelLeft;
ValueLabel->Position->Y = LabelTop;
ValueLabel->Width = ValueLabelWidth;
if ( OutputValue.Length() == 0 )
//Turn it light gray if empty
  ValueLabel->StyledSettings = ValueLabel->StyledSettings >> TStyledSetting::FontColor;
  ValueLabel->TextSettings->FontColor = claLightgray;
  ValueLabel->Text = "Empty";
  ValueLabel->Text = OutputValue;

So far, I'm not too impressed with the FMX framework. It does some cool things, but some elements are so buggy and counter-intuitive that it's easy to see why no one is making new documentation or tutorials for it. Which is a bummer for those of us who are obligated to use it for the foreseeable future.

Tuesday, May 13, 2014

Valid NPI Number Generator

If you're in the health care industry, you might be familiar with the term National Provider Identifier (NPI). This is a number used to identify medical providers in many various systems, including the SureScripts network.

The thing about NPIs is that you can't just throw any 10 digits together, as you can for many dummy data elements (such as SSNs).

Here's a handy piece of JavaScript for helping you to generate the appropriate check digit for your NPIs. Just another reminder that other people have probably already solved most of the problems I encounter. :-)

Wednesday, May 7, 2014

JavaScript Odometer Image Generator for Blogger

I looked around a LOT for a simple web app that would allow me to generate an odometer based on simple numeric inputs. Since I didn't find any, I decided to be like the Little Red Hen and make one myself.

It's not very fancy and doesn't have a nice UI or anything, but it gets the job done. If you have a Blogger blog, you can paste this into an HTML / JavaScript gadget and just change the variables in the "mileage" array to change the numbers that display. 

Here is the javascript I used to accomplish this:
<div id="odometer"></div>

//enter additional mileage in this array:
  var mileage = [ 136, // 04/05/2014
77.5, // 04/12/2014
259, // 05/03/2014
0 ];
var miles = 0;

while (mileage.length > 0)
miles += mileage.pop();

var totalmiles = miles;

    //handle weird floating point issue   
    totalmiles = Math.round( ( totalmiles + 0.00001 ) *       10 ) / 10; 
miles *= 10;

var digits = [];
var divby = 1000000;
var dig = 0;

while (divby >= 1)
dig = Math.floor(miles/divby);
miles %= divby;
divby /= 10;

var bdigits = [ "",

var wdigits = [ "",

var borderimg = "";

var outputHtml = "<img height = '32' title = '" + totalmiles + " miles' src = '" + borderimg + "'/ >";

for (var x=0; x<digits.length-1; x++)
outputHtml += "<img width = '20' title = '" + totalmiles + " miles' src = '" + bdigits[digits[x]] + "'/ >";

outputHtml += "<img width = '20' title = '" + totalmiles + " miles' src = '" + wdigits[ digits[digits.length-1] ] + "'/ >";

outputHtml += "<img height = '32' title = '" + totalmiles + " miles' src = '" + borderimg + "'/ >";

document.getElementById("odometer").innerHTML = outputHtml;


Thursday, April 10, 2014

Need to View Files from your Chrome Cache? Here's a Solution!

Here's a great solution to a problem that I was about to solve the hard way. I was trying to retrieve some images (just the images) from a web page I had visited in Chrome.

(They were wrapped in a design that wouldn't allow just right-click, then save as. And, yes, I had a good reason for needing them... it's a long story regarding my church's flaky web provider.)

In Chrome, if you type "about:cache", it brings up a list of the files the browser has recently loaded. When you click on them, though, you see a large HTML file with a hexadecimal code in the body. This is true even for binary files like .jpg or .png.

Senseful Solutions has posted a great little tool for translating the hex back into pages (or, in my case, images): Viewing Chrome cache (the easy way).

This is what programming is all about: making people's lives easier by creating elegant solutions to everyday problems.

Tuesday, April 1, 2014

XML Formatting in Edit Plus

I was thinking of writing a macro to help me format XML in Edit Plus. Fortunately, someone else already came up with a better solution 5 years ago.

In case this link ever dies, here's the code he used:
var stdin  = WScript.StdIn; var stdout = WScript.StdOut; var xml = WScript.createObject("MSXML2.DomDocument"); xml.loadXML(stdin.ReadAll().replace(/\t/g, '').replace(/\r|\n/g, '').replace(/\>\</g, '>\n<')); stdout.Write(xml.xml.substr(0, xml.xml.length-2));
This is why I love the internet.

Scheduling for Makers

Here's a great essay by Paul Graham: Maker's Schedule, Manager's Schedule.

One of my favorite parts:
When you're operating on the maker's schedule, meetings are a disaster. A single meeting can blow a whole afternoon, by breaking it into two pieces each too small to do anything hard in. Plus you have to remember to go to the meeting. That's no problem for someone on the manager's schedule. There's always something coming on the next hour; the only question is what. But when someone on the maker's schedule has a meeting, they have to think about it.

For someone on the maker's schedule, having a meeting is like throwing an exception. It doesn't merely cause you to switch from one task to another; it changes the mode in which you work.
This shines a lot of light on some of the most frustrating parts of my previous job as a Business Systems Analyst. I was never happier than when I had a meeting-free day to work on my deliverables and help my developers with theirs. The problem was that I was also expected to attend a lot of planning, project management, and status meetings that shouldn't have been in my job description.

Meetings interrupt creative and analytical processes. They use time that would be more efficiently spent on solving problems. Sometimes they are a necessary evil, but often they are just plain evil.

I wish every manager and every scrum master would read Graham's essay, digest it, and internalize the lessons. It would make a world of difference to the people who work with and for them.

Thursday, March 27, 2014

I Love DeBugger

I'm not sure how I ever got along without using my compiler's debugger. It's SO much nicer to see the call stack and step through my code rather just making wild guesses about what might be wrong.

I am reminded of Winston Smith's epiphany at the end of 1984 (though, I hope, without the sinister overtones). With apologies to George Orwell:
O cruel, needless misunderstanding! O stubborn, self-willed exile from the loving breast! Two gin-scented tears trickled down the sides of his nose. But it was all right, everything was all right, the struggle was finished. He had won the victory over himself. He loved DeBugger.

Wednesday, March 5, 2014

Baby Steps

I am working on a pretty big C++ project to take XML, parse out certain fields in it, and then use it to populate various tables.
My first few efforts in writing this class were akin to giving a mouse a drink from a firehouse -- extremely frustrating, and not particularly enjoyable or profitable. It dampened my fur, to say the least.

But then I remembered some of the best programming advice I ever received, and that has helped things to go better.

When in doubt, remember Bob's method: baby steps. It'll make you feel much better.

Tuesday, March 4, 2014

The Pragmatic Programmer: Craftsmen and Cathedrals

I'm still only in the preface to Andrew Hunt's and David Thomas's The Pragmatic Programmer, but I can already tell it's going to be a favorite.

Hunt and Thomas have this to say about about the importance of craftsmanship in software development:
Think about the large cathedrals built in Europe during the Middle Ages. Each took thousands of person-years of effort, spread over many decades. Lessons learned were passed down to the next set of builders, who advanced the state of structural engineering with their accomplishments. But the carpenters, stonecutters, carvers, and glass workers were all craftspeople, interpreting the engineering requirements to produce a whole that transcended the purely mechanical side of their construction. It was their belief in their individual contributions that sustained the projects.
We who cut mere stones must always be envisioning cathedrals.

-Quarry Worker's Creed  
 (p. xx of The Pragmatic Programmer, Boston: Addison-Wesley, 2000 )
Good stuff -- makes me want to do more than just sling code that compiles. It's an excellent reminder that there is always room for beauty and elegance, even in the seemingly mundane.

Monday, February 3, 2014

Stuck? Review, Debug, Rebuild.

Just finished troubleshooting a very irritating bug.

In the process, I ran up against a couple of walls and got pretty frustrated. I ended up just setting it aside for awhile, since I was out of strategies to try. I think this was the best course of action for someone with my admittedly limited experience.

I asked a senior developer about it this morning, and he encouraged me to follow this flow in the future.

I don't know if it was something funny about my IDE or just the standard n00b problem of missing some important steps, but my current build of the project was pretty screwy. This caused an error when my C++ app tried to execute a script in SQL Server. Cleaning and doing a full rebuild was just the ticket.

So, when I don't know what to do next, I'm adding "full rebuild" to the list of options.

Wednesday, January 29, 2014

I've Got 99 Problems... and I am the Solution!

Until very recently, I was a business systems analyst (BSA) at a large financial services company. In changing career paths, I have noticed that application developers have to think very differently from BSAs.

Typically, a BSA's role is all about requirements, details, and approvals. Some problem solving is required, but a BSA's problems tend to center around people. In that position, I was always reasonably confident that the answer was out there. I was also pretty good at knowing how to find it.

As a developer, I am finding that sometimes, the answer isn't out there. My job is to create the answer, not document one that already exists. This is simultaneously my favorite and my least favorite part about my new role as a programmer.

Very little frustrates me as much as attempting something that should be simple -- such as getting my code to compile -- and running into wall after wall without any success.

And very little is more exhilarating than finding an elegant solution to a difficult problem.

Despite the occasional moments of wanting to bash my head against the wall, I think I'm going to like this job. It's a fun change to be the one creating answers instead of the one who records them.

Monday, January 20, 2014

Lucidchart: A Great Replacement for MS Visio

I was looking for an online flowchart utility and found this web-based gem of an application: Flow Chart Maker & Online Diagram Software | Lucidchart.

Lucidchart has an impressive number of features that are attractive to me (and, I suspect, many other users):
  • Integration with Google Drive
  • Intuitive user interface (Visio is nowhere near this good at UI design)
  • Cloud-based storage
  • Excellent collaboration support
  • Tier-based, feature-driven pricing model
They aren't paying me anything to say this; I tried it and really just think it's a terrific app. The clean, modern website design is also notable and gives them big marketing points, in my book.

I am looking forward to using this app more... I hope it lives up to my initial good impression.

Friday, January 17, 2014


Whoever said that change is good probably wasn't a programmer.

I don't know about you, but if my code is running well and isn't eating up too many system resources, I don't want to change it. This is particularly true for purely stylistic changes. For example, I am seeing a lot of code like this in a program I've been reviewing:

if(a == false){    Do action;}

if(b == true){    Do action;}

This syntax isn't going to throw any errors, but it bothers me because it's not good idiomatic C++. A better (and equivalent) way to express these statements would be:

if(!a){    Do action;}

if(b){    Do action;}
If this was a novel -- or even one of my students' papers -- I would slash away with my red pen. With production code, however, that can be dangerous.

Yes, cleaning up legacy code can improve readability and, in some cases, even performance. But the risk of bumping or forgetting something in the process is greater than any benefit I can imagine from making the change.

Bottom line: in written or spoken English, I am quick to assert my preferences. The risk is low and I have the experience to back my preferences up. In production code, though, my motto is closer to "If it ain't broke, don't fix it."

Thursday, January 16, 2014

strcat() != StirCat

Whenever I see strcat(), the C++ function for concatenation, I can't help but think of this:

That is all.

Wednesday, January 15, 2014

Best MOOC for Beginning Programmers

I took An Introduction to Interactive Programming in Python on this fall, and I was amazed by how well it was designed.

This course provides a nice first look at programming in general, and Python specifically.1 While it gives many step-by-step instructions to help beginners through the tasks, it also leaves some intentional small gaps for students to fill in on their own.

Overall, the design and content are the best I've seen in a MOOC. Big-time kudos to Scott Rixner and Joe Warren, the masterminds behind this course. (They had help from a couple of other Rice faculty members, as well.)

I was especially impressed with the fully cloud-based Python Integrated Development Environment, CodeSkulptor, which Dr. Rixner designed for the course. This tool allows you to enter and run Python code using nothing more than an Internet connection and a Web browser.

If you want to poke CodeSkulptor around on your own, you can feel free to. You don't have to be enrolled in the class to use it. It also includes a Graphical User Interface module called SimpleGUI, which allows you to code visual elements without too much fuss.

Coursera is a great MOOC platform, and this course really showcases its flexibility and power. I would love to see more offerings like this in the future, as well as some more advanced courses in Python.

You can read Rixner's and Warren's reflections on creating the course here: MOOCs: Lessons from the front lines.

You can also watch them discuss MOOCs with the president of Rice in this video: The professors behind the first massive online open course at Rice University.

1 If you're a complete novice and you find this course overwhelming, you might try Introduction to Systematic Program Design - Part 1 or Computer Science 101 first. They are both quite good as well, and they provide content tailored for those with little prior exposure to programming.

Tuesday, January 14, 2014

Lots of Code

I'm a little bit stunned to think of the sheer volume of code in the project that my machine is compiling right now. I'm on line 60,000 of... well, a really big number. So big that it has made my int roll over to negative twice so far.

What is even more striking -- sobering, even -- is that this code represents the lives of the people who work here. Most of their waking hours, on most days, for most of their lives, have been spent adding to this code. They have created it, perfected it, sweated and sighed over it... and now here I am, distilling it to machine-readable 1s and 0s in a matter of minutes.

With that thought in mind, and in honor of National Poetry at Work Day (here's a delightful infographic about it), I will quote a few lines of Eliot's "Love Song of J. Alfred Prufrock":

For I have known them all already, known them all:
Have known the evenings, mornings, afternoons,        50
I have measured out my life with coffee spoons;
I know the voices dying with a dying fall
Beneath the music from a farther room.
  So how should I presume?
But what are any of our lives, really, but a long, slow measuring out? And lines of C++ are as good a yardstick as coffee spoons, I reckon.

Monday, January 13, 2014

Embarcadero RAD Studio: VCL Tutorial

I'm not sure why, but I had a hard time finding beginner-level tutorials on how to create VCL forms applications in Embarcadero's RAD Studio. After a lot of googling and some poking around, I found this one, which was more helpful than anything else I've encountered yet:

Starting your first RAD Studio application Index (IDE Tutorial) - RAD Studio:

Does anyone else know of tutorials that would be helpful for a beginner trying to learn about VCL forms in RAD / C++ Builder?