Apr
16

Earlier today a fellow FoxPro developer sent me a question about an IntelliSense script Andy Kramek wrote about in MegaFox. Normally I pass along the questions I get on topics I did not write about to the original author, but in this case I had an alternative solution to pass along.

Our reader asked for some help with the InLineGetLocVars script found on page 74. So I looked up the section in MegaFox and re-read the tip. This cool script is designed to drop down a list of declared variables when you type in the first two letters of a memory variable following the standard of a scope letter and data type letter. This is a common code standard adopted by VFP developers. Local character variables start with “lc”, local date variables with “ld”, character parameters start with a “tc”, and so on. Once you type in the second letter and hit the spacebar, a dropdown list appears with all the variables declared in the procedure or method. This is a very power and very productive IntelliSense script.

Reading this section reminded me of a moment a few months ago when I was sitting in Cleveland listening to Andy speak on IntelliSense. Andy demonstrated a script that ships with VFP 8 and 9 that I had never seen. In one of your programs type in the following:

zloc

And press the spacebar. Bingo, all the local variables and any parameters for this procedure are in a dropdown list. You can type zloc anywhere in the code line. There are two advantages of this script compared to the one Andy created for MegaFox. The first advantage is you do not need to know what the variable starts with. The second advantage might not be a practical advantage for many developers, but your variables do not have to conform to the industry variable naming standard. At first this might sound like a bad idea, but I often work with code written by other developers who do not code to the same standards I have established.

Both IntelliSense scripts (the MegaFox example and the native VFP) require you to have your variable declared (which is something everyone should be doing by default anyway – another part of my development standards and best practices I subscribe to in an attempt to retain sanity).

There are a couple of gotchas you have to watch for with this IntelliSense script. The variables in this list are only the variables declared between the beginning of the method/procedure and where your type in zloc. The other gotcha is PRIVATE memory variables are not included (note it is called zLOC).

Now something I did not share with our reader is the cousin script to the zloc script, the zdef script. The zdef script will drop down all the constants you have declared in #DEFINEs. Both of these scripts provide a dramatic increase in productivity and I hope it adds to yours.

The person who sent me the question was slightly embarassed they did not know about the zloc script. I perfer to look at it from a different perspective. One can never know everything about FoxPro, it is impossible. I love the fact I have the opportunity to learn something new about my profession and the tools I use in my profession every single day.

So why did I title this blog entry “Paying It Forward VFP Tips?” It is simple: I don’t want to be the last person to learn the tip so I try to tell others. If every developer passes along this tip to a couple other FoxPro developers, and they pass it along to another couple of developers, and so on, this tip will make the rounds in no time. Pay it forward!

Apr
11

I am going to alert you to a grumpy developer warning in advance. I am back from a restful vacation and finally, after a week of catching up on the various tasks put into the background, I have time for a blog post.

Most people who know me understand that I am usually a fan of Microsoft products. It is not that I automatically adopt all Microsoft technology or that I drink the marketing kool-aid, rather I prefer mature Microsoft products that make my day-to-day computing experience enjoyable. MSN Messenger is one of those products.

I often get pulled into debates with friends on how Microsoft is trying to rule the world, and how Bill Gates is the current incarnation of Satan, and how feeding Microsoft my hard earned cash is the stupidest thing I could do. Normally I thank Bill Gates for the roof over my head, and the Microsoft geeks for providing a stable platform, and more importantly the capability for my software creations to run on hundreds of millions of computers without too much hassle. Today provided me a clearer glimpse into the negative viewpoint so many others have on how Microsoft forces themselves on their customers.

Before I go any further, let me state for the record that I fully understand the viewpoint of my friends and clients who would rather use another office suite, different email clients, safer browsers, etc., I just philosophically disagree with them. I refuse to make emotional business decisions, and try to pick technical solutions to my needs based on feature sets, technical support, reliability, stability, and ease-of-use.

Today I got notification that Microsoft released the latest version of MSN IM. I have been using this tool for more than four years now. I read about the new features and because I have not been burned in the past with upgrades I decided to download it and install it. This will not be a story of woe with the product (unlike Andrew MacNeill’s trouble with Windows 2003 SP1), it is working flawlessly so far. My gripe is purely with the installation.

The installation is the typical wizard stepping you through some choices. This is where my complaint is centered. There is a page where you select additional features and settings. I am upgrading, therefore I believe it should respect the settings I made during the last install or upgrade. I might want to change, but why should I have to uncheck the settings I unchecked the last time?? I do not need the MSN Toolbar polluting Internet Explorer (even though I only use IE when exploring Microsoft.com pages). I am perfectly happy with Google Search so I don’t need MSN Search at this time. My browser home page is FoxCentral. I see no single reason to have it automatically changed to MSN Home. Lastly, I already have enough shortcuts to MSN Messenger configured and having the installer add more means I have to delete them later. So instead of hitting the next button, I have to click four times to uncheck these options before proceeding.

It does not end here. After the install I have to explore the MSN IM Options to see what other options it has tweaked on me. Sure enough, despite me turning this off previously, the installer decides I need to see MSN Today every time MSN IM is started. I don’t think so! So I again, uncheck this option.

Come on Microsoft, stop making decisions on my behalf! I am perfectly happy and capable making my own decisions. If I want to switch these options, I can go into the Options Dialog and make the choices. Sheesh! At least the installation did not pollute my desktop with an unnecessary shortcut.

Before all the anti-Microsofties get overly excited by my flirtation with the dark side, I will not be scrapping MSN IM anytime soon because it is an app I am dependent upon. Maybe Microsoft is just trying to be compatible with AOL Instant Messenger. Each time I have upgrade AIM, I have the exact same issues, and it keeps adding several shortcuts to my desktop despite my selection for the installer not to do it. AIM keeps trying to add the Weatherbug applet and other applets each time, and turns on the AIM.com page during startup. These two apps keep ignoring my preferences during upgrades. This is a complete waste of my time. Microsoft and AOL (and other software vendors thinking about tweaking my preferences) need to get their act cleaned up with respect to their software installations. Deployment is supposed to be easy for the end users.

Okay, time to get ungrumpy.

You may be wondering why I use IM, and three of them at that (Skype is the third one). Well I have friends who have asked this question recently and plan on blogging on this topic soon. Stay tuned.

Mar
22

VFP 9 has many major enhancements that make the justification to purchase it a no-brainer. Then there are the many little things the Fox Team threw in the product to make our development lives a little easier. The new beautify directive (note the singular) is not only one of the little things, but until recently it was one of the undocumented gems.

The Beautify feature has been in Visual FoxPro since the beginning. It cleans up code and makes it consistent. One specific function it provides is changing the case of VFP keywords. This works well in most cases and most of the time it does not matter what case the code is because VFP is a case insensitive language. However, there are exceptions when case does matter. For instance, DLL declarations can be case sensitive. If you are unaware of this issue you can break code accidentally by running the beautify feature on your code. The reality of this problem could be spending hours trying to debug code that worked fine until you went to the extra effort to make the code look consistent and meet your company’s coding standards. Not much fun.

In VFP 9 the Fox Team introduces a new directive (the case of the directive does not matter).

*# beautify keyword_nochange
*# beautify

You may notice something a little different about the beautify directive in comparison to a compiler directive. It has a comment character proceeding the “pound” or “sharp” character (#). This is required and has a nice side effect of making the code backwards compatible. What this means is you can include this new directive in any code, use VFP 9 to beautify it, and still compile the code in VFP 8 and earlier.

The directive lines bracket the code you want the beautify process to ignore. The rest of the beautify functionality (indenting comments, continuation lines, procedures and CASE statements, and converting annoying tabs to space) is still applied to the code. The only thing not applied is the casing of the keywords.

The code sample Microsoft provided is a very good example, and one of the more common ones developers could be burned by: the DLL call to ShowWindow. ShowWindow is both a common DLL Declaration and an intrinsic VFP property to specify if a form is a top-level form. If you beautify the code with the DLL Declaration it will respect your preference of upper of lower case and break the code. Here is a code example before beautification:

*# beautify keyword_nochange
PROCEDURE PleasShowWindow
LPARAMETERS tcFormName, tlDoIt
* This is a comment which could be indented or not

DO CASE
CASE PCOUNT() # 2
CASE PCOUNT() # 1
OTHERWISE
ENDCASE

if llSecurityClearance > 30
#DEFINE SW_MINIMIZE 6
DECLARE INTEGER ShowWindow IN WIN32API ;
INTEGER nHWND, ;
INTEGER nCmdShowShowWindow(_VFP.HWND, SW_MINIMIZE)
endif
endproc
*# beautify

Try it out in VFP 9 and one of the eariler versions to see the difference. This example also shows one of the drawbacks you have with this directive. You need to be careful where you place thedirective or you will find other keywords you want cased to your preference getting ignored.

This particular new feature is not documented in the released version of the VFP 9 Help file and was not included in the Hentzenwerke Publishing’s What’s New In Nine: Visual FoxPro’s Latest Hits (disclosure: I am one of the authors on this book).

Mar
19

The ThunderChickens are the team of brilliant students in our school district banding together to build a robot in the FIRST Robotics Competition. The competition for the last couple of days was held at Wayne State University in downtown Detroit. Since White Light Computing is one of many sponsors and I have a vested interested as dad, I decide to play hooky from the office the last couple of days. It was energizing and the team did fantastic, finishing fourth in the qualifying matches, and first overall in the elimination round.

From the FIRST Web site: “FIRST (For Inspiration and Recognition of Science and Technology) is a multinational non-profit organization, that aspires to transform culture, making science, math, engineering, and technology as cool for kids as sports are today.”

This is not robot wars you see on television. This year’s game is a fury of tic-tac-toe with tetrahedrons placed on top and underneath larger tetrahedrons. Stacking them as high as the robot can reach and hopefully having your team’s color on top at the end of the 135 second round. Three teams form an alliance during match and work together to ensure they have the top tetras. The robots work autonomously for the first 15 seconds of each match. Then the students jump in and drive the robots around the playing field.

You can watch a QuickTime animation of the Triple Play game on the FIRST site (check out the “Triple Play Animation” under the downloads), but to see it in person is amazing. Watching our young adults figure out strategy, solve engineering problems, attempt to defy physics, challenge their own limitations, and some how get it all done in six weeks from requirements delivery to shipping a robot is way cool.

My favorite part of this competition is that teams help other teams succeed. Share experiences, share parts, share code, share tools, share ideas, and help each other get better. Sound familiar? Absolutely, much like what the Fox Community is all about. Helping each other be better at what we do. The students really learn first hand about teamwork and collaboration. Each of the teams also takes on a local community service project. They also work with the local elementary schools to build Lego robots for a competition in the Fall. Not only do they learn what it takes to be mechanical, electrical, and software engineers, but they learn about teaching others, giving back, and paying it forward. The skills they learn during the competition will serve them well throughout their lives.

This weekend the ThunderChickens also won the Sportsman Award to add to the collection of awards they won (Entrepreneur and Sportsman) at the Finger Lakes Regional where they finished third in the qualifying matches and were eliminated in the semi-finals.

So the ThunderChickens have accomplished one of their many goals (winning the Detroit Regional). They still have more, like winning a Chairman’s Award, and winning the national competition in Atlanta. Therese and I are hoping to get to Atlanta. After this weekend, I cannot see how we can miss it!

My son Chris is one of the programmers on the team. He tried to explain to me a couple of times how they code this machine to run by itself and respond to the drivers movements of the joystick, and how it will literally spin on a dime. Using code to drive a motor, spin wheels, work with pneumatics to control the arm, and all the other cool stuff they do made my head spin. Databases are so much easier.

Chris, we are very proud of your teamwork, the team accomplishments, and the fun you all had in the regionals. I am continuously amazed how this all works, but I am not amazed how well the team has done knowing the students and mentors involved. I hope you take this energizing experience and expand on it during the national competition.

Now if the ThunderChicken Web site was updated…

Mar
18

I am a mobile developer. I work in my home office, at a client’s office, my in-laws cottage, in my camper, in an airport, hotel room, and even in the car as my wife drives. My primary machine has been a notebook/laptop for the last nine years and it pretty much goes everywhere. Because of this lifestyle, I have a computer backpack and in it I carry my life.

I recently was asked what I have in my laptop bag. Someone I know recently purchased a laptop and wanted to get a head start on the list of items they would be purchasing. Here is the list of accessories I carry with me everywhere I go:

Portable mouse

  • Extra battery and power adapter
  • Thumb drive (256 MB)
  • Ethernet cable and phone cable
  • Kensington lock
  • Baby USB Hub (four port)
  • Headphones with microphone so I can Skype
  • CD case with CDs to install software
  • Portfolio for note taking
  • Spare CD-RW and DVD-R
  • Palm 515
  • Cell phone
  • Cell headphone/microphone
  • Cell phone spare battery and car charger
  • MP3 Player
  • Business cards
  • Sunglass clip
  • Pens & highlighter
  • Mini-flashlight
  • Tylenol
  • Granola bar
  • Cash
  • The entire bag with the laptop and accessories weights 21 pounds. This version is downsized considerably from my older notebook and backpack (at least five pounds lighter). The laptop is lighter, the portfolio I now use is half size, and I parted with junk I don’t use daily. The new notebook has a Centrino and 4-5 hour battery life so I could probably skip the extra battery, but I never know when I am going to need it.

    So what do you carry in your computer backpack or case?

    Mar
    16

    Foxcast is an excellent resource for the Visual FoxPro developer. Just in case you are not familiar with the concept of Foxcast, it is free Webinars presented by knowledgable people in the Fox Community. These live Webinars are recorded so you can download them and watch them on your own time.

    The live Webinars require four things:
    1) Registration for the Webinar
    2) A solid connection to the Internet
    3) A long distance phone call
    4) Your dedication and desire to better your career

    The long distance phone call might turn some people off the live feed. The way I reduced my overall expense was to follow some good advice from Doug Carpenter (the moderator of this venture), and head out to Costco or another reseller of phone cards. I bought 600 minutes for the cheap price of two cents a minute. I watched Drew Speedie’s and Doug Hennig’s presentations live and used it for the session I presented, and still have minutes on the card. If the phone call is a barrier (like being outside the USA), there is always the download.

    The only other problem I see for some developers is the download is big (~300 MB), and some developers still have dial-up, and others have to pay by the minute. My guess is someone will burn these files to a CD and ship them for a nominal cost (hint: there is a business opportunity, or a special contribution to the cause).

    If you are someone who wants to present, great. It is simple and the folks at Visionpace will step you through the process and let you practice a bit before you present live.

    I have personally received more feedback on my Debugging Essentials Foxcast than any other presentation I have made at conferences or user groups. The reason is simple, it has reached a larger audience because of the availability of the download. I also know the video has been shown at user groups all over the country and downloaded by developers across the globe. I could not have presented the session in person at all these user groups and still made a living.

    Foxcast has enabled user groups to easily get quality presentations from outside speakers, and at the same time, allowed speakers to pass along their information and experiences fast, and to more people. Another win-win-win! If you want to download one of the existing Webinars, register for the session and you will get an email telling you where to download it. Simple.

    The next one is scheduled for March 21, 2005. All around great speaker, top-gun developer, and nice guy, Doug “the report dude” Hennig will be presenting the topic “Extending the VFP 9 Reporting System at Run-Time.” I suggest there is not a better time to try Foxcast out than this month.

    Absolute kudos to Russ Swall, Doug Bliss, Doug Carpenter, Drew Speedie, and the entire leadership team at Visionpace for sponsoring this resource and making it happen. There are not many companies in our community with the dedication, the funding, and the vision to make something like this happen.

    Mar
    14

    For all those developers screaming to hear Microsoft market Visual FoxPro, well here is one example: Developers Report on Power, Productivity and Extensibility of New Visual FoxPro 9.0.

    From Ken Levy: “The news of this PressPass article is being sent to many IT journalists today for education on Microsoft’s release of Visual FoxPro 9.0 and to promote the generation of media coverage and articles on VFP 9.0.”

    This is definitely a step in the right direction from my perspective and hope Ken continues with releases of this type. Nice to see positive news like this.

    Interesting details on how two of the Fox Community’s finest have used VFP 9.0. Great success stories. Thanks to John and Doug for their contribution to this story.

    A call to arms: I hope all FoxPro developers have a story to tell Ken, the Microsoft Fox Team, and the big wigs at Microsoft. The more stories we can provide Ken and the marketeers, the more opportunity he will have to spread the word about how great this product is and the great things we can do with Visual FoxPro.

    Mar
    10

    Go Golden Grizzlies!

    I graduated from Oakland University in Rochester Michigan 19 years ago. I really enjoyed my four and half years on campus. When I went to Oakland it was a small university with 7,000 students. It was better known as a school with the second best Computer Science program in the state (even higher than the University of Michigan at the time), than a school with a basketball team. We had champion caliber swim and soccer teams while I was there, but basketball not something that attracted a lot of attention. Oakland molded computer geeks, engineers, nurses, business people, teachers, actors, journalists, and other professionals, but not a single NBA player.

    I am very excited to see our basketball team is in the NCAA Championship “big dance” and one of the finest universities around is getting some national exposure. Maybe the luck of the hard working Pistons is rubbing off. The home of the Pistons is only a 10 minute ride from the middle of the Oakland campus.

    So to all my friends who went to the fine University of Michigan and over the years have ribbed me about us not having a real sports program: watch the Cinderella Golden Grizzlies march toward the final four.

    I think it would be fun if Oakland plays the amazing Fighting Illini so I can have some fun with Rick Borup.