Planet FoxPro

February 03, 2012

Alex Feldstein

February 02, 2012

Rick Strahl's FoxPro and Web Connection Web Log

Creating Gravatar Web Image Avatars in FoxPro

Gravatar.com is a great and very popular Web service based way to associate an image with user accounts that are based on email addresses. It's easy to use and can provide a nice touch of personalization with very little effort to just about any Web application that uses email addresses for users. This post shows how you can use Gravatar from within your FoxPro based applications.

I recently restyled my West Wind Message Board support site and one of things that I think makes the messages look a little more interesting and personal is having an avatar - an image - associated with users. But rather than asking users to upload images and storing them on my servers, I opted to use Gravatar which is a Web based service that can be used in many applications and is supported by a large number of popular Web sites already. Ultimately it's a better choice for users who only have to sign up once to associate an email address with a Gravatar to be used on many sites.

Here's what the Gravatar image looks like on a message board message:

Gravatar 
The Gravatar service  simply returns an an image for a given email address and some other parameters that are encoded and point at the Gravatar.com site. As a developer you configure Gravatar by creating a URL and embedding that URL into an <img> control's src attribute.

Above you can see the image that is associated with my Email address. The cool thing about Gravatar - if they have a Gravatar account already - is that once users have provided an email address they don't have to do anything else to associate their gravatar image with your application. If they have a gravatar configured the image is shown. If not, a default image is shown.

If an email address is sent to Gravatar that doesn't exist you can either provide another URL to an alternate image (some sort of default that's appropriate for your app) or you can let Gravatar serve it's default icon which looks like this:

GravatarDefault 

How it works

The Gravatar service works by calling a URL on their site and providing a few known parameters. An URL to retrieve an email address looks something like this:

http://www.gravatar.com/avatar/a4ec5092141a8649fe9d81527569a4c0?s=80&r=r

In an image control:

<img src="http://www.gravatar.com/avatar/a4ec5092141a8649fe9d81527569a4c0?s=80&r=" 
class="gravatar"
alt="Gratar Image based on email address" />

The components you need to send to get a Gravatar image are:

  • The Email Address encoded with an MD5 Hash
  • An image size
  • A default image if the email address is not registered with
  • A rating for the image (g, pg, r, x)

I've created a small reusable function that helps create Gravatar images in FoxPro. Using the function you can do:

? GravatarLink("rstrahl@west-wind.com",80) 
? GravatarLink("invalid@west-wind.com",60,,"r")

Here's the code for the GravatarLink function:

************************************************************************
*  GravatarLink
****************************************
***  Function: Creates an image URL for a given email address
***            that is registered with Gravatar.com.
***
***            Gravatar is a very popular avatar service that
***            requires only an email address to share a picture.
***            Used on many web sites so once you sign up your
***            picture will be used on many sites.
***    Assume: 
***      Pass: lcEmail - Email Address
***            lnSize - Image Size (square) 60-80 is usually good
***            lcDefaultImage - Url to an image if no match is found
***                             for email. Empty shows Gravatar's default
***            lcRating - g, pg, r, x   (Default: pg)
***    Return: URL to the Gravatar image
************************************************************************
FUNCTION GravatarLink(lcEmail,lnSize,lcDefaultImage, lcRating)
LOCAL lcDefaultImage

IF EMPTY(lnSize)
   lnSize = 80
ENDIF

IF !EMPTY(lcEmail)
    lcHash = LOWER(STRCONV(HashMd5(lcEmail),15))
ELSE
  lcHash = ""
ENDIF
IF EMPTY(lcDefaultImage)
   *** Gravatar default image displays
   lcDefaultImage = ""
ELSE
   lcDefaultImage = "&d=" + UrlEncode(lcDefaultImage)
ENDIF   
IF EMPTY(lcRating)
   lcRating = "pg"
ENDIF   

lcUrl = "http://www.gravatar.com/avatar/" + lcHash + "?" +;
       "s=" + TRANSFORM(lnSize) +;
       "&r=" + lcRating +;
       lcDefaultImage

RETURN lcUrl
* GravatarLink

The code is pretty straight forward - it basically builds up a URL as a string and adds the components provided by the parameters. The trickiest part of this is the MD5 encoding of the Email address. The MD5 hash creates a binary value which is then turned into a HexBinary string with STRCONV().

In order to encode the email address as an MD5 hash I use the following routine based on the content from the FoxPro Wiki a long while back:

************************************************************************
* wwAPI :: HashMD5
****************************************
***  Function: retrieved from the FoxWiki
***            http://fox.wikis.com/wc.dll?fox~vfpmd5hashfunction
***    Assume: Self standing function - not part of wwAPI class
***      Pass: Data to encrypt
***    Return: 
************************************************************************
FUNCTION HashMD5(tcData)

*** #include "c:\program files\microsoft visual foxpro 8\ffc\wincrypt.h"
#DEFINE dnPROV_RSA_FULL           1
#DEFINE dnCRYPT_VERIFYCONTEXT     0xF0000000

#DEFINE dnALG_CLASS_HASH         BITLSHIFT(4,13)
#DEFINE dnALG_TYPE_ANY          0
#DEFINE dnALG_SID_MD5           3
#DEFINE dnCALG_MD5        BITOR(BITOR(dnALG_CLASS_HASH,dnALG_TYPE_ANY),dnALG_SID_MD5)

#DEFINE dnHP_HASHVAL              0x0002  && Hash value

LOCAL lnStatus, lnErr, lhProv, lhHashObject, lnDataSize, lcHashValue, lnHashSize
lhProv = 0
lhHashObject = 0
lnDataSize = LEN(tcData)
lcHashValue = REPLICATE(CHR(0), 16)
lnHashSize = LEN(lcHashValue)


DECLARE INTEGER GetLastError ;
   IN win32api AS GetLastError

DECLARE INTEGER CryptAcquireContextA ;
   IN WIN32API AS CryptAcquireContext ;
   INTEGER @lhProvHandle, ;
   STRING cContainer, ;
   STRING cProvider, ;
   INTEGER nProvType, ;
   INTEGER nFlags

* load a crypto provider
lnStatus = CryptAcquireContext(@lhProv, 0, 0, dnPROV_RSA_FULL, dnCRYPT_VERIFYCONTEXT)
IF lnStatus = 0
   THROW GetLastError()
ENDIF

DECLARE INTEGER CryptCreateHash ;
   IN WIN32API AS CryptCreateHash ;
   INTEGER hProviderHandle, ;
   INTEGER nALG_ID, ;
   INTEGER hKeyhandle, ;
   INTEGER nFlags, ;
   INTEGER @hCryptHashHandle

* create a hash object that uses MD5 algorithm
lnStatus = CryptCreateHash(lhProv, dnCALG_MD5, 0, 0, @lhHashObject)
IF lnStatus = 0
   THROW GetLastError()
ENDIF

DECLARE INTEGER CryptHashData ;
   IN WIN32API AS CryptHashData ;
   INTEGER hHashHandle, ;
   STRING @cData, ;
   INTEGER nDataLen, ;
   INTEGER nFlags

* add the input data to the hash object
lnStatus = CryptHashData(lhHashObject, tcData, lnDataSize, 0)
IF lnStatus = 0
   THROW GetLastError()
ENDIF


DECLARE INTEGER CryptGetHashParam ;
   IN WIN32API AS CryptGetHashParam ;
   INTEGER hHashHandle, ;
   INTEGER nParam, ;
   STRING @cHashValue, ;
   INTEGER @nHashSize, ;
   INTEGER nFlags

* retrieve the hash value, if caller did not provide enough storage (16 bytes for MD5)
* this will fail with dnERROR_MORE_DATA and lnHashSize will contain needed storage size
lnStatus = CryptGetHashParam(lhHashObject, dnHP_HASHVAL, @lcHashValue, @lnHashSize, 0)
IF lnStatus = 0
   THROW GetLastError()
ENDIF


DECLARE INTEGER CryptDestroyHash ;
   IN WIN32API AS CryptDestroyHash;
   INTEGER hKeyHandle

*** free the hash object
lnStatus = CryptDestroyHash(lhHashObject)
IF lnStatus = 0
   THROW GetLastError()
ENDIF


DECLARE INTEGER CryptReleaseContext ;
   IN WIN32API AS CryptReleaseContext ;
   INTEGER hProvHandle, ;
   INTEGER nReserved

*** release the crypto provider
lnStatus = CryptReleaseContext(lhProv, 0)
IF lnStatus = 0
   THROW GetLastError()
ENDIF

RETURN lcHashValue
ENDFUNC
* HashMD5

With this function in place it's now a snap to embed Gravatar images into HTML based applications. In a Web Connection (or any other template/script based environment that uses Fox code) you can now simply do:

<img src="<%= GravatarLink(poUser.Email,80,,"pg") %>" class="gravatar" />

And you're off to the races.

On the West Wind MessageBoard

If you're a user of the West Wind Message Board I recommend you head over to Gravatar.com and hook up your Avatar image if you are interested in showing an image for any of your messages. Go ahead post a message, and see your Gravatar pop up. Once you have a Gravatar you may find that a lot of sites where you participate also already use Gravatar images so this will be useful in a lot of places beyond just the message board or your own applications.

GravatarLink() is now also part of the wwUtils library in Web Connection and the West Wind Client Tools.


by Rick Strahl at February 02, 2012 11:52 PM

Beth Massi - Sharing the goodness that is VB

LightSwitch Community & Content Rollup–January 2012

Last Fall I started posting a rollup of interesting community happenings, content, samples and extensions popping up around Visual Studio LightSwitch. If you missed those rollups you can check them out here:

Looks like folks took a few well-deserved days to ramp back into the groove after the holidays (including myself). But there were still a lot of awesome things around LightSwitch this month, especially the number of submissions The Code Project had in the LightSwitch Star Contest. A lot of really interesting applications and some great case studies for LightSwitch as well as some for Azure. Check them out…

“LightSwitch Star” Contest

“LightSwitch Star” Contest on CodeProject

In November The Code Project launched the “LightSwitch Star” contest. They’re looking for apps that show off the most productivity in a business as well as apps that use extensions in a unique, innovative way. Prizes are given away each month. Soon they will announce the January winners as well as the two grand prize winners of an ASUS U31SD-DH31 Laptop!

Check out all the submission we had in January and make sure to log onto Code Project and vote for your favorites. Here’s a breakdown of the 13 apps that were submitted in January (see all 34 apps that have been submitted here). There are some very creative “business apps” here – like a campaign manager for Dungeons & Dragons!

There are a lot of really interesting real-world LightSwitch production applications that were submitted. Some departmental apps, a few personal apps, some enterprise apps as well as a couple start-up companies. There are also some great case studies here for Azure, in particular:

Developer Center Updates

Learn Page Updates

In December I kicked off a series aimed at beginner developers just getting started with LightSwitch and was featured in the MSDN Flash Newsletter. In January we updated the Learn page of the Developer Center to feature this series and it’s been getting some great traffic!

image

I also released the completed source code for the sample we build in the series: Beginning LightSwitch - Address Book Sample

How Do I Videos – Learning Made Easier

We also updated all the How Do I video pages to show the sequential list of videos so that you can easily get to the previous and next videos in the series. This makes it a lot easier to navigate through the over 20 videos in the correct order. Just click into any video page like this one and you will see the video navigator at the bottom of the page.

image

Notable Content this Month

Here’s some more of the fun things the team and community released in January.

Extensions released in January (see all 73 of them here!):

The team also released a control extension sample that you can learn from. Check out the announcement on the team blog:  Many-to-Many Control Released!

Build your own extensions by visiting the LightSwitch Extensibility page on the LightSwitch Developer Center.

Team Articles:
Community Articles:
Presentations:
Samples (see all of them here):
LightSwitch Team Community Sites

The Visual Studio LightSwitch Facebook Page has been increasing in activity thanks to you all. Become a fan! Have fun and interact with us on our wall. Check out the cool stories and resources.

Also here are some other places you can find the LightSwitch team:

LightSwitch MSDN Forums
LightSwitch Developer Center
LightSwitch Team Blog
LightSwitch on Twitter (@VSLightSwitch, #VisualStudio #LightSwitch)

Join Us!

The community has been using the hash tag #LightSwitch on twitter when posting stuff so it’s easier for me to catch it (although this is a common English word so you may end up with a few weird ones ;-)). Join the conversation! And if I missed anything please add a comment to the bottom of this post and let us know!

Enjoy!

by Beth Massi at February 02, 2012 03:30 PM

Alex Feldstein

Chris Sainty

Bug hunting in the public eye

A few days ago, ayende put up a post showing a bug that had been found in RavenDb that was causing the profiling tools to enter an infinite loop.

http://ayende.com/blog/152738/bug-hunt-what-made-this-blog-slow

This was followed by a post about how this bug had come into being and survived so long.

http://ayende.com/blog/153825/ask-ayende-what-about-the-qa-env

So confession time, that’s my bug. I contributed the early code for the profiler.

So since then I have been trying to work out how I missed it. Was I really so oblivious to what was going on while writing that code?

Second to that, how had it sat in production on ayende’s blog for 6 months or so without being noticed?

I am glad to say I have an explanation for both, which I will share now.

First some background on how the profiling actually works.

When you attach your DocumentStore to the profile, the following code is run

<script src="https://gist.github.com/1720587.js?file=RavenProfilingHandler.cs"></script>

Basically we attach to the OnSessionCreated event and stuff a header into the response with the session id.

This is very important, and the key to why this bug was missed. So I will say it again, the X-RavenDb-Profiling-Id header is only added to your response if you actually open a session.

So lets look at that JavaScript again.

<script src="https://gist.github.com/1720587.js?file=ravendb-profiler-scripts.js"></script>

It only calls back to the server when it gets an AJAX response that has the header set. So if you make an AJAX request to your server for data that does not come from RavenDb, the profiler will not pay any attention to that request.

The request to get the profiling results does not need a session, and in all my development it did not create a session. So it never set the header. So it never entered a loop.

So that explained to me how I had missed the bug, the way I deal with session management (creating and disposing of them only as needed) simply does not trigger the bug.

So with my conscious cleared, I moved on to the second problem. Just because I handle my session this way, clearly RacoonBlog does not, surely that bug hasn’t been there since ayende turned on the profiler for his blog.

Well let me present a commit to the RacoonBlog source from the very end of December.

https://github.com/ayende/RaccoonBlog/commit/b284efae61108af991221d948eb891e1310bc64b

In this commit, Racoon switched from creating sessions only as they are needed (my way of handling them) to creating the session in the BeginRequest event of *every* request. So even requests that don’t use the session still create one. Which obviously adds the profiling header and tells the JavaScript “this request hit RavenDb, so you should fetch it’s profiling results”.

So until that commit was pushed live RacoonBlog, like my own sites, simply did not trigger this bug, it was sitting there dormant just waiting for someone to take a different approach to session management.

So there we have it. I really don’t feel so bad about it now.

To a certain degree the JavaScript was actually correct. It noticed an AJAX request that said it had profiling information attached and it fetched that information. The fallacy in this argument though is that the JavaScript also has enough information available (the request URL) to know that it is being lied to. It should have used that information to avoid the trap that was laid for it. So it’s still a bug for all that I wish it were not.

by Chris Sainty (noreply@blogger.com) at February 02, 2012 01:18 AM

February 01, 2012

Ted Roche's weblog

Alpha Loft announces inaugural Web Developers Meetup

The folks at Alpha Loft announce a new meetup for Web Developers. The first meeting will feature Mark Bates talking about CoffeeScript and, no doubt, provide some insights from his upcoming book. The idea of a group focused on general web development and not a particular technology sounds like a great idea. I wish the group good luck and hope to attend future meetings.

by tedroche at February 01, 2012 02:22 PM

Rick Strahl's Web Log

Dynamic Types and DynamicObject References in C#

I've been working a bit with C# custom dynamic types for several customers recently and I've seen some confusion in understanding how dynamic types are referenced. This discussion specifically centers around types that implement IDynamicObject or subclass from DynamicObject as opposed to arbitrary type casts of standard .NET types. IDynamicObject types  are treated special when they are cast to the dynamic type.

Assume for a second that I've created my own implementation of a custom dynamic type called DynamicFoo which is about as simple of a dynamic class that I can think of:

public class DynamicFoo : DynamicObject
{
    Dictionary<string, object> properties = new Dictionary<string, object>();

    public string Bar { get; set; }
    public DateTime Entered { get; set; }

    public override bool TryGetMember(GetMemberBinder binder, out object result)
    {
        result = null;
        if (!properties.ContainsKey(binder.Name))
            return false;

        result = properties[binder.Name];
        return true;
    }

    public override bool TrySetMember(SetMemberBinder binder, object value)
    {
        properties[binder.Name] = value;
        return true;
    }
}

This class has an internal dictionary member and I'm exposing this dictionary member through a dynamic by implementing DynamicObject. This implementation exposes the properties dictionary so the dictionary keys can be referenced like properties (foo.NewProperty = "Cool!"). I override TryGetMember() and TrySetMember() which are fired at runtime every time you access a 'property' on a dynamic instance of this DynamicFoo type.

Strong Typing and Dynamic Casting

I now can instantiate and use DynamicFoo in a couple of different ways:

Strong Typing

DynamicFoo fooExplicit = new DynamicFoo();
var fooVar = new DynamicFoo();

These two commands are essentially identical and use strong typing. The compiler generates identical code for both of them. The var statement is merely a compiler directive to infer the type of fooVar at compile time and so the type of fooExplicit is DynamicFoo, just like fooExplicit. This is very static - nothing dynamic about it - and it completely ignores the IDynamicObject implementation of my class above as it's never used.

Using either of these I can access the native properties:

DynamicFoo fooExplicit = new DynamicFoo();


// static typing assignments
fooVar.Bar = "Barred!"; fooExplicit.Entered = DateTime.Now;
// echo back static values
Console.WriteLine(fooVar.Bar);
Console.WriteLine(fooExplicit.Entered);

but I have no access whatsoever to the properties dictionary. Basically this creates a strongly typed instance of the type with access only to the strongly typed interface. You get no dynamic behavior at all. The IDynamicObject features don't kick in until you cast the type to dynamic.

If I try to access a non-existing property on fooExplicit I get a compilation error that tells me that the property doesn't exist. Again, it's clearly and utterly non-dynamic.

Dynamic

dynamic fooDynamic = new DynamicFoo();

fooDynamic on the other hand is created as a dynamic type and it's a completely different beast. I can also create a dynamic by simply casting any type to dynamic like this:

DynamicFoo fooExplicit = new DynamicFoo();
dynamic fooDynamic = fooExplicit;

Note that dynamic typically doesn't require an explicit cast as the compiler automatically performs the cast so there's no need to use as dynamic.

Dynamic functionality works at runtime and allows for the dynamic wrapper to look up and call members dynamically. A dynamic type will look for members to access or call in two places:

  • Using the strongly typed members of the object
  • Using the IDynamicObject Interface methods to access members

So rather than statically linking and calling a method or retrieving a property, the dynamic type looks up - at runtime  - where the value actually comes from. It's essentially late-binding which allows runtime determination what action to take when a member is accessed at runtime *if* the member you are accessing does not exist on the object. Class members are checked first before IDynamicObject interface methods are kick in.

All of the following works with the dynamic type:

dynamic fooDynamic = new DynamicFoo();
// dynamic typing assignments
fooDynamic.NewProperty = "Something new!";
fooDynamic.LastAccess = DateTime.Now;

// dynamic assigning static properties
fooDynamic.Bar = "dynamic barred";
fooDynamic.Entered = DateTime.Now;

// echo back dynamic values
Console.WriteLine(fooDynamic.NewProperty);
Console.WriteLine(fooDynamic.LastAccess);
Console.WriteLine(fooDynamic.Bar);
Console.WriteLine(fooDynamic.Entered);

The dynamic type can access the native class properties (Bar and Entered) and create and read new ones (NewProperty,LastAccess) all using a single type instance which is pretty cool. As you can see it's pretty easy to create an extensible type this way that can dynamically add members at runtime dynamically.

The Alter Ego of IDynamicObject

The key point here is that all three statements - explicit, var and dynamic - declare a new DynamicFoo(), but the dynamic declaration results in completely different behavior than the first two simply because the type has been cast to dynamic.

Dynamic binding means that the type loses its typical strong typing, compile time features. You can see this easily in the Visual Studio code editor. As soon as you assign a value to a dynamic you lose Intellisense and you see

DynamicInDebugger

which means there's no Intellisense and no compiler type checking on any members you apply to this instance.

If you're new to the dynamic type it might seem really confusing that a single type can behave differently depending on how it is cast, but that's exactly what happens when you use a type that implements IDynamicObject. Declare the type as its strong type name and you only get to access the native instance members of the type. Declare or cast it to dynamic and you get dynamic behavior which accesses native members plus it uses IDynamicObject implementation to handle any missing member definitions by running custom code.

You can easily cast objects back and forth between dynamic and the original type:

dynamic fooDynamic = new DynamicFoo();
fooDynamic.NewProperty = "New Property Value";             
DynamicFoo foo = fooDynamic;
foo.Bar = "Barred";

Here the code starts out with a dynamic cast and a dynamic assignment. The code then casts back the value to the DynamicFoo. Notice that when casting from dynamic to DynamicFoo and back we typically do not have to specify the cast explicitly - the compiler can induce the type so I don't need to specify as dynamic or as DynamicFoo.

Moral of the Story

This easy interchange between dynamic and the underlying type is actually super useful, because it allows you to create extensible objects that can expose non-member data stores and expose them as an object interface. You can create an object that hosts a number of strongly typed properties and then cast the object to dynamic and add additional dynamic properties to the same type at runtime. You can easily switch back and forth between the strongly typed instance to access the well-known strongly typed properties and to dynamic for the dynamic properties added at runtime.

Keep in mind that dynamic object access has quite a bit of overhead and is definitely slower than strongly typed binding, so if you're accessing the strongly typed parts of your objects you definitely want to use a strongly typed reference. Reserve dynamic for the dynamic members to optimize your code.

The real beauty of dynamic is that with very little effort you can build expandable objects or objects that expose different data stores to an object interface. I'll have more on this in my next post when I create a customized and extensible Expando object based on DynamicObject.

© Rick Strahl, West Wind Technologies, 2005-2012
Posted in CSharp  .NET  
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> <g:plusone href="http://www.west-wind.com/weblog/posts/2012/Feb/01/Dynamic-Types-and-DynamicObject-References-in-C" size="medium"></g:plusone> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script>

by Rick Strahl at February 01, 2012 10:47 AM

Alex Feldstein

January 31, 2012

Ted Roche's weblog

Keeping up: theme changes

Astute readers (and I know who you two are!) will notice a change to a newer theme. I’ve switched over to the WordPress Twenty-Eleven base theme, with a few of my own tucks, nips and tweaks. I wanted to check out the new theme and test out the new functionality and keep up with the latest stuff.

Child themes are a piece of cake to create, and a child theme lets me override the original without messing with the original source, so updates will not erase the changes. While they are not so difficult to do manually if you are familiar with the command-line, they are even easier with the plugin One-Click Child Theme.

With the child theme in place, I was able to shorten the gap between the site description (the motto) and the header picture, just by adding CSS to the style.css in the child theme (that’s the cascading part of CSS). I added a paper-curl edge effect based on the work of Craig Buckler, published on Sitepoint.

I was disappointed that my site was not valid HTML5, according to the W3C’s validator site. Category tags used in REL links aren’t standard, so I deleted those. The Creative Commons plugins want to use Dublin Core XML namespaces, and there are issues there I’ve got to clean up. And the “generator” REL tag on the bottom of the page isn’t too standard, either. Overall, though, the pages are relatively clean of excessive markup or poorly-formed structures. Stay tuned as I tweak the last few elements into line.

by tedroche at January 31, 2012 04:27 PM

Alex Feldstein

VisualFoxProWiki

CrystalReportsFAQ

I have used Crystal Reports with three VFP applications. For the most part, it is a terrific reporting tool, but I am also aware of its limitations. I have written an FAQ for anyone interested in learning more about it. Please see http://www.ml-consult.co.uk/foxst-19.htm. --
Bounce House Rental Mesa AZ

[http://www.bouncewow.com/ |Bounce House Rental Mesa AZ]
Mike Lewis
The FAQ referred to above has now been updated for Crystal Reports XI (Jan '06)

You can also download a VFP class library that handles a lot of the details of dealing with CR here:
http://www.kirtlandsys.com/Tools%20Page.htm

<< Page not found >> at this link - Paul Mrozowski

<updated> The whitepapers on my web site will help you get started. http://www.craigberntson.com -- Craig Berntson

January 31, 2012 08:13 AM

Chris Sainty

Experiments in text adventure

Like many who were into computers “back in the day” I still maintain a nostalgic, warm and fuzzy feeling at the memory of early text based adventure games.

Back when all I knew were the PRINT and INPUT commands in QBASIC, these were the very first programs I created.

Where am I going with this?

Well over the weekend I was learning the Impress.js presentation library and thought to myself that it really was a beautiful way to display text in a web browser. Then a little light bulb went off in my head.

3 hours later, I had forked impress.js and used it’s HTML5 canvas and CSS3 animations to create an engine for a modern text adventure game.

You can see the results of that intense session of programming here http://csainty.github.com/ImpressGame

I have quite a few other ideas for what I could do with this underlying concept. If it eventually comes together as I see it, it will be beautiful.

by Chris Sainty (noreply@blogger.com) at January 31, 2012 02:39 AM

January 30, 2012

Calvin Hsia's WebLog

Be careful about nothing in managed code

Here’s a pattern of code use I’ve seen in a few places. There’s a function DeserializeList that returns an array of various sizes, depending on the input. This code can be called to deserialize (rehydrate) an object from a stream. For example,...(read more)

by CalvinH at January 30, 2012 10:12 PM

Ted Roche's weblog

Seacoast WordPress Developers Group announces February meeting

The Seacoast WordPress Developers Group will meet on February 15th at the New Hampshire Innovation Commercialization Center. I’ll talk about techniques for making backups of WordPress sites (slides and notes) and Amanda Giles will talk about custom post types. Hope to see you there!

Sign up at the Meetup site to confirm attendance.

by tedroche at January 30, 2012 08:48 PM

VisualFoxProWiki

FoxRockXTOC

TOC January 2012 - Number 24

New Ways: Managing Properties as Virtual Table Fields
Pradip Acharya
In a distributed multi user application with a central shared database, its not easy to add new fields to a table or modify table structures at will. This may not even be practical. For example, when the Product table must support inventory for a several Business Models, there may be thousands of individual Product properties.

Deep Dive: The ctl32 Library, Part 3
Doug Hennig
Carlos Alloatti has created an incredible library of controls you can use to give your applications a more modern interface. Doug finishes his look at the library with the last set of controls.

Know How: Speed Up Your SQL Code
Tamar Granor, Ph D
In my last article, I talked about the two functionsin VFP that allow you to measure the optimization of SQL commands. This month, Ill look at what you can do to improve performance once you know that a query is sub-optimal.

VFPX: Parallel Fox
Rick Schummer
Parallel processing is defined as the performance by a computer of two or more simultaneous operations divided among multiple processors. Parallel programming is spawning processes on two separate processors either on different computers or the same computer. This is becoming more and more important based on the engineering fact it is getting harder to get silicone-based processors to run faster with the reliability and stability we expect and require. So how do Visual FoxPro developers take advantage of this approach? Well thanks to Joel Leach and the Parallel Fox project on VFPX, it actually is quite straightforward.


TOC November 2011 - Number 23

New Ways: Foxparse C Library for Handling Strings, Properties and Windows
Pradip Acharya
A limited version of the Foxparse.fll C library was introduced in an earlier recent issue. This issue covers the full version featuring the complete set of advanced functions. The C API was created to expand the limited choices for string handling, formatting and parsing offered by VFP9.


TOC September 2011 - Number 22

Editorial: Totally Marshmallowed? Join us at SWFox DevCon for a refresher!
Rainer Becker
You should not miss the SWFox DevCon. It covers a lot of great topics, treated by great speakers! But maybe economics are harsh again in your region and maybe there is a problem with the funding concerning not only the money to spend, but also the time? Time of not being available at your desk for the perennially urgent development work, support and maintenance tasks?. Here come a few more reasons why you should circumnavigate all these obstacles somehow or why your boss should be won over, too.

Deep Dive: The ctl32 Library, Part 2
Doug Hennig
Carlos Alloatti has created an incredible library of controls you
can use to give your applications amore modern interface. Doug continues his look at the library withthe next set of controls.

Know How: Make Your Queries Fly
Tamar Granor, Ph D
In the January, 2010 issue, I wrote about changes in VFP's SQL commands in VFP 8 and 9. But one of the key elements in using SQL commands is that they can be very fast. When they're not, you need to figure out why. Fortunately, VFP includes a couple of functions that help you do so.

VFPX: Thor Adding Tools
Rick Schummer
Thor is designed to be the ultimate IDE extension and tool manager and is quickly maturing on VFPX. Last issue Rick briefly introduced you to the installation process and provided a brief overview of Thors user interface. This month Rick dives in to the core reason this tool was created in the first place by detailing how you can use Thor to manage various add-ons and tools you want integrated into the Visual FoxPro 9 IDE.

Tips & Tricks: Schummer Tips and Tricks
Rick Schummer
ActiveX/IntelliSense tip
Dragging the ActiveX controls from the Visual FoxPro Toolbox to an editor provides the syntax for CREATEOBJECT() code. The following code was created when I dropped the Adobe PDF Reader ActiveX Control in the program editor:

Tips & Tricks: Report Writer
Cathy Knight
The VFP Report Writer has some very useful features hidden away. The first hidden feature is very helpful for concatenating data in a single field object on a report. The second hidden feature is helpful for browsing or hacking the FRX.

Internationalization: Internationalize Your App, Part 1 Entering international characters
Rainer Becker
Numerous articles and publications describe how to use Unicode and such in Visual FoxPro applications to enable the input and display of international character sets. Visual FoxPro cannot process double byte character sets and a workaround is needed in all cases. The simple approach discussed here might be the quickest solution to internationalize the data input capabilities of your application, at least to some degree.


TOC July 2011 - Number 21

Editorial: It's show time again
Rainer Becker
Mark the date: October 26 - 29, 2011. The Southwest Fox 2011 will take place at the Legado Hotel, Gilbert, Arizona, USA and you should not miss this great event! All details including very interesting session descriptions and the speakers' biographies are available on-line at www.swfox.net. Registration is already open.

Deep Dive: The ctl32 Library, Part 1
Doug Hennig
Want to add fresher, more modern-looking controls to your applications? Want to avoid ActiveX issues?
Take a look at the ctl32 library.

Know How: Talking to Microsoft Office
Tamar Granor, Ph D
While most Office Automation code moves smoothly from older versions to the latest, some
changes in recent versions do have an impact on the process of automating the Office apps. One change in Office 2010 has major implications for applications that need to use Office's applications programmatically.

Customerizing: Customizing Your Vertical Market Application, Part IV
Cathy Pountney
In the previous three installments of this four-part series, I introduced you to a customization methodology you can implement in your vertical market application to keep your standard code independent from your custom code, yet have the two code bases play nice together. I showed you how to lay the foundation and add hooks in your application. I showed you how to build the custom application and add basic functionality. I explained how to customize menus, forms, processes and even offer customized data. In this last article of the series, I show you how to customize my favorite part of an application; Reports.

Silverlight: Applications and the local System
Michael Niethammer
As You saw this headline You might be wondering why it is necessary to write an article in Fox RockX
about SL-applications and the system they are running on. But please remember: Silverlight is a web-technology, applications written this way are running on the local system in a sandbox, hosted by a web browser, without any access to the local machine. Thinking about business- applications it becomes very important to talk about ways to use the local file system, automate applications like Office or using the local hardware.

VFPX: Thor Introduction
Rick Schummer
Thor is designed to be the ultimate IDE extension and tool manager and is relatively new to VFPX. Thor helps you manage hotkeys as shortcuts to your add-ons, allows you to create and manage a developer menu, and positions itself as a facilitator to add-ons and the ability to more easily share tools you create with other Visual FoxPro developers. This month Rick is going to give you a short introduction to this fluid project in hopes you will help test it out and provide some of your own add-ons to share with the Fox Community, and then next time dig deeper into some extensions samples.


TOC May 2011 - Number 20

Deep Dive: Email and File Transfer the Fast (and Cheap!) Way
Doug Hennig
In the previous two issues, Doug discusses free libraries generously provided by Craig Boyd to compress and decompress files and encrypt and decrypt strings and files. In this issue, he discussed two more libraries that add MAPI email and file upload and download capabilities to your applications.

Know How: Build Your Own Project Tools
Tamar Granor, Ph D
While Visual FoxPro's Project Manager doesn't offer much in the way of tools to audit or manage projects, the ability to address the project as an object more than makes up for this deficiency.

Customerizing: Customizing Your Vertical Market Application, Part III
Cathy Pountney
In the previous two installments of this four-part series, I introduced you to a customization methodology you can implement in your vertical market application to keep your standard code independent from your custom code, yet have the two code bases play nice together. I showed you how to lay the foundation and add hooks in your application. I showed you how to build the custom application, add basic functionality, and explained how to customize menus. In this article, Part 3, I take it a step further and show you how to customize forms, processes, and offer customized data to your clients.

Tools: dFPUG.fll Version 3 - Zip, Scan and more
Venelina Jordanova and Uwe Habermann and Erich Todt
The dFPUG.fll has grown up. The little FLL with functions for compressing and decompressing files has become an ample collection of functions indispensable for many purposes. FoxPro developers are offered capabilites hitherto unknown.


TOC March 2011 - Number 19

Deep Dive: Encryption the Fast (and Cheap!) Way
Doug Hennig
In the previous issue, Doug discussed a free library generously provided by Craig Boyd to compress and decompress files using the ubiquitous ZIP format. This time, he examines another free library from Craig, one that encrypts and decrypts strings and files.

Know How: Inside the Object Inspector
Tamar Granor, Ph D
In my last article, I demonstrated the Object and Collection Inspector, a new tool I built to overcome the VFP Debugger's weaknesses in working with collections. This time, I'll open the hood and cover some of the issues I encountered in building the tool.

Customerizing: Customizing Your Vertical Market Application, Part II
Cathy Pountney
Part 1 of this four-part series introduced you to a customization methodology you can implement in your vertical market application to keep your standard code independent from your custom code, yet have the two code bases play nice together. This article, Part 2, dives into the code showing you how to lay the foundation and start building the custom application as well as how to add some customization to menus in your application.

VFPX: Vista (and Windows 7) Dialogs via COMtool
Rick Schummer
Sedna was released on January 25, 2008, which is more than three years ago. Yet Rick still finds Visual FoxPro developers asking questions about Sedna, where to go get it, what is included, and how to install it. Microsoft open sourced the Sedna release package and source code, and made it so they could be available on VFPX. Now developers can extend them and have the ability to re-release them to the Fox Community. This month Rick is going to show you the VistaDialogs4COM, which is one of the components available in the Sedna package.


TOC January 2011 - Number 18

Deep Dive: Compression the Fast (and Cheap!) Way
Doug Hennig
Need a way to compress and decompress files in your applications? VFP guru Craig Boyd has created a free library to zip and unzip files quickly and easily.

Know How: Introducing the Object and Collection Inspector
Tamar Granor, Ph D
For the last four years, I've been working on a project that has grown to include a complex object hierarchy with many embedded collections. While VFP's collection class is quite useful, the debugging tools for collections are weak. In particular, there's no support for drilling down into collections. So I finally created my own tool.

Customerizing: Customizing Your Vertical Market Application, Part I
Cathy Pountney
Writing a vertical market application can be very rewarding. You write one application, sell it numerous times, and sit back while the money rolls in. Well,that's the theory anyway. The reality is often times new clients want to buy your software as long as you can change this one little thing. Managing custom code for various clients within your application can easily turn into a nightmare as your client base expands. This article, part 1 of a four-part series, introduces you to a customization methodology you can implement in your vertical market application to keep your standard code independent from your custom code, yet have the two code bases play nice together.

Silverlight: Lightswitch - a first look at the Beta of the new RAD tool
Michael Niethammer
End of August this year Microsoft published the first Beta of their new product called Lightswitch (former internal name: KittyHawk). This product should fill a gap in the Visual Studio toolset for professional developers as well as for home users to create database applications as easy as possible. Without writing a line of code, Lightswitch enables the user to create CRUD applications for different datasources (locally or anywhere else) easily. Even though its somewhat a model-based application generator there are enough ways for enhancing the generated application to make the toolset a valuable thing for professionals. In this article I will give a brief overview of Lightswitch and its architecture.

Tools: Application String Handling Made Easy with Foxparse C library
Pradip Acharya
In business applications (and in general), we are faced with complex string handling and parsing issues every day. Fulfilling this requirement with the rudimentary VFP functions SUBSTR, ATC and ALINES is a tedious task involving lengthy ad hoc coding with numerous chained function calls within VFP loops, slowing down development not to mention execution. In this introductory article, Pradip Acharya presents the broad outlines of the new Foxparse C library, its advantages, how its used and a few core functions with examples. In a forthcoming issue, the complete set of functions and the advanced options will be unveiled. Foxparse.fll included in this download is the curtailed version of the library.


TOC November 2010 - Number 17

Silverlight: Silverlight Business Applications
Venelina Jordanova and Uwe Habermann
You can create Silverlight 4 applications with any version of Visual Studio 2010. We are using the version Visual Web Developer 2010 Express which is available for download free of charge. Basically all Silverlight 4 applications can be developed with this free version of Visual Studio 2010. But the various commercial versions of Visual Studio offer an extended debugging, automatized testing capabilities, and the possibility of integrating them in a source code management system. However, the free Visual Web Developer 2010 Express is the right choice for beginners. And in many cases it will suffice for doing professional development work.

Deep Dive: A More Flexible Report Designer
Doug Hennig
This month, Doug presents a way to make the VFP Report Designer more flexible, such as customizing the pages of the properties dialogs without having
to change ReportDesigner.APP.

Know How: Understanding Business Objects, Part III
Tamar Granor, Ph D
Once you have business objects, you need to connect them to the user interface. Plus changing the application is easier than when business logic and UI code are mingled


TOC September 2010 - Number 16

Editorial: Rescue in sight with Silverlight
Rainer Becker
Dear Fox RockX reader,the publisher of Fox RockX magazine, the FoxPro User group of German Language Inc., is happy to report good news: Our plans to offer a migration path for Visual FoxPro developers have taken big steps forward!
Complete article available at http://www.foxrockx.com.

VFPX: zProc IntelliSense
Rick Schummer
IntelliSense in Visual FoxPro is highly extensible and this is proven by the number of developers who create scripts over the years to assist themselves and other developers in writing source code quicker. This month Rick is going to dive into the relatively new ⬓zProc, zVFP, and zCOM IntelliSense Scripts⬝ project headed up by Jijo Pappachan to show you three new scripts which may or may not be useful for your development, and potentially can save you time.

Deep Dive: Practical Uses for GDIPlusX, Part III
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the last in a series that examines some practical uses for GDIPlusX.

Know How: Understanding Business Objects, Part II
Tamar Granor, Ph D
In my last article, I explained what business objects are and why I had a hard time learning to use them. Then, I looked at a client application (called NMS) that brought the ideas home to me. In this issue, I'll begin to look at the details of using business objects.

Silverlight: SL Data-Binding and Data-Validation
Michael Niethammer
Developing Silverlight applications is totally different from the way FoxPro developers did things for a long time. Most of them don⬜t like to switch over to Visual Studio because of the DataBinding in old style Winforms Applications. Microsoft has released the Windows Presentation Foundation and Silverlight with a totally rewritten User-Interface. So let⬜s take a closer look at it.


TOC July 2010 - Number 15

SilverLight: SilverLight for VFP Developers
Venelina Jordanova and Uwe Habermann
In the past most of VFP developers were in search of new development tools. Some of us switched to other development platforms like Java or .NET, but most VFP developers still looked for a development platform.
Complete article available at http://www.foxrockx.com.

VFPX: Code References
Rick Schummer
The Code Reference developer tool is one of those tools some developers find indispensible and other developers find less useful. Regardless of your opinion all Visual FoxPro developers have the need to do global searching of the different source code files included in their projects. Jim Nelson decided he wanted a few of his enhancements ideas implemented to make his searching more productive and is making Code References a little more powerful. This month Rick digs into the beta release of this product to show you what is new, and maybe even shed some light on some gotchas with the latest release.

Deep Dive: Practical Uses for GDIPlusX, Part II
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the second in a series that examines some practical uses for GDIPlusX.

Know How: Understanding Business Objects, Part I
Tamar Granor, Ph D
I've been hearing about business objects since some time in the mid-1990's. Not long after VFP added object-orientation, people started recommending that business logic be encapsulated into a set of separate objects. Intellectually, I understood the idea, but the examples I saw never really seemed to deliver on the promise. The standard example involved a customer object with the customer data entry form calling on that business object to do things like calculate sales tax. While I could see how to build that kind of object, it didn't seem all that important.


TOC May 2010 - Number 14

Editorial: The Visual FoxPro Roadshow 2010
Rainer Becker
Dear Subscribers, thank you for your ongoing support of Fox RockX! And here comes our gift to you for supporting us: You are herewith invited to a free one-day workhop right after the South West DevCon in October!
Complete editorial available at http://www.foxrockx.com.

VFPX: OOP Menus
Rick Schummer
OOP menus are probably the second highest requested feature to be added to Visual FoxPro over the years. Microsoft never responded to this request for some reason (I am speculating it was most likely a resource issue). Doug Hennig wanted OOP menus and over the years implemented his own set of classes to accomplish this task and has posted the classes up on VFPX for others to use and help enhance.

Deep Dive: Practical Uses for GDIPlusX, Part I
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the first in a series that examines some practical uses for GDIPlusX.

New Ways: Extending the Toolbox
Tamar Granor, Ph D
Several issues back, I wrote about the Toolbox, a cool tool added in VFP 8 that makes designing forms and classes much easier. Like many other VFP tools, the Toolbox was written with VFP and was designed with extension in mind. This month, I want to show you how simple some changes to the Toolbox are, so you can customize it for your needs.

New Ways: Dating with DBI
Toni Feltman
In the last issue of Fox RockX I talked about three of the eight ActiveX controls that DBI Technologies have graciously provided Visual FoxPro 9.0 SP2 users for free. In this issue I am going to talk about two more controls that make working with dates a little more exciting.


TOC March 2010 - Number 13

Editorial: Visual FoxPro Stack Overflow
Ken Levy
In software, a stack overflow occurs when too much memory is used on the call stack, usually caused by programming errors, typically resulting in a program crash. In ideas, a stack overflow might occur when too many ideas, all with good intention, comprise a concept which is too far reaching and/ or unrealistic to reach its goals.
Complete editorial available at http://www.foxrockx.com.

VFPX: ProjectHookX
Rick Schummer
Projecthooks were introduced in Visual FoxPro 6, yet even today I know developers who have not implemented projecthooks in their development. Projecthooks allow you as a developer to write code that reacts to the different events of the Project Manager. One of the drawbacks of projecthooks is you only get one per project. Toni Feltman from F1 Technologies saw this limitation pain and designed one approach to working around it so developers can use more than one projecthook for any one project and calls this project ProjectHookX.

Deep Dive: Introduction to GDIPlusX, Part III
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the third in a series that provides an introduction to GDIPlusX, going through the basics of GDI+, looking at the classes in GDIPlusX, and going through various samples of how to use GDIPlusX in VFP applications.

New Ways: OOP + Metadata = Flexibility
Tamar Granor, Ph D
Over the last few years, I've found many situations where data-driving code makes an application easier to maintain. But sometimes, data-driving alone can lead to repeated code and more difficult maintenance. In such cases, combining good objectoriented practices with data-driving may provide a better solution.

New Ways: Paying it Forward
Toni Feltman
For years DBI Technologies, www.dbi-tech.com, has offered for sale ActiveX controls that could be used in various development languages and unlike many other third party vendors they had examples written in FoxPro. Now, DBI�s support of the Fox- Pro community is even better. They have agreed to give away 8 of their active controls for free to users of VFP 9, SP2 in a bundle called the Sedna Components.


TOC January 2010 - Number 12

Editorial: Get on the VFPX Bandwagon
Rick Schummer
A group of VFPX developers/users held a bonus session during the Southwest Fox conference in October to discuss future direction of VFPX and what is needed to get the word out to other developers in the Fox Community. There were a number of good ideas shared, but there are three key details I believe need to be highlighted.
Complete editorial available at http://www.foxrockx.com.

VFPX: SCCText X
Rick Schummer
Source code control is an integral part of the development process for Visual FoxPro developers, but much of the source code elements in Visual FoxPro are stored in binary format (DBF files), which is not friendly to source code control repositories. The Alternate SCCText project and specifically the SCCText X program is the key ingredient to flattening the DBFs into text files so comparisons can be performed between versions, and merging of two changed versions can occur. Jurgen wOOdy Wondzinski leads the SCCText X project that contains what is considered the gold standard for the Visual FoxPro SCCText process.

Deep Dive: Introduction to GDIPlusX, Part II
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the second in a series that provides an introduction to GDIPlusX, going through the basics of GDI+, looking at the classes in GDIPlusX, and going through various samples of how to use GDIPlusX in VFP applications.

New Ways: Take adventage of SQL improvements
Tamar E. Granor, Ph D
When SQL commands were added in FoxPro 2, it didn't take me long to see that they could make writing code easier. SQL SELECT, in particular, was very appealing since it made it possible to retrieve the data I needed by specifying what I wanted rather than how to find it.

New Ways: Wheres the Beef?
Jim Booth Offsite link to http://www.jamesbooth.com
Many times I have found my self using onto a piece of software for one purpose only to find out that it has many other very valuable uses as well. It�s like finding a free tool in my tool box. Well Fox RockX is just like that once you discover its web version. If you haven�t yet visited http://www.foxrockx.com please make it a point to visit there and spelunk around abit real soon. There are gems lying around that place worth their weight in gold.

New Ways: String.Format for VFP
Eric Selje
If you havent used C#s String.Format() method, its a real treat. Theres nothing natively like it in VFP, but we can certainly roll our own equivalent. This will make our code easier to read and maintain. This article will show why you want to do that, and how to do it.

VUProjectTools: Updating project files from the source control management
Venelina Jordanova and Uwe Habermann
To make our daily development work easier we have brought many useful little tools to life. In this article in two parts we would like to introduce two of our V and U Project Tools. This second part concerns how to update project files from the source control management.


TOC November 2009 - Number 11

Editorial
Ken Levy
Complete editorial available at http://www.foxrockx.com.

VFPX: Control Renamer
Rick Schummer
The Control Renamer Builder project headed by long time Visual FoxPro guru Tamar Granor is relatively new to VFPX, but has been around a few years. This tool started out as a personal project to help Tamar rename controls in forms developed by other developers so the names of the controls have meaning and followed common programming standards. In this article I hope to show you how this sophisticated builder actually helps me refactor code that I have in forms and VCX-based classes.

Deep Dive: Introduction to GDIPlusX, Part I
Doug Hennig
GDIPlusX is a VFPX project that exposes GDI+ to VFP applications as a set of VFP class libraries. GDIPlusX makes it easy to add new graphical abilities to your applications, allowing you to provide a fresher and more powerful user interface. This article is the first in a series that provides an introduction to GDIPlusX, going through the basics of GDI+, looking at the classes in GDIPlusX, and going through various samples of how to use GDIPlusX in VFP applications.

New Ways: Collections instead of Arrays
Tamar Granor, Ph D
Every procedural programming language I used before FoxBase+ offered arrays as a way to hold an ordered collection of information. So when I started learning FoxBase+, its arrays made sense to me. Infact, the very first article I ever published in a Foxjournal was about arrays.

Best Practices: Best Practices Part VI
Jim Booth Offsite link to http://www.jamesbooth.com
In this series of articles we have discussed a wide variety of issues related to the development of high quality software systems. We have investigated methods for achieving efficiency in our development efforts and attempting to reduce the risk for errors in our code.

VUProjectTools: Beauty Studio
Venelina Jordanova and Uwe Habermann
To make our daily development work easier we have brought many useful little tools to life. In this article in two parts we would like to introduce two of our V and U Project Tools. The first part treats the so-called Beauty Studio.


TOC September 2009 - Number 10

Editorial: New kids on the block
Rainer Becker
And here they come: A new book about Visual FoxPro has been sent to the printer today, and printed copies will be available in September 2009. It is the rewritten version of the best-selling Visual FoxPro book of all time: Effective Techniques for Application development with Visual FoxPro 6.0 by Jim Booth and Steve Sawyer from Hentzenwerke Publishing. Jim Booth has reworked and updated it for Visual FoxPro 9.0, but it is still valid for all versions. And why do we say kids instead of kid? Because this book, Effective Application development with Visual FoxPro comes in two flavours, English and German at the same time!
Complete editorial available at http://www.foxrockx.com.

VFPX: Code Analyst
Rick Schummer
Code Analyst is a tool developed by Andrew MacNeill who is a long time Visual FoxPro guru and most recently famous for his The Fox Show podcasts (http://akselsoft.libsyn.com/). Code Analyst is being developed to help Visual FoxPro developers recognize possible refactoring opportunities. If you are not familiar with refactoring then you need to know it is part of the development process when you recognize a smell of properly working code that could be written better. There are a number of refactoring patterns developers have detailed over the years and concepts we all recognize in our code and in other developers code. Code Analyst is here to help you find these opportunities faster.

Deep Dive: Custom UI Controls:SFCombo Tree
Doug Hennig
Sometimes you need to display a list of items but don�t have much room to do so. While a combo box is usually used in this case, it doesnt display a hierarchical list or support checkboxes for items. SFComboTree fits this need nicely.

New Ways: The Right Keys are Primary
Tamar Granor, Ph D
FoxPro is a relational database, that is, data is stored in multiple tables with fields that establish relationships between those tables. In order to establish those relationships, there must be a way to uniquely identify each record in a table. The field or fields that link one table to another are called keys. Over the years, the best practices for creating those keys have changed, as have the tools for doing so in VFP.

New Ways: Test Driven Development, After the Fact, Part II
Eric Selje
In Part I, we reviewed what test-driven development (TDD) was, created some unit tests in Fox-Unit, and put together some trivial code to calculate a factorial to run the tests on. It�s easy stuff when youre starting with a blank slate, but how do you get started when youve already got a ton of legacy code? This article will show you how to make a couple of quick changes to Fox Unit to quickly get a suite of tests on existing code.

New Ways: ActiveLabel Class - CmdButton Substitute for Forms with the New Look
Pradip Acharya
On the Web and in desktop applications, command buttons are a rare sight today. An action is launched via a highlighted or underlined text string. While VFP offers a HyperLink native class and a Click method for a label, neither a Hyper-Link nor a passive label fulfils the general need for a full featured ActiveLabel control with Set Focus, Keypress and TabStop functionality with builtin co-ordination of associated internal or external access keys, images(s), and supplementary descriptive label. Pradip Acharya presents an easy to use ActiveLabel class with rich capabilities which is not a container class. The class library in the download is self sufficient with no external dependencies. The class is also an excellent Toolbar alternative for simplicity, and can also serve as raised 3D buttons as seen in VFP task panes, with optional double line captions.


TOC July 2009 - Number 9

Editorial: All You Can Eat!
Rainer Becker
It's conference time again. This year's Prague DevCon took place, South West Fox and the FoxPro DevCon Germany and other events are coming soon. And lots of new topics and new stuff to learn for everyone. For 15+ years I have really tried to attend conferences and learn new things. And the FoxPro conferences I always enjoyed most as they are the best on earth from my perspective. I am really sorry about each one I missed for whatever reason. Surely the FoxPro DevCons are smaller nowadays, which is a pity as the number of topics you need to know about has increased each year. Therefore developers have to attend other conferences as well.
Complete editorial available at http://www.foxrockx.com.

VFPX: Tabbing Navigation
Rick Schummer
Rick covers the Tabbing Navigation project this month in his continuing series of articles on the open source project known as VFPX hosted on Codeplex. This project provides developers with a snappy dialog filled with the titles of the open windows as well as a list of standard Visual FoxPro windows available for selection. This enhancement to the Visual FoxPro Interactive Development Environment (IDE) is clean and a fast way to find a specific instance of an editor or designer window when you have numerous instances open.

Deep Dive: Custom UI Controls:Splitter
Doug Hennig
Adding a splitter control to your forms gives them a more professional behavior and allows your users to decide the relative sizes of resizable controls.

Best Practices: Best Practices Part V
Jim Booth Offsite link to http://www.jamesbooth.com
Last time we discussed some of the concepts that allow us to really exploit our object oriented approach to system development. This time we will pull back a bit and look at our work from a more distant perspective. We will look at the very big picture of our system design by focusing on the architectural structure of our systems.

New Ways: Use the Toolbox!
Tamar Granor, Ph D
Until now, Ive focused this column on the FoxPro language, covering commands and functions. In this issue, I want to take a look at one of my favorite recent tools, the Toolbox, introduced in VFP 8.

New Ways: Test Driven Development,After the Fact, Part I
Eric Selje
Test-Driven Development (TDD) is easiest when you do it right from the start. But once you�ve written a lot of code it may seem overwhelming to start testing it after the fact. But if you change any of that existing code, having tests is the best way to ensure that you don�t break any functionality. It may seem like a catch-22, but it is worthwhile to create tests on legacy code so you can use to make sure that doesnt happen.


TOC May 2009 - Number 8

Editorial: VFP 9 SP2 News
Rick Schummer
The perception and adoption of the Visual FoxPro 9 Service Pack 2 has been in a word, underwhelming. Reports of the Report Designer having some bugs and the Help file being a mess spread across the various forums and blogosphere extremely fast. Rick has good news on both fronts!
Complete editorial available at http://www.foxrockx.com.

VFPX: PEM-Editor
Rick Schummer
The PEM Editor is one of the fastest moving projects on VFPX and for this reason one of the hardest tools to write about in this continuing series. That said, this month Rick attempts to catch you up on all the development for the PEM Editor, show you some of the super cool features it has to help you be more productive, and expose some of the new functionality being developed for the fourth release of this powerful tool.

Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 3
Doug Hennig
The last article in this three-part series finishes examining a set of classes that provide Explorer-style interfaces to Visual FoxPro applications.

Best Practices: Best Practices Part IV
Jim Booth Offsite link to http://www.jamesbooth.com
Last month we covered the introduction of object orientation and some of the key concepts of that programming paradigm. This month we will continue to look into the key concepts of object orientation and discover some additional mechanisms that are at our disposal within this conceptual programming approach. In addition to covering some more of the programming concepts of object orientation, this month we will introduce and discuss at some length the idea of application frameworks and see how they are constructed and what they can do for us. Obviously, in a single article we will not be building a complete application framework or even discussing a complete framework but we will cover enough about frameworks to give you a very good start on how to approach building your own and how to evaluate any of the many commercial application frameworks that are out there.

New Ways: Handling Code that Changes at Runtime
Tamar Granor, Ph D
There are lots of places in VFP code where you dont know until the code is running exactly what you want it to do. Perhaps you want to let the user choose a file to operate on, or you want to run a report based on criteria specified by a user. VFP offers a number of different ways to handle code that isnt known until run-time. Knowing which one to use when affects the efficiency, accuracy, and reliability of your code, but many people stick with macros and dont use any of the other options. In this article, I'll look at each of the options and discuss where its appropriate.

New Ways: Use FastNoData to drastically improve form load times
Mike Yearwood
Forms that take too long to load are a cause of frequent complaints. Heres a technique that can dramatically reduce form load times. Ive seen anywhere from 8 to 4375 times faster. My most complex form went from loading in a range of 8 to 10 seconds, down to a consistent 2.2 seconds.


TOC March 2009 - Number 7

Editorial: Thanks for the Memories (and all the code)!
Doug Hennig
As they discuss in this issues article, Andy Kramek and Marcia Akins have written their last Kitbox column. Doug offers a tribute to Andy and Marcia to celebrate their years of contribution to the FoxPro community.
Complete editorial available at http://www.foxrockx.com.

VFPX: Fox Tabs the VFP IDE
Rick Schummer
Fox Tabs is relatively new to VFPX, but has been in development for years. In October 2008 project manager Joel Leach dusted off the initial development started several years ago by Craig Bailey and Scott Scovell and began moving the tool forward. This month Rick will discuss this innovative approach to enhancing the VFP IDE and explain how he uses it to enhance his productivity.

Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 2
Doug Hennig
In the first part of this three-part series, Doug presented a set of classes that form the basis of an Explorer-style interface. This article looks at more of these classes.

Kit Box: So Long and Thanks for all the Fish!
Marcia Akins and Andy Kramek
For more than 10 years Andy has been writing the Kitbox Column. He was first published, with co-author and long-time friend, Paul Maskens, in the April 1998 edition of Fox Talk. Andy and Paul wrote some 42 articles together in the three and a half years of their collaboration and the style of the column as an interchange between two peers began to gradually evolve. When Paul retired from the column in September 2001, Marcia jumped in and took over as Andys partner in the column, as she is in real life. Together they have written more than seventy articles together and, under their collaboration, the back-and-forth style of two real-life developers discussing a problem of mutual interest evolved further until it truly has become their unique signature. Andy and Marcias writings are instantly recognizable, and their style has even been imitated (the sincerest form of flattery even if it was not very successful). However, like all things, this too must come to an end and this is the final offering from Andy and Marcia.

New Ways: The Scope of Things
Tamar Granor, Ph D
When I started using FoxBase+, there were two kinds of variables available: public and private. If you did nothing, any variables you used in code were private. Since that was the most restrictive scope available, it was easy to get into the habit of not declaring variables unless they were public.

Best Practices: Best Practices Part III
Jim Booth Offsite link to http://www.jamesbooth.com
In the last article of this series we covered the concepts of encapsulation and cohesiveness to understand how to construct routines that have a solid internal structure and we discussed coupling to investigate the issues involved with constructing routines that play well with others. Our first venture into this best practices series covered what constitutes a routine and why we care about routines at all.


TOC January 2009 - Number 6

VFPS: Visual FoxPro Stack
Ken Levy
The evolution and next phase of Visual FoxPro has essentially been transferred from Microsoft to the FoxPro community. Visual FoxPro will evolve, but the results of its evolution depend on the efforts within the FoxPro community. VFPS (Visual FoxPro Stack) can become an important part in the future and perception of Visual FoxPro starting in 2009 and into the next decade.
Complete editorial available at http://www.foxrockx.com.

VFPX: Using Desktop Alerts
Rick Schummer
The Desktop Alerts provide you with another common mechanism to deliver informational messages to the users while your application is running. This month in Rick�s continuing series on VFPX deep dives, he takes a look at the Desktop Alert project on Codeplex, and demonstrates why this control might help you get rid of a few WAIT WINDOWS in your applications.

Kit Box: Take it up with Management
Marcia Akins and Andy Kramek
All Visual FoxPro applications rely on data and in VFP we have various ways of handling sets of data. We may use tables directly, views, predefined cursors, or cursors generated on the fly by SQL queries. However, VFP doesnt have a command that will unconditionally create or open and make current a data set irrespective of the type. In this months column Andy and Marcia discuss the creation of a class that will do precisely that thing.

New Ways: From Type to Type
Tamar Granor, Ph D
Changing data from one type to another is a common requirement. In older versions of VFP, you had to know a veritable cornucopia of functions to handle the various possibilities. A few recent additions make type conversion easier.

Best Practices: Best Practices Part II
Jim Booth Offsite link to http://www.jamesbooth.com
Last month we started this series with a little history and some discussion of basic programming practices. We discovered the ideas of routines and modules in our application development and we discussed the impact of designing for expansion to be able to adapt to future requirements. This month we will be digging deeper into the construction of our code and the concepts that we need to understand to realize the benefits of well designed system development.

Extend Excel with VFP!: Using a Visual FoxPro ComServer with Excel (and other VBA applications)
Rainer Voemel
Most programmers that use VBA are non-IT employees usually, with a marketing, finance, or logistics background trying to automate some reporting tasks. Usually this starts with an Excel spreadsheet and the use of ODBC. With ODBC the user can retrieve results from database queries and create some powerful reports. However, there might be some surprises that will make the user look for a different solution. In my case this was a bug in the VFP ODBC driver when I was using the default settings. The setting Fetch data in background caused the ODBC driver to hang after creating a lot of reports. In my case this was creating a personalized report for roughly 150 recipients. Sometimes after about report 92 the process would hang; at other times this would be around report 102, etc. This made me want to use a VFP ComServer instead of ODBC. After unchecking the ODBC setting Fetch data in the background, the problem vanished, but I now understood the potential benefits of using a ComServer. In addition, the ComServer now has all the SQL features of Visual FoxPro 9, whereas the ODBC driver has not been updated for several years. The ComServer I am using now has about 150 methods. This article describes how to use a Visual FoxPro Comserver with Microsoft Excel.


TOC November 2008 - Number 5

VFPX: Using the BalloonTip
Rick Schummer
The balloon tip control is a nice way to communicate information to the users while they are interacting with the user interface of the application. This month in Rick�s continuing series on VFPX deep dives, he takes a look at the ctl32_BalloonTip control found in the ctl32_StatusBar project up on Codeplex.

Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 1
Doug Hennig
Explorer-style user interfaces are among the most popular for today�s applications. However, working with and integrating the controls necessary to implement an explorer interface can be challenging. This first of a multi-part series presents a set of classes and techniques that makes short work of developing explorer interfaces for your applications.

Kit Box: A Moving Experience
Marcia Akins and Andy Kramek
One question that seems to pop up again and again in various on-line forums is how to create a grid with mover bars that will allow the users to re-sequence the records in the same way that they can in a list box. This month Andy and Marcia discuss how to implement this.

New Ways: Breaking Up is Not Hard to Do
Tamar Granor, Ph D
In my last article, I looked at techniques for reading and writing text files. Once you�ve read a text file into memory, or perhaps created a long string in some other way, its not unusual to need to break it up into lines, or words, or based on some other criteria. Prior to VFP 6, you had to use different approaches depending on the criteria for parsing. With the introduction of the ALINES() function, though, most simple parsing has been reduced to a single function call.

Best Practices: Best Practices Part I
Jim Booth Offsite link to http://www.jamesbooth.com
Programming in Visual FoxPro is not really any different than programming in any other language. Programming languages all have differing syntaxes and the commands and functions vary from one to the other, but the underlying concepts of good programming are universal across all languages. These underlying concepts of good programming are referred to as the Best Practices. In this article series I will be discussing the Best Practices in programming with Visual FoxPro. The Best Practices are the same for all languages; consequently, the only thing that will make this series about Visual FoxPro will be the example code.

TOC September 2008 - Number 4

Intro: Career Investment 101 - How can I become a better developer?
Rick Schummer
Rick gets asked the question: how can I become a better developer? He explains how he attempts to stay at the top of his game in software development.
Complete editorial available at http://www.foxrockx.com.

VFPX: Putting the OutlookNavBar to use
Rick Schummer
The Microsoft Outlook user interface was all the rage a few years ago. The last two versions of Outlook include the navigation bar with separate panes for you to manage email, calendar, contacts, tasks, etc. Developers scrambled to duplicate this interface in VFP applications. Emerson Stanton Reed first created the Outlook2003Bar. This month Rick is going to show you how to implement the most current OutlookNavBar and demonstrate some new flexibility included in the July 2008 release.

Deep Dive: Practical Uses for XML, Part 2
Doug Hennig
In part 1 of this two-part article, Doug examined the basics of XML: what it is, how its structured, how to create XML, and how to parse it. This article focuses on why XML is useful and shows some practical examples of how he�s used XML in various applications.

Kit Box: A program is trying to automatically send e-mail
Marcia Akins and Andy Kramek
Sending E-mail from within an application is often more than a luxury, and there are many ways of doing it in Visual FoxPro. Outlook automation is a common approach and works well, but the version of Collaboration Data Objects that was introduced with Windows 2000 offers a more flexible and extensible approach that allows you to generate E-mail without needing a specific E-mail client installed, or even a work-around for the security patch introduced in Office 2000 SP2. In this months column Andy and Marcia show how to implement CDO in Visual FoxPro.

New Ways: Working with text
Tamar Granor, Ph D
VFPs tools for working with text have improved as the importance of text files has grown. In a world where we need to parse and create HTML, XML, and other text formats, using the best VFP has to offer makes the job a lot easier.

TimeFrame Class - Autoset Past or Future Date Range in Reports
Pradip Acharya
Many financial and forecasting reports require a start date and an end date to be entered in the Report Setup interface. This can be a past or a future time period. A sales summary for the last completed Quarter or a preventive maintenance forecast for the next month are typical examples. It�s not easy for the user to figure out the limiting dates in the first place and secondly, users in general are averse to typing in dates in the stipulated format. The TimeFrame class was created to make it easy to autoset a date range with a click. Select any past or future time period from a dropdown list and the two dates are filled in programmatically. The user can then override either date or select the Open Dates option to enter a date range of choice.


TOC July 2008 - Number 3

VFPX: ctl32_StatusBar Easy to Implement
Rick Schummer
The VFPX project is a set of replacement controls designed to improve the user interface experience of your applications. In this issue of Fox RockX, Rick shows you how simple it is to implement a modern replacement for the Visual FoxPro native status bar.

Deep Dive: Practical Uses for XML, Part 1
Doug Hennig
XML can be a great way to store some types of data or transfer data from one application to another. In the first of a two-part article, Doug discusses what XML is and how to use it.

New Ways: Working with work areas
Tamar Granor, Ph D
Although we have had techniques that let us ignore work area numbers and letters for many versions, some developers still write code that addresses work areas directly. This month, I will look at how to write code without worrying about work area letters or numbers, and how to depend as little as possible on the currently selected work area. The result is better code that is easier to write and maintain.

Kit Box: Doing a PROPER job
Marcia Akins and Andy Kramek
Correctly formatting blocks of text is a problem that we all have to deal with from time to time. While VFP has functions for forcing text to either upper or lower case, its handling of mixed case text suffers from a number of shortcomings that make it essentially unusable in all but the simplest of circumstances. This month Andy and Marcia are discussing the issues surrounding the task of formatting text and come up with a class that does a better job of handling mixed case text.

Vista: Displaying form borders in Windows Vista
Uwe Habermann and Venelina Jordanova
If you are running VFP 9 applications in Windows Vista, you will know the problem. Forms with a Border Style setting other than 3 sometimes appear without a form border. In principle this bug shall have been fixed with VFP 9 SP 2. But then why are the forms often displayed incorrectly?

Events: The DevCon Germany 2007 from a visitors perspective
Boudewijn Lutgerink
While visiting the DevCon Germany last year I took the chance to listen to Steven Blacks sessions about niche markets and So fox is dead, now what?


TOC May 2008 - Number 2

New Ways: Use the right loop for the job
Tamar Granor, Ph D
Learning to use the right loop for the situation will make your code faster and more readable. Both of those goals are worth breaking old habits and building new ones. Happy looping!

New Ways: Stroking the Keys
Jim Booth Offsite link to http://www.jamesbooth.com
The mouse is commonly used for many tasks in windows. In real heads down data entry operations it is often more efficient for the users to keep their fingers on the home row. To accomplish this, it is necessary to provide keystroke equivalents for mouse actions like selecting an item from a menu or clicking on a button, even access to functionality that may not be represented by any menu option or button.

Deep Dive: A Generic Import Utility, Part 2
Doug Hennig
Part 1 of this two-part series presented a set of classes making up a generic import utility you can add to your applications to provide import capabilities from a variety of data sources. Part 2 focuses on the user interface components.

Kit Box: All a matter of form
Marcia Akins, Andy Kramek
This month Andy and Marcia create a class to handle the creation of word documents from templates using named Bookmarks and Tables to indicate where data should be inserted. The class was originally designed for use with Office 2003, but will work without modification in Office XP and Office 2000. It will also work in Office 2007 but, in that version, creates the new ".docx" file type by default.

VFPX: Property / Method Dialog Replacements
Rick Schummer
In the first issue of Fox RockX, Rick provided you an overview of VFPX and the Codeplex Web site where VFPX projects are established and maintained. In this issue he is starting a series of deepdives into the various projects of VFPX with the intent of exposing the productivity you can gain using VFPX tools, and enhance your applications using the various VFPX components. First up are two of the tools he uses numerous times a day: the New Property and Method dialog and the Edit Property/Method dialog replacements.

TOC April 2008 - Free ADS issue

Advantage Database Server for Visual FoxPro Developers
Doug Hennig
Advantage Database Server is a full-featured, high-performance client/server database engine. Interestingly, it can use Visual FoxPro DBF files as its data store and provides a number of benefits over accessing these files directly. This article introduces Advantage and discusses how to access it from VFP applications.

TOC March 2008 - Number 1

VFPX: Open Source Extensions
Rick Schummer
In 2007 I presented a session on VFPX at four Visual FoxPro Conferences in the United States and Europe. During each of the sessions I asked, How many of you have heard of VFPX? Approximately 10 to 15 percent of the people sitting in the room raised their hand. Since I believe VFPX is a significant part of the future of Visual FoxPro, this is a disturbing revelation. The goal of this series of articles is to introduce you to the VFPX open source project, and to do some high level overviews of the different tools and components, as well as some deepdives to show how they can be used in your day-to-day development of Visual FoxPro solutions. This article will describe VFPX, provide a short history of this project, show you where on the Internet you will find VFPX, and provide an overview of the Web site......

Deep Dive: A Generic Import Utility, Part 1
Doug Hennig
Data entry forms arent the only way your users want to put data into their applications. Often, important data is stored in other applications, so you need a way to import that data into your application. This article, part 1 of a two-part series, presents a generic import utility you can add to your applications to provide import capabilities from a variety of data sources......

New Ways: Parsing und Building File and Path Names
Tamar Granor
I started using FoxBase+ nearly 20 years ago. In the evolution from that remarkably able product to Visual FoxPro 9, hundreds, perhaps thousands, of new elements have been added to the FoxPro programming language. Each new version has introduced not only new capabilities, but new ways to do old things.

Kit Box: Managing Global Variables
Marcia Akins, Andy Kramek
The use of Public Variables in FoxPro Applications has long been regarded as poor design. However there are many situations in which a variable that can be accessed, or updated, from anywhere in the application is really the only feasible way of handling things. In this article, Andy and Marcia design a data driven "Variable Manager" class that can be either be instantiated directly, or can be attached to an application object, to manage variables that need to be globally available...

Blog: Advantage Database Server V9.0, available soon
Andy Kramek
Sybase Anywhere have been working on a Visual FoxPro compatible version of the Advantage Database Server for some time and, just before Christmas, the long-awaited Version 9.0 was released in Beta. You can download the Beta version (time limited until mid of March, beta license expiring on March 28th) from here:....

January 30, 2012 02:58 PM

FoxRockXIssues

The 24th regular issue of Fox RockX is available:

January 2012 - Number 24

01 New Ways: Managing Properties as Virtual Table Fields by Pradip Acharya
02 Deep Dive: The ctl32 Library, Part 3 by Doug Hennig
06 Know How: Speed Up Your SQL Code by Tamar Granor, Ph D
09 VFPX: Parallel Fox by Rick Schummer


November 2011 - Number 23

01 New Ways: Foxparse C Library for Handling Strings, Properties and Windows by Pradip Acharya


September 2011 - Number 22

01 Editorial: Totally Marshmallowed? Join us at SWFox DevCon for a refresher! by Rainer Becker
02 Deep Dive: The ctl32 Library, Part 2 by Doug Hennig
07 Know How: Make Your Queries Fly by Tamar Granor, Ph D
11 VFPX: Thor Adding Tools by Rick Schummer
17 Tips & Tricks: Schummer Tips and Tricks by Rick Schummer
19 Tips & Tricks: Report Writer by Cathy Knight
21 Internationalization: Internationalize Your App, Part 1 Entering international characters by Rainer Becker


July 2011 - Number 21

01 Editorial: It's show time again by Rainer Becker
02 Deep Dive: The ctl32 Library, Part 1 by Doug Hennig
07 Know How: Talking to Microsoft Office by Tamar Granor, Ph D
11 Customerizing: Customizing Your Vertical Market Application, Part IV by Cathy Pountney
17 Silverlight: Applications and the local System by Michael Niethammer
21 VFPX: Thor Introduction by Rick Schummer


May 2011 - Number 20

01 Deep Dive: Email and File Transfer the Fast (and Cheap!) Way by Doug Hennig
06 Know How: Build Your Own Project Tools by Tamar Granor, Ph D
13 Customerizing: Customizing Your Vertical Market Application, Part III by Cathy Pountney
17 Tools: dFPUG.fll Version 3 - Zip, Scan and more by Venelina Jordanova and Uwe Habermann and Erich Todt


March 2011 - Number 19

01 Deep Dive: Encryption the Fast (and Cheap!) Way by Doug Hennig
06 Know How: Inside the Object Inspector by Tamar Granor, Ph D
14 Customerizing: Customizing Your Vertical Market Application, Part II by Cathy Pountney
19 VFPX: Vista (and Windows 7) Dialogs via COMtool by Rick Schummer


January 2011 - Number 18

01 Deep Dive: Compression the Fast (and Cheap!) Way by Doug Hennig
06 Know How: Introducing the Object and Collection Inspector by Tamar Granor, Ph D
09 Customerizing: Customizing Your Vertical Market Application, Part I by Cathy Pountney
13 Silverlight: Lightswitch - a first look at the Beta of the new RAD tool by Michael Niethammer
20 Tools: Application String Handling Made Easy with Foxparse C library by Pradip Acharya


November 2010 - Number 17

01 Silverlight: Silverlight Business Applications by Venelina Jordanova and Uwe Habermann.
10 Deep Dive: A More Flexible Report Designer by Doug Hennig.
18 Know How: Understanding Business Objects, Part III by Tamar Granor, Ph D


September 2010 - Number 16

01 Editorial: Rescue in sight with Silverlight by Rainer Becker
02 VFPX: zProc IntelliSense by Rick Schummer
07 Deep Dive: Practical Uses for GDIPlusX, Part III by Doug Hennig
11 Know How: Understanding Business Objects, Part II by Tamar Granor, Ph D
20 Silverlight: SL Data-Binding and Data-Validation by Michael Niethammer


July 2010 - Number 15

01 Silverlight: Silverlight for VFP Developers by Venelina Jordanova and Uwe Habermann
09 VFPX: Code References by Rick Schummer
14 Deep Dive: Practical Uses for GDIPlusX, Part II by Doug Hennig
19 Know How: Understanding Business Objects, Part I by Tamar Granor, Ph D


May 2010 - Number 14

01 Editorial: The Visual FoxPro Roadshow 2010 by Rainer Becker
02 VFPX: OOP Menus by Rick Schummer
08 Deep Dive: Practical Uses for GDIPlusX, Part I by Doug Hennig
13 New Ways: Extending the Toolbox by Tamar Granor, Ph D
18 New Ways: Dating with DBI by Toni Feltman


April 2010 - Free special German issue about ADS
German edition, sponsored by Sybase

01 Advantage Database Server fuer Visual FoxPro Entwickler von Ken Levy


March 2010 - Number 13

01 Editorial: Visual FoxPro Stack Overflow by Ken Levy
02 VFPX: ProjectHookX by Rick Schummer
06 Deep Dive: Introduction to GDIPlusX, Part III by Doug Hennig
11 New Ways: OOP + Metadata = Flexibility by Tamar Granor, Ph D
15 New Ways: Paying it Forward by Toni Feltman


February 2010 - Free special issue about ADS
sponsored by Sybase

01 Advantage Database Server for Visual FoxPro Developers by Ken Levy


January 2010 - Number 12

01 Editorial: Get on the VFPX Bandwagon by Rick Schummer
02 VFPX: SCCText X by Rick Schummer
06 Deep Dive: Introduction to GDIPlusX, Part II by Doug Hennig
13 New Ways: Take adventage of SQL improvements by Tamar Granor, Ph D
17 New Ways: Where�s the Beef? by Jim Booth Offsite link to http://www.jamesbooth.com
19 New Ways: String.Format for VFP by Eric Selje
22 VUProjectTools: Updating project files from the source control management by Uwe Habermann and Venelina Jordanova


December 2009 - Free special issue about VFP.NET

01 VFP.NET by Boudewijn Lutgerink


November 2009 - Number 11

01 Editorial: The history of VFP by Ken Levy (also available in French)
02 VFPX: Control Renamer by Rick Schummer
07 Deep Dive: Introduction to GDIPlusX, Part I by Doug Hennig
13 New Ways: Collections instead of Arrays by Tamar Granor, Ph D
17 Best Practices: Best Practices Part VI by Jim Booth Offsite link to http://www.jamesbooth.com
19 VUProjectTools: Beauty Studio by Uwe Habermann and Venelina Jordanova


September 2009 - Number 10

01 Editorial: New kids on the block by Rainer Becker
02 VFPX: Code Analyst by Rick Schummer
09 Deep Dive: Custom UI Controls:SFCombo Tree by Doug Hennig
14 New Ways: The Right Keys are Primary by Tamar Granor, Ph D
18 New Ways: Test Driven Development, After the Fact, Part II by Eric Selje
21 New Ways: ActiveLabel Class - CmdButton Substitute for Forms with the New Look by Pradip Acharya


July 2009 - Number 9

01 Editorial: All You Can Eat! by Rainer Becker
02 VFPX: Tabbing Navigation by Rick Schummer
06 Deep Dive: Custom UI Controls:Splitter by Doug Hennig
10 Best Practices: Best Practices Part V by Jim Booth Offsite link to http://www.jamesbooth.com
13 New Ways: Use the Toolbox! by Tamar Granor, Ph D
20 New Ways: Test Driven Development,After the Fact, Part I by Eric Selje


May 2009 - Number 8

01 Editorial: VFP 9 SP2 News by Rick Schummer
02 VFPX: PEM-Editor by Rick Schummer
10 Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 3 by Doug Hennig
16 Best Practices: Best Practices Part IV by Jim Booth Offsite link to http://www.jamesbooth.com
20 New Ways: Handling Code that Changes at Runtime by Tamar Granor, Ph D
23 New Ways: Use FastNoData to drastically improve form load times by Mike Yearwood


March 2009 - Number 7

01 Editorial: Thanks for the Memories (and all the code)! by Doug Hennig
02 VFPX: Fox Tabs the VFP IDE by Rick Schummer
05 Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 2 by Doug Hennig
11 Kit Box: So Long and Thanks for all the Fish! by Marcia Akins and Andy Kramek
16 New Ways: The Scope of Things by Tamar Granor, Ph D
19 Best Practices: Best Practices Part III by Jim Booth Offsite link to http://www.jamesbooth.com


January 2009 - Number 6

01 Editorial: VFPS: Visual FoxPro Stack by Ken Levy (also available in French and German)
02 VFPX: Using Desktop Alerts by Rick Schummer
06 Kit Box: Take it up with Management by Marcia Akins and Andy Kramek
10 New Ways: From Type to Type by Tamar Granor, Ph D
13 Best Practices: Best Practices Part II by Jim Booth Offsite link to http://www.jamesbooth.com
17 Extend Excel with VFP!: Using a Visual FoxPro ComServer with Excel (and other VBA applications) by Rainer Voemel


November 2008 - Number 5

01 Introduction by Rainer Becker
02 VFPX: Using the BalloonTip by Rick Schummer
08 Deep Dive: Creating Explorer Interfaces in Visual FoxPro, Part 1 by Doug Hennig
15 Kit Box: A Moving Experience by Marcia Akins and Andy Kramek
18 New Ways: Breaking Up is Not Hard to Do by Tamar Granor, Ph D
21 Best Practices: Best Practices Part I by Jim Booth Offsite link to http://www.jamesbooth.com


September 2008 - Number 4

01 Introduction by Rick Schummer
03 VFPX: Putting the OutlookNavBar to use by Rick Schummer
11 Deep Dive: Practical Uses for XML, Part 2 by Doug Hennig
17 Kit Box: A program is trying to automatically send e-mail by Marcia Akins and Andy Kramek
23 New Ways: Working with text by Tamar Granor, Ph D
27 New Ways: Past or Future Date Range in Reports by Pradip Acharya


July 2008 - Number 3

01 Introduction by Rainer Becker
02 VFPX: ctl32_StatusBar Easy to Implement by Rick Schummer
07 Deep Dive: Practical Uses for XML, Part 1 by Doug Hennig
14 New Ways: Working with work areas by Tamar Granor, Ph D
18 Kit Box: Doing a PROPER job by Marcia Akins and Andy Kramek
21 Vista: Displaying form borders in Windows Vista by Uwe Habermann
24 Events: The DevCon Germany 2007 from a visitors perspective by Boudewijn Lutgerink


June 2008 - Free special issue about ADS
German version, sponsored by Sybase

01 Advantage Database Server fuer Visual FoxPro Entwickler by Doug Hennig


May 2008 - Number 2

01 Introduction by Rainer Becker
02 New Ways: Use the right loop for the job by Tamar Granor, Ph D
06 New Ways: Stroking the Keys by Jim Booth Offsite link to http://www.jamesbooth.com
08 Deep Dive: A Generic Import Utility, Part 2 by Doug Hennig
15 Kit Box: All a matter of form by Marcia Akins and Andy Kramek
21 VFPX: Property / Method Dialog Replacements by Rick Schummer


April 2008 - Free special issue about ADS
sponsored by Sybase

01 Advantage Database Server for Visual FoxPro Developers by Doug Hennig


March 2008 - Number 1

01 Introduction, see Fox RockX Introduction by Rainer Becker
02 VFPX: Open Source Extensions by Rick Schummer
09 Deep Dive: A Generic Import Utility, Part 1 by Doug Hennig
15 New Ways: Parsing und Building File and Path Names by Tamar Granor, Ph D
19 Kit Box: Managing Global Variables by Marcia Akins and Andy Kramek
23 Blog: Advantage Database Server V9.0, available soon by Andy Kramek

January 30, 2012 02:55 PM

Beth Massi - Sharing the goodness that is VB

Calling Web Services to Validate Data in Visual Studio LightSwitch

Very often in business applications we need to validate data through another service. I’m not talking about validating the format of data entered – this is very simple to do in LightSwitch -- I’m talking about validating the meaning of the data. For instance, you may need to validate not just the format of an email address (which LightSwitch handles automatically for you) but you also want to verify that the email address is real. Another common example is physical Address validation in order to make sure that a postal address is real before you send packages to it.

In this post I’m going to show you how you can call web services when validating LightSwitch data. I’m going to use the Address Book sample and implement an Address validator that calls a service to verify the data.

Where Do We Call the Service?

In Visual Studio LightSwitch there are a few places where you can place code to validate entities. There are Property_Validate methods and there are Entity_Validate methods. Property_Validate methods run first on the client and then on the server and are good for checking the format of data entered, doing any comparisons to other properties, or manipulating the data based on conditions stored in the entity itself or its related entities. Usually you want to put your validation code here so that users get immediate feedback of any errors before the data is submitted to the server. These methods are contained on the entity classes themselves. (For more detailed information on the LightSwitch Validation Framework see: Overview of Data Validation in LightSwitch Applications)

The Entity_Validate methods only run on the server and are contained in the ApplicationDataService class. This is the perfect place to call an external validation service because it avoids having clients calling external services directly -- instead the LightSwitch middle-tier makes the call. This gives you finer control over your network traffic. Client applications may only be allowed to connect to your intranet internally but you can allow external traffic to the server managing the external connection in one place.

Calling Web Services

There are a lot of services out there for validating all sorts of data and each service has a different set of requirements. Typically I prefer REST-ful services so that you can make a simple http request (GET) and get some data back. However, you can also add service references like ASMX and WCF services as well. It’s all going to depend on the service you use so you’ll need to refer to their specific documentation.

To add a service reference to a LightSwitch application, first flip to File View in the Solution Explorer, right-click on the Server project and then select Add Service Reference…

image

Enter the service URL and the service proxy classes will be generated for you. You can then call these from server code you write on the ApplicationDataService just like you would in any other application that has a service reference. In the case of calling REST-ful services that return XML feeds, you can simply construct the URL to call and examine the results. Let’s see how to do that.

Address Book Example

In this sample we have an Address table where we want to validate the physical address when the data is saved. There are a few address validator services out there to choose from that I could find, but for this example I chose to sign up for a free trial of an address validation service from ServiceObjects. They’ve got some nice, simple APIs and support REST web requests. Once you sign up they give you a License Key that you need to pass into the service.

A sample request looks like this:

http://trial.serviceobjects.com/av/AddressValidate.asmx/ValidateAddress?Address=One+Microsoft+Way&Address2=&City=Redmond&State=WA&PostalCode=98052&LicenseKey=12345

Which gives you back the result:

<?xml version="1.0" encoding="UTF-8"?>
<Address xmlns="http://www.serviceobjects.com/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Address>1 Microsoft Way</Address>
    <City>Redmond</City>
    <State>WA</State>
    <Zip>98052-8300</Zip>
    <Address2/>
    <BarcodeDigits>980528300997</BarcodeDigits>
    <CarrierRoute>C012</CarrierRoute>
    <CongressCode>08</CongressCode>
    <CountyCode>033</CountyCode>
    <CountyName>King</CountyName>
    <Fragment/>
  </Address>

If you enter a bogus address or forget to specify the City+State or PostalCode then you will get an error result:

<?xml version="1.0" encoding="UTF-8"?>
<Address xmlns="http://www.serviceobjects.com/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Error>
    <Desc>Please input either zip code or both city and state.</Desc>
    <Number>2</Number>
    <Location/>
  </Error>
</Address>

So in order to interact with this service we’ll first need to add some assembly references to the Server project. Right-click on the Server project (like shown above) and select “Add Reference” and import System.Web and System.Xml.Linq.

image

Next, flip back to Logical View and open the Address entity in the Data Designer. Drop down the Write Code button to access the Addresses_Validate method. (You could also just open the Server\UserCode\ApplicationDataService code file if you are in File View).

image

First we need to import some namespaces as well as the default XML namespace that is returned in the response. (For more information on XML in Visual Basic please see: Overview of LINQ to XML in Visual Basic and articles here on my blog.) Then we can construct the URL based on the entity’s Address properties and query the result XML for either errors or the corrected address. If we find an error, we tell LightSwitch to display the validation result to the user on the screen.

Imports System.Xml.Linq
Imports System.Web.HttpUtility
Imports <xmlns="http://www.serviceobjects.com/">

Namespace LightSwitchApplication
  Public Class ApplicationDataService

    Private Sub Addresses_Validate(entity As Address, results As EntitySetValidationResultsBuilder)
      Dim isValid = False
      Dim errorDesc = ""

      'Construct the URL to call the web service
      Dim url = String.Format("http://trial.serviceobjects.com/av/AddressValidate.asmx/ValidateAddress?" &
                              "Address={0}&Address2={1}&City={2}&State={3}&PostalCode={4}&LicenseKey={5}",
                              UrlEncode(entity.Address1),
                              UrlEncode(entity.Address2),
                              UrlEncode(entity.City),
                              UrlEncode(entity.State),
                              UrlEncode(entity.ZIP),
                              "12345")

      Try
          'Call the service and load the XML result 
Dim
addressData = XElement.Load(url) 'Check for errors first Dim err = addressData...<Error> If err.Any Then errorDesc = err.<Desc>.Value Else 'Fill in corrected address values returned from service entity.Address1 = addressData.<Address>.Value entity.Address2 = addressData.<Address2>.Value entity.City = addressData.<City>.Value entity.State = addressData.<State>.Value entity.ZIP = addressData.<Zip>.Value isValid = True End If Catch ex As Exception Trace.TraceError(ex) End Try If Not (isValid) Then results.AddEntityError("This is not a valid US address. " & errorDesc) End If End Sub End Class End Namespace

Run it!

Now that I’ve got this code implemented let’s enter some addresses on our contact screen. Here I’ve entered three addresses, the first two are legal and the last one is not. Also notice that I’ve only specified partial addresses.

image

If I try to save this screen, an error will be returned from the service on the last row. LightSwitch won’t let us save until the address is fixed.

image

If I delete the bogus address and save again, you will see that the other addresses were verified and all the fields are updated with complete address information.

image

Wrap Up

I hope this gives you a good idea on how to implement web service calls into the LightSwitch validation pipeline. Even though each service you use will have different requirements on how to call them and what they return, the LightSwitch validation pipeline gives you the necessary hooks to implement complex entity validation easily.

Enjoy!

by Beth Massi at January 30, 2012 02:15 PM

Alex Feldstein

Photo of the day


Palmer Johnson 135' Dragon
Seen at Haulover Cut (Miami)

by Alex Feldstein (noreply@blogger.com) at January 30, 2012 06:00 AM

VisualFoxProWiki

MichaelReynolds

Michael has been developing in FoxPro since it was first introduced as Fox BASE, and was using dBASE II and dBASE III+ prior to that. He's been in computers since 1977, and has also developed (or still is) in Perl/CGI, Visual Basic, VBA, ASP, C#, Cognos, HTML, Java Script, Assembler, RAMIS, FORTRAN, and COBOL. He spent 10 years in the Air Force as a telecommunications and computer technician.

Currently, he's the Database Administrator at Mentor Worldwide, a global manufacturer of various healthcare products, where he specializes in office automation. For example, he developed a fully-automated process that pulls numerous sales reports from Oracle via Cognos Impromptu, that are exported to Visual FoxPro, which then generates formatted Excel spreadsheets, and emails the reports to the global sales force and upper management. He also developed a web-based system that accepts data queries, retrieves the information, and emails the results to the requester, based on various levels of security.

Other organizations he has worked for include Sprint, Deckers Outdoor (Teva, Simple, UGG), and Snohomish County (WA).

Michael's main part-time project is being the Webmaster for his wife, Sue, who is a Master Herbalist. The site is at www.ReynoldsOffice.com, and contains several thousand pages, where about 95% of the site is generated by a FoxPro inventory database, which in turn generates Perl code that provides the web content. The Perl code supports multiple hosted sites, and adjusts the look and feel for each site. He's also a part-time independent developer, and completed a project that assists in Public Works departments throughout the country to become accredited agencies.

January 30, 2012 04:46 AM

January 29, 2012

VisualFoxProWiki

ActiveVFP

Active VFP has always been a community effort.
Thanks to the following FoxPro giants for code and/or ideas that has made AVFP what it is today:

Calvin Hsia
Brian Marquis
Pandelis Tiritas
Rick Strahl
Craig Boyd
Randy Pearson
Maurice De Beijer
Paul James
Ed Rauh

If you examine the source code for Active VFP or visit http://activevfp.codeplex.com you're bound to come across some of their code or influences.

January 29, 2012 07:33 PM

Alex Feldstein

January 28, 2012

VisualFoxProWiki

BlogWatch

Editor comments: Rick Strahl's FoxPro RSS feed moves to Feedburner

Links to blogs that have something to do with VFP, or by VFP folks


Active Blogs See also Twitter Gallery /
Author Home Page Feed
Alex Feldstein http://feeds.feedburner.com/blogspot/alexfeldstein/
Andrew Coates  class= http://blogs.msdn.com/b/acoat/  class=
Andrew MacNeill - AKSEL Solutions http://akselsoft.blogspot.com/
Andrew MacNeill - Learning Visual FoxPro http://learningvfp.blogspot.com/
Andrew MacNeill - Fox Show Pod Cast http://www.thefoxshow.com/
Andy Kramek http://weblogs.foxite.com/andykramek/
 class= Arnon Rotem-Gal-Oz http://www.drdobbs.com/blog/bioPages/author/Arnon/index.jhtml  class= NONE - removed by Dr Dobbs
AtoutFox http://www.atoutfox.org/
Beth Massi http://blogs.msdn.com/b/bethmassi/
Bernard Bout - Making VFP look cool. http://weblogs.foxite.com/bernardbout
Bo Durban http://blog.moxiedata.com/
Boudewijn Lutgerink http://weblogs.foxite.com/boudewijnlutgerink/
Calvin Hsia http://blogs.msdn.com/b/calvin_hsia
 class= Cathy Pountney http://cathypountney.blogspot.com/
Cetin Basoz  class= http://cetinbasoz.wordpress.com/blog  class=
Christof Wollenhaupt http://www.foxpert.com/knowlbits.htm
John Koziol - Gonzo Maximus Blog - Musings on VFP, SDLC, and whatnot http://gonzmax.blogspot.com/
Chris Sainty http://csainty.blogspot.com
Craig Bailey Main blog http://blog.craigbailey.net/
Craig Berntson http://www.craigberntson.com/blog  class=
Craig S Boyd http://www.sweetpotatosoftware.com/SPSBlog/
Dave Bernard http://davebernard.blogspot.com/
Dave Crozier http://www.replacement-software.co.uk/blog
David T Anderson http://detah.blogspot.com/
David Stevenson http://talkingfox.blogspot.com/
 class= DeCiacco.com Blog http://deciacco.com/blog/  class= Down for two weeks was http://deciacco.com/blog/feed/
 class= Del Lee http://deltonlee.blogspot.com/
Doug Hennig http://doughennig.blogspot.com/
Esparta Palma http://weblogs.foxite.com/esparta
Franklin Garz�n http://weblogs.foxite.com/fgarzonhz
Frank Perez http://www.pfsolutions-mi.com/blog/default.aspx
 class= Nancy Folsom http://nancyfolsom.wordpress.com/
Foxite Community Blog -- All http://weblogs.foxite.com/  class=
 class=Guineu Release Blog http://guineu-blog.blogspot.com/
Richard Camelo K. Base - foxpro.catalyst http://foxpro.ntsl119.com/scr/
 class= Joel Leach http://weblogs.foxite.com/joel_leach/default.aspx
Ken Levy http://blogs.msdn.com/b/klevy/
Kevin Cully  class= http://cully.biz
Kevin McNeish  class= MIA, was: http://msmvps.com/kevinmcneish/ MIA
Kevin Ragsdale http://kevinragsdale.net/
Jochen Kirst䴥r (aka JoKi)  class= http://jochen.kirstaetter.name/  class=
Juan Calcagno http://blog.jlcconsulting.com/  class=
Kok Kiet John Jones http://weblogs.foxite.com/kkchan/
 class= Lisa Slater Nicholls http://spacefold.com/lisa/
Martin Salias http://msalias.blogdrive.com/
 class= Martin Pirringer MYSQL Blog (VFP -> MYSQL migration) http://pirringers.com/mysqlblog/
Matt Slay http://mattslay.com/blog
Maurice De Beijer http://msmvps.com/blogs/theproblemsolver/default.aspx
Nadya Nosonovsky http://blogs.lessthandot.com/index.php/All/?disp=authdir&author=218
Patrick Bibro BROKEN: http://bibro.blogspot.com missing
Paul McNett http://paulmcnett.com/cgi-bin/blosxom.cgi
Paul Mrozowski http://www.rcs-solutions.com/blog  class=
 class= PEM Editor (Jim Nelson) http://pemeditor.blogspot.com/
 class= Philadelphia VFP User Group http://vfpphilly.blogspot.com/  class=
ProSys Plus ( Hank Fay ) http://www.prosysplus.net/blog/pspblog.html  class= Offline
Rahul Desai http://RahulBlog.nationalcom.com
Rick Borup http://rickborup.blogspot.com/
Rick Schummer Shedding Some Light v2.0  class= http://www.rickschummer.com/blog
http://rickschummer.com/blog2/index.php  class=

Rick Strahl General/.NET http://www.west-wind.com/WebLog/default.aspx
Rick Strahl FoxPro/Web Connection http://www.west-wind.com/wconnect/WebLog/default.blog [UPDATED]
 class= Rod Paddock OLDER: http://blogs.officezealot.com/rod/

OLD: http://codebetter.com/blogs/rodpaddock/Default.aspx

NEW: http://www.lostechies.com/blogs/rodpaddock/default.aspx
Ronald Ramirez Moran http://weblogs.foxite.com/dlanorok
Sergey Berezniker class= http://sergey.berezniker.com
Simon Arnold http://weblogs.foxite.com/simonarnold/
 class= Southwest Fox http://www.swfox.net/blog/
Stephen Bodnar http://www.geeksandgurus.com/blogs/sjb/
Steve Davis http://foxpro-optimal.blogspot.com
 class= Steve Ellenoff http://sellenoff.blogspot.com/
Stuart Dunkeld http://weblogs.foxite.com/stuartdunkeld/
Ted Roche  class= http://blog.tedroche.com/
Tod McKenna TodMeansFox http://blog.todmeansfox.com.  class=
Visionpace Blog http://blog.visionpace.com/
VFP Imaging - GDI+ articles and tips http://weblogs.foxite.com/vfpimaging/
VS DATA Team's Blog http://blogs.msdn.com/b/vsdata/
F 1 Technologies http://f1technologies.blogspot.com/
Randy Jean http://www.randyjean.com
Tom Borgmann Tom's VFP Blog (in German) http://tomsvfpblog.blogspot.com/
Tom Meeks' Beginning Visual FoxPro Tips http://vfpstart.blogspot.com/
William Sanders TerraFox Publishing http://www.terrafox.net/  class=
Victor Espina (in Spanish / en Espanol) http://vespina.blogspot.com/ (not available at this time)
Y Alan Griver http://blogs.msdn.com/b/yag/
Alan Stevens http://netcave.org/
Walt Krzystek http://wkrzystek.blogspot.com/
VFP Developers http://visualfoxpro-developers.com/blog/
Vassilis Aggelakos http://weblogs.foxite.com/vassilisaggelakos/
Mark Gordon http://dotbloat.blogspot.com
Portal Fox (In Spanish)  class= http://www.portalfox.com
Planet FoxPro  class= http://www.tedroche.com/planetfox/
foxpro rss feed agregator
wOOdy's Blog (in German)  class= http://woody-prolib.blogspot.com/

January 28, 2012 11:23 AM

Alex Feldstein

January 27, 2012

VisualFoxProWiki

AnonymousClass

(Please, anyone with more Java experience than I have, feel free to make any adjustements here)

In Java, not all objects must be created from pre-existing, named class definitions. Sometimes it is useful (and convenient) to create an object that is a Sub Class of some class, but which overrides just a couple of properties or methods.

Here is an example (quoted from Software Development Magazine):
public void testConnectToSMCRemoteServer() throws Exception {
  SocketServer server = new SocketServer(){
    public void server(Socket socket) {
      try { socket.close();
      } catch (IOException e) {
      };
    }
  };
  SocketService smc = new SocketService( SMCPORT, server);
  boolean connection = c.connect();
  assertTrue(connection);
}

This example code is creating an Anonymous Class that is a Sub Class of SocketServer, in order to facilitate a test case of the SocketService class.

In the past, I had recognized that VFP supports the same Anonymous Class pattern (is it a pattern?), however I had thought of it as an "Ad Hoc" class definition. Same meaning, different words. (see OOp Terms, Object Oriented Programming)

In VFP, you effectively create an Anonymous Class every time you create a form using MODIFY FORM FormName, since you are able to add and override methods and properties in that form definition; Yet, (even though you could consider the form's .Name property to be the name of an Ad Hoc class) you cannot ever Sub Class that anonymous form class.

January 27, 2012 11:25 AM

The Problem Solver

DotNed Podcast: Koen Zwikstra over Silverlight 5 en de toekomst van Silverlight

Er is weer een nieuwe DotNed podcast online. In deze podcast spreekt Maurice de Beijer met Koen Zwikstra over de recente Silverlight 5 release en hoe de toekomst er voor Silverlight ontwikkelaars uitziet. Verder vertelt hij over Silverlight Spy een runtime inspector waarmee je willekeurige Silverlight applicaties kan inspecteren. Hij kondigt ook nog even aan dat hij druk bezig is met een Spy voor Metro applicaties op Windows 8.

Links:

 

enjoy!

 

TheProblemSolver
DotNetEvents

by Maurice at January 27, 2012 10:39 AM

Alex Feldstein

January 26, 2012

Rick Strahl's FoxPro and Web Connection Web Log

Transparent Bitmaps on Buttons and other Controls

Overlayed bitmaps in FoxPro have always been a royal pain, but in order to make a UI that looks clean, getting some sort of transparency to work with FoxPro controls is pretty important. Although FoxPro supports most common image formats including GIF and PNG that support transparency, the transparency isn't supported everywhere within the product.

Specifically the FoxPro Image control supports transparency of the various transparent image formats. If you load up an image control with a GIF or PNG file, the transparency is preserved and the image displays correctly.

However, displaying transparent images on other controls that have a Picture property, unfortunately doesn't work as smoothly. Specifically, here's an example of what I've been struggling with, which is buttons with associated icons:

ataleoftwobuttons[6] 

The first button doesn't show transparency and looks terrible, while the second button properly shows transparency and appears like it should using one of the approaches mentioned below. Similar situation arises with other controls that have picture properties like OptionButton, Checkboxes. ComboBoxes and Listboxes as well, although it's less of a problem there because the background of lists tend to be white. As a matter of fact all container controls have a picture property and the same rules apply.

By default only the Image control supports transparency properly for all GDI+ image formats.

The good news is that with a bit of trickery you can get FoxPro to render transparent images. The bad news is that there are tradeoffs and extra work required to make it work properly.

Old School Transparency Support: BMP Image

GDI+ image support for non-BMP images is actually a relatively new feature in FoxPro. GDI+ support for graphics was introduced with Visual FoxPro 8. Prior to version 8 only BMP images were directly supported in the product and there are a couple of mechanisms used for handling transparency with BMPs.

The most reliable way to get transparency in FoxPro involves using BMP files and a matching BMP Mask file. The mask file basically holds black dots for each of the pixels that should display and white content for anything that should be transparent. As you might imagine creating MASK files is a pain and adds clutter to your image management - anytime the image changes the mask has to be changed too and keeping things in sync is terrible. To me this has always been a non-starter.

You can also get transparency support with only BMP images. By default BMP images display white pixels as transparent, so as long as you can easily represent your transparent content as white it's easy to do. This is not always so cut and dried however because the image 'content' may also contain white pixels. In this case you can fill the white pixels with a slightly off white color like RGB(254,254,254).

Both of these approaches are painful but they are very reliable. Once you got your image set up it always works without fail. But both approaches require that you at the very least convert them to BMP format and potentially tweak your images for transparency or by creating a mask.

Resource Loading in FoxPro

There's another approach that works in most situations because of a quirk in FoxPro that I just found out about last week. FoxPro loads images as resources and you can trick FoxPro by loading images with transparency by first loading them into an Image control which as mentioned earlier does support transparency. The trick is that you have to load the image into the image control BEFORE it gets loaded into a picture property of another control. The quirk is that FoxPro caches image data once loaded from a path, so loading it into an image control first caches the transparent image which then gets loaded in subsequent loads that reference the same disk image (or compiled in image resource).

The image control has to only be loaded up and the control can then be released. The key is that this 'pre-load' has to happen BEFORE you load the same image into other controls. The image control doesn't need to stick around, so I use a small function that I only need to pass a file path to, create the Image control and set the picture property:

************************************************************************
*  LoadImageResource
****************************************
***  Function: Pre-load an image file so transparency is respected
***    Assume:
***      Pass:
***    Return:
************************************************************************
FUNCTION LoadImageResource(lcFile)
LOCAL loImg as Image
loImg = CREATEOBJECT("Image")
loImg.Picture = FULLPATH("bmps\search_small.png")
ENDFUNC
*   LoadImageResource

When the function exits the Image control is released, but since the image was effectively loaded into the control the image is now cached inside of VFP's image cache. Now when you load an image that has been called with the function into a Picture property of another control like a button it will display GIF and PNG transparency properly.

In an application I tend to have quite a few image resources I need to load up, so centralize one place when I do all the image pre-loading during startup. I create a function that I call from the application's startup, typically right after I display a startup splash screen.

The method is simply a conglomeration of LoadImageResource() calls:

************************************************************************
*  LoadImageResources
****************************************
***  Function: Method is used to load up transparent images into
***            UI. This method should be called on startup
***    Assume:
***      Pass:
***    Return:
************************************************************************
FUNCTION LoadImageResources()
LOCAL loImg as Image

LoadImageResource("bmps\search_small.png")
LoadImageResource("bmps\zipfile.gif")
…
ENDFUNC
*   LoadPictureResources

This is a simple approach that works fine and allows using PNG and GIF images with transparency on buttons and other controls.

Caveats with Preloading

In some instances however you can still end up with non-transparent resources. Basically FoxPro caches resources internally, but there are several ways that resources can get un-cached. Explicitly, if your code calls the CLEAR RESOURCES command anywhere, resources will get released and you'll lose any cached resources at that point. If you go back to a form with a transparent image on a control the image will display again with opaque background. Note that CLEAR RESOURCES is not affected by commands like CLEAR ALL or RELEASE ALL.

Implicitly, FoxPro can on certain occasions also unload its image resources internally when memory is really low. This should be very rare but it's possible and I have seen occasions when this does occur. But it's really rare so it's probably OK to ignore that possibility. If you're concerned about this scenario you can either have some code that calls LoadImageResources() or something like it during certain key application points that fire occasionally to explicitly force reloading of the images, or you can load resources as needed everytime a given form is fired up. This will ensure that resources are always fresh, but keep in mind that this causes some extra overhead.

Summary

I sure wish this was easier to accomplish or more obvious. For the longest time I didn't even know this hack of image pre-loading. The safest solution is to use BMP files, but it's definitely way more convenient to use Web ready files like PNGs or GIFs that support transparency both for designing the icons and re-using them across applications and platforms (Web/Desktop as I do).

Having to pre-load resources for transparent images in this fashion is a big hassle as opposed just loading up image resources directly. And worse it's an ugly hack that's impossible to discover on your own. I found a vague reference to this on a message board message somewhere so it's even hard to search for. Hopefully this blog entry will help clarfiy the subject a little better, even if it's just for me to remember in the future.

What really sucks about this problem is the fact that it DOES works with preloaded image resources. This seems to suggest that transparency actually works on controls but there's a small implementation detail in Visual FoxPro that prevents this from working all the time. It seems this would have been such a minor thing for the Fox team to fix and get working out of the box if the resources to do so had been there. But alas, we're stuck with a few minor and undiscoverable hacks. I take a hack over it not working at all which was what I thought until a week ago.

Thanks to Cesar Chalom, Joel Leach, Dragan Nedeljkovich for providing some ideas for this post and Mike Lewis for providing the inspiration to look further into this and getting me to a working solution in Html Help Builder.


by Rick Strahl at January 26, 2012 11:19 PM

Transparent Bitmaps on Buttons and other Controls

Overlayed bitmaps in FoxPro have always been a royal pain, but in order to make a UI that looks clean, getting some sort of transparency to work with FoxPro controls is pretty important. Although FoxPro supports most common image formats including GIF and PNG that support transparency, the transparency isn't supported everywhere within the product.

Specifically the FoxPro Image control supports transparency of the various transparent image formats. If you load up an image control with a GIF or PNG file, the transparency is preserved and the image displays correctly.

However, displaying transparent images on other controls that have a Picture property, unfortunately doesn't work as smoothly. Specifically, here's an example of what I've been struggling with, which is buttons with associated icons:

ataleoftwobuttons[6] 

The first button doesn't show transparency and looks terrible, while the second button properly shows transparency and appears like it should using one of the approaches mentioned below. Similar situation arises with other controls that have picture properties like OptionButton, Checkboxes. ComboBoxes and Listboxes as well, although it's less of a problem there because the background of lists tend to be white. As a matter of fact all container controls have a picture property and the same rules apply.

By default only the Image control supports transparency properly for all GDI+ image formats.

The good news is that with a bit of trickery you can get FoxPro to render transparent images. The bad news is that there are tradeoffs and extra work required to make it work properly.

Old School Transparency Support: BMP Image

GDI+ image support for non-BMP images is actually a relatively new feature in FoxPro. GDI+ support for graphics was introduced with Visual FoxPro 8. Prior to version 8 only BMP images were directly supported in the product and there are a couple of mechanisms used for handling transparency with BMPs.

The most reliable way to get transparency in FoxPro involves using BMP files and a matching BMP Mask file. The mask file basically holds black dots for each of the pixels that should display and white content for anything that should be transparent. As you might imagine creating MASK files is a pain and adds clutter to your image management - anytime the image changes the mask has to be changed too and keeping things in sync is terrible. To me this has always been a non-starter.

You can also get transparency support with only BMP images. By default BMP images display white pixels as transparent, so as long as you can easily represent your transparent content as white it's easy to do. This is not always so cut and dried however because the image 'content' may also contain white pixels. In this case you can fill the white pixels with a slightly off white color like RGB(254,254,254).

Both of these approaches are painful but they are very reliable. Once you got your image set up it always works without fail. But both approaches require that you at the very least convert them to BMP format and potentially tweak your images for transparency or by creating a mask.

Resource Loading in FoxPro

There's another approach that works in most situations because of a quirk in FoxPro that I just found out about last week. FoxPro loads images as resources and you can trick FoxPro by loading images with transparency by first loading them into an Image control which as mentioned earlier does support transparency. The trick is that you have to load the image into the image control BEFORE it gets loaded into a picture property of another control. The quirk is that FoxPro caches image data once loaded from a path, so loading it into an image control first caches the transparent image which then gets loaded in subsequent loads that reference the same disk image (or compiled in image resource).

The image control has to only be loaded up and the control can then be released. The key is that this 'pre-load' has to happen BEFORE you load the same image into other controls. The image control doesn't need to stick around, so I use a small function that I only need to pass a file path to, create the Image control and set the picture property:

************************************************************************
*  LoadImageResource
****************************************
***  Function: Pre-load an image file so transparency is respected
***    Assume:
***      Pass:
***    Return:
************************************************************************
FUNCTION LoadImageResource(lcFile)
LOCAL loImg as Image
loImg = CREATEOBJECT("Image")
loImg.Picture = FULLPATH("bmps\search_small.png")
ENDFUNC
*   LoadImageResource

When the function exits the Image control is released, but since the image was effectively loaded into the control the image is now cached inside of VFP's image cache. Now when you load an image that has been called with the function into a Picture property of another control like a button it will display GIF and PNG transparency properly.

In an application I tend to have quite a few image resources I need to load up, so centralize one place when I do all the image pre-loading during startup. I create a function that I call from the application's startup, typically right after I display a startup splash screen.

The method is simply a conglomeration of LoadImageResource() calls:

************************************************************************
*  LoadImageResources
****************************************
***  Function: Method is used to load up transparent images into
***            UI. This method should be called on startup
***    Assume:
***      Pass:
***    Return:
************************************************************************
FUNCTION LoadImageResources()
LOCAL loImg as Image

LoadImageResource("bmps\search_small.png")
LoadImageResource("bmps\zipfile.gif")
…
ENDFUNC
*   LoadPictureResources

This is a simple approach that works fine and allows using PNG and GIF images with transparency on buttons and other controls.

Caveats with Preloading

In some instances however you can still end up with non-transparent resources. Basically FoxPro caches resources internally, but there are several ways that resources can get un-cached. Explicitly, if your code calls the CLEAR RESOURCES command anywhere, resources will get released and you'll lose any cached resources at that point. If you go back to a form with a transparent image on a control the image will display again with opaque background. Note that CLEAR RESOURCES is not affected by commands like CLEAR ALL or RELEASE ALL.

Implicitly, FoxPro can on certain occasions also unload its image resources internally when memory is really low. This should be very rare but it's possible and I have seen occasions when this does occur. But it's really rare so it's probably OK to ignore that possibility. If you're concerned about this scenario you can either have some code that calls LoadImageResources() or something like it during certain key application points that fire occasionally to explicitly force reloading of the images, or you can load resources as needed everytime a given form is fired up. This will ensure that resources are always fresh, but keep in mind that this causes some extra overhead.

Summary

I sure wish this was easier to accomplish or more obvious. For the longest time I didn't even know this hack of image pre-loading. The safest solution is to use BMP files, but it's definitely way more convenient to use Web ready files like PNGs or GIFs that support transparency both for designing the icons and re-using them across applications and platforms (Web/Desktop as I do).

Having to pre-load resources for transparent images in this fashion is a big hassle as opposed just loading up image resources directly. And worse it's an ugly hack that's impossible to discover on your own. I found a vague reference to this on a message board message somewhere so it's even hard to search for. Hopefully this blog entry will help clarfiy the subject a little better, even if it's just for me to remember in the future.

What really sucks about this problem is the fact that it DOES works with preloaded image resources. This seems to suggest that transparency actually works on controls but there's a small implementation detail in Visual FoxPro that prevents this from working all the time. It seems this would have been such a minor thing for the Fox team to fix and get working out of the box if the resources to do so had been there. But alas, we're stuck with a few minor and undiscoverable hacks. I take a hack over it not working at all which was what I thought until a week ago.

Thanks to Cesar Chalom, Joel Leach, Dragan Nedeljkovich for providing some ideas for this post and Mike Lewis for providing the inspiration to look further into this and getting me to a working solution in Html Help Builder.


by Rick Strahl at January 26, 2012 11:19 PM

Beth Massi - Sharing the goodness that is VB

Alex Feldstein

Photo of the day


Limpkin closeup at Green Cay wetlands in Delray, FL

Sometimes the birds are too close in Florida and you cannot fit the whole bird in the image on a prime telephoto lens (shot with 300mm f/4 Nikon lens).

by Alex Feldstein (noreply@blogger.com) at January 26, 2012 10:00 AM

foxpro.catalyst «

MarsMissionTEST

Been playing with jAlbum again.  Check this album for more pics.

by WildFire at January 26, 2012 08:04 AM

January 25, 2012

Chris Sainty

Getting deeper into Open Source

It’s about 8 months since my first contribution to an open source project. It was followed up minutes later by one to reverse all the accidental formatting changes I made. Damn you Visual Studio!

I am happy to say that it was not an isolated contribution though.

Now I am by no means a prolific contributor and my spare time is more often spent tinkering with my own ideas and projects rather than working hard on open source. However, there has been a steady enough flow of pull requests and projects to keep me satisfied that I am at least involved.

RavenDb and Nancy are where most of my focus has been. Two great examples of modern C# open source development.

In my own right there have been RavenDb plugins for Glimpse and MvcMiniProfiler.

Straying from C# there is even a start being made on a Node.js client for RavenDb. Getting started with Node has been an absolute blast, and my first serious attempt at adding a new language to my skill set since C#. Sure I’ve dabbled with jQuery heavy javascript in the past to add a little life to a web page, but truly learning the object model and scoping rules of javascript is a different beast entirely.

Most recently, as in last week, I have been pitching in at Code52, a new idea for this year which tackles a new project every week. It has been very .NET focussed so far, but that is simply a product of the founding core of developers having .NET backgrounds. At the end of the day, the people who are in the chat room at the start of each project are the ones who decide the technology stack. I hope to get them doing a Node project at some point this year.

The project from last week was IdeaStrike a UserVoice inspired (clone?) site that you can simply deploy to AppHarbor and manage yourself to track ideas and gather feedback about your product. You can see it in action at http://ideastrike.apphb.com/.

It uses Nancy and Entity Framework. I wouldn’t call it a best practice example of either at the moment, it is tough to refactor a project that goes from start to finish in a week. It is however a good example of a non-trivial application, with (some) tests, in Nancy.

Even though the week is up, the project does not stop there. People are always welcome to fork, change, commit and send through a pull request.

A full list of previous projects, that will update over the year, can be found at http://code52.org/projects.html.

This week the focus is a cross-platform multiplayer game. Much further out of my comfort zone, but a great chance to learn some XNA, and eventually Android and iOS when those clients are added.

Now this is a fairly reflective post, not my usual style, but the point is really just to spread the word. There are lots of interesting projects around, big and small, in almost any language you care to use. Just pick one and jump in.

by Chris Sainty (noreply@blogger.com) at January 25, 2012 11:07 PM

Ted Roche's weblog

HTML5 Boilerplate

Paul Irish started the idea of an HTML5 Boilerplate, a template to start the basic web application with the common features, and addressed problems, of HTML5 and CSS3.

Behold OpHTML5 logoen Source Power: “my” base CSS for next project, is v 2.0, with 209 well-reviewed commits from 49 practitioners.

There’s a dream team of coders and well-tested code I couldn’t imagine assembling in real life.

Now, there’s a web site that will generate and optionally customize the base templates for you: http://www.initializr.com/

by tedroche at January 25, 2012 02:18 PM

Alex Feldstein

January 24, 2012

foxpro.catalyst «

The Problem Solver

Deploying SqlServerCe with an ASP.NET MVC application

Using Entity Framework Code First together with SqlServerCe is a great way to work with small databases in ASP.NET MVC applications. I have several web applications running on shared hosting sites where SqlServerCe is the database engine under the hood. Deploying is also quite easy. I typically use the build in Publish Web option which works great over FTP.

image

 

When using SqlServerCe you have to make sure you add the deployable dependencies. Forgetting those results in pretty clear error messages.

image

 

However once that is done I always run into another issue. When a page actually tries to use SqlServerCe I will see a security exception:

System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

The solution is simple enough. Go to whatever security portal your provider is using, mine is using Plesk, and make sure the user that is actually running the web site has the required read/write privileges to work with the Bin folder.

 

image

 

 

Enjoy!

 

TheProblemSolver
DotNetEvents

by Maurice at January 24, 2012 10:50 AM

Alex Feldstein

January 23, 2012

VisualFoxProWiki

NameChanges

For a huge number of people changing their name is part of their life; a number that is likely to be underestimated by those who never changed their name. A name change disconnects us from our previous digital identity, because these are still largely linked to ones name. With a new name we partly have to start again building up a new identity and new credibility.

This list contains name changes in the FoxPro community to simplify the task of linking past achievements with current activities.

Current name Previous names
Christof Wollenhaupt Christof Lange
Cathy Knight Cathy Pountney
Toni Feltman Toni Taylor
Toni Taylor-Feltman

May I please ask to add people only with their permission.

January 23, 2012 11:22 PM

VFPSQL-TSQL-Mapping

VFP/SQL functions concordance

This is a table to help people that are converting VFP SQL Statements to SQL Server T-SQL statements.

 class= Set of VFP string functions implemented in T-SQL by Brad Schulz

Handy String Functions


TYPEVFPT-SQL
AutoIncrement field last valueGETAUTOINCVALUESCOPE_IDENTITY() / OUTPUT clause in SQL Server 2005 and up.

[NEW] See also:
Find the IDENTITY value of the last inserted row (discussion on @@IDENTITY, SCOPE_IDENTITY() and IDENT_CURRENT(), and which one to use).

See also http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/
Inline ConditionIIF(condition,true value, false value)CASE WHEN condition THEN true value ELSE false value END
BETWEEN BETWEEN(field,low value, high value)field BETWEEN lowvalue AND highvalue. Better yet, just use the SQL BETWEEN instead of the VFP between() in all cases when writing SQL (VFP or NOT)
True/False.T. / .F.No logical data type
1=1/1=2
Check something is NULLISNULL(checked_value)IS [NOT] NULL this syntax worked in VFP also
Get non NULL value from two expressionsNVL(checked_value,value_if_expression_is_null)

ISNULL(checked_value,value_if_expression_is_null)

Also COALESCE ( expression [ ,...n ] ) - returns the first nonnull expression among its arguments.


String comparison = for partial, == for exact. LIKE is supported since at least VFP v7 -- Mike Yearwood LIKE
Empty Dates{}Not supported. Use NULL instead
 class= Checking for an empty stringEMPTY(fieldname). EMPTY() has never been Rushmore optimizable. Try fieldname = space(len(fieldname)) or UPPER(fieldname) = SPACE(LEN(fieldname)) especially if you have an index on UPPER(fieldname). -- Mike Yearwood LEN(fieldname) = 0
Current Date and TimeDateTime()GetDate() or DATEADD(ms,-DATEPART(ms,GETDATE()),GETDATE()) because GetDate() return datetime with ms
Current DateDate()Date data type doesn't exist
 class= In SQL Server 2008 there are new DATE and TIME types
Add/Subtract from a dateUse arithmetic operators Date() + 1 or Date() - 1 DATEADD(day,1,Getdate()) or to substract use a negative integer
You can directly add/subtract dates from getdate():
select getdate() - 31, getdate() + 30
Regarding the last comment - you can not do this with Dates in SQL Server 2008
see Compatibility Clash in 2008
Compare two dateslogic symbols<,>,=DATEDIFF ( datepart , startdate , enddate )
Date constant or literalcurly braces and an uproot example: {^2006/01/31} Several format with single quotes example: 'April 15, 1998'
'15 April, 1998'
'980415'
'04/15/98'
 class= Get the integer portion of a numberINT()CAST(somenumber AS int)
Convert date to sortable stringDTOS(date-value) CONVERT(char(8), date-value, 112)
Replace text in a stringSTRTRAN()REPLACE()
[NEW] Trim stringLTRIM(), TRIM() or RTRIM(),
ALLTRIM()
LTRIM(), RTRIM(),
LTRIM(RTRIM())
 class= Number of occurrences of a character in a stringOCCURS()
How many occurrences in a string
Pad a string with spacePADR(somestring,numchars)
PADL(somestring,numchars)
CAST(somestring AS char(numchars))
REPLICATE(SPACE(1), numchars - DATALENGTH(somestring )) + somestring , PADR(),PADL(),PADC() ></td></tr>  <tr><td>Convert an integer to fixed length zero padded</td><td>PADL(intval,numchars, '0')<br> </td><td> REPLICATE('0', numchars - DATALENGTH( CAST(intval AS varchar(numchars)) )) + CAST(intval AS varchar(numchars)) </td></tr>  <tr><td>Find text in a string</td><td>AT()<br> $</td><td>CHARINDEX(), PATINDEX()<br> LIKE </td></tr>  <tr><td><img src=
Convert an integer to fixed length zero paddedPADL(intval,numchars, '0')
REPLICATE('0', numchars - DATALENGTH( CAST(intval AS varchar(numchars)) )) + CAST(intval AS varchar(numchars))
Find text in a stringAT()
$
CHARINDEX(), PATINDEX()
LIKE
 class= Return a string within in a stringSUBSTR()SUBSTRING()
A string lengthLEN()DATALENGTH()
LEN() - doesn't count trailing spaces
Checking a list of values[NOT] INLIST(valuelookingfor, testval1, testval2, testval3)
IN / NOT IN works in VFP also
valuelookingfor [NOT] IN (testval1, testval2, testval3)
 class= If value is in another table, then INNER JOIN / LEFT JOIN with IS NULL may be a better alternative
Deleting all recordsZAP [IN nWorkArea | cTableAlias] TRUNCATE TABLE tablename
Determine last query rowcount_TALLY@@ROWCOUNT
Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.CHRTRAN()
Removes all characters from a string except those specified.
[NEW] CHRTRAN(cString, CHRTRAN(cString, cFilter, "), ")Igor's Nikiforov UDF StrFilter
Counts the words in a string.
GETWORDCOUNT()Igor's Nikiforov UDF GetWordCount
Returns a specified word from a string.
GETWORDNUM()Igor's Nikiforov UDF GetWordNum

January 23, 2012 09:06 PM

Ted Roche's weblog

HTML5 reference

There’s a neat new front end to the caniuse.com HTML 5 reference at http://html5please.us/ – it’s hard to keep up on all the browser versions and who does what.

by tedroche at January 23, 2012 06:22 PM

VisualFoxProWiki

CathyPountney

Now known as Cathy Knight!

Cathy Knight (formerly Pountney) has been developing software since 1982 and considers it her passion. She has worked with Fox products since 1989, including 6 months as a contractor on the Fox Team at Microsoft. She speaks at many FoxPro conferences and user groups across the U.S., Canada, and Germany, writes articles for various trade magazines, and has authored and co-authored several books (Making Sense of Sedna and SP2, The Visual FoxPro Report Writer: Pushing it to the Limit and Beyond, Visual FoxPro Best Practices for the Next Ten Years, and Inside FoxPro 2.5 for Dos). Cathy is an eight-time recipient of the prestigious Microsoft Visual FoxPro MVP award which is given by Microsoft to those who are acknowledged by their peers, demonstrate practical expertise providing the highest quality information, and are active technical community leaders who share their experience with peers. Visit her website at www.frontier2000.com or her blog at www.cathypountney.blogspot.com.

January 23, 2012 02:10 PM

The Problem Solver

HTML5, Internet Explorer and automatic updates

One of the problems with HTML5, or development at the cutting edge of the web, has always the need to support a large number of different browsers. Depending on who you ask the numbers will vary slightly but is usually boils down to Internet Explorer being the biggest and Chrome and FireFox each taking quite a big chunk of the stats and the remainder of the browsers filling up the gaps.

image

So that means that any public facing website should at the very least support the three major browsers, not to bad right?

 

Turns out that live isn’t quite as good as that. With Chrome and FireFox most users are at or close to the last revision of the browser but with Internet Explorer this isn’t the case. In fact as the chart below shows the majority is still using IE8 with IE9 only accounting for a little over a third of all IE users.

image

 

So what the big difference?

There are 2 reasons.

First of all IE9 is only available on Windows Vista and Windows 7 and it turns out there is still a substantial number of people using Windows XP. For all those users Internet Explorer 8 is the latest version of the browser they can use. And that is not going to change when Internet Explorer 10 ships. However that number of XP users isn’t that large.

The second and more important reason is that Microsoft doesn’t automatically update Internet Explorer when a newer version is available. You can download it if you want to but if you don’t explicitly do so nothing happens. And by contrast all recent versions of FireFox and Chrome are self updating, so whenever a new version is available it is downloaded without any explicit user action. The benefit is that with both Chrome and FireFox a web developer wanting to do cutting edge HTML5 stuff can be pretty confident that a user has an up to date browser. Well except with Internet explorer that is Sad smile

 

Microsoft has seen the update light

Fortunately that won’t be a problem much longer. Recently Microsoft has announced that it will start auto updating Internet Explorer using Windows Update. So no longer are we dependent on users going in and manually doing an update, instead if they don’t take any action they will be automatically upgraded to the last possible version of IE. This means that we should soon see at leas two thirds of all IE users use IE9, and more important for HTML5 developers, a more compliant browser with a much faster JavaScript engine.

Of course IE9 still isn’t perfect because it supports less HTML5 features than both Chrome and FireFox but the fact that the JavaScript engine is much faster makes it much easier when using polyfills to insert missing pieces. And the fast JavaScript engine and more compliant rendering engine is great news for all web developers Smile

And the this update will mean that adoption of IE10 will be a lot faster when it ships later this year.

 

The auto update doesn’t start worldwide right away. At first it will start in Australia and Brazil only. But when that is done they plan on doing so in more countries around the world.

 

A big step forwards for Microsoft and a huge step forward for HTML5 developers all over the world Open-mouthed smile

 

Enjoy!

 

TheProblemSolver
DotNetEvents

by Maurice at January 23, 2012 10:24 AM

Alex Feldstein

foxpro.catalyst «

VisualFoxProWiki

VFPSQL-TSQL-Mapping

Editor comments: Removed bad link
VFP/SQL functions concordance

This is a table to help people that are converting VFP SQL Statements to SQL Server T-SQL statements.

<new> Set of VFP string functions implemented in T-SQL by Brad Schulz

Handy String Functions


TYPEVFPT-SQL
AutoIncrement field last valueGETAUTOINCVALUESCOPE_IDENTITY() / OUTPUT clause in SQL Server 2005 and up
See also http://blog.sqlauthority.com/2007/03/25/sql-server-identity-vs-scope_identity-vs-ident_current-retrieve-last-inserted-identity-of-record/
Inline ConditionIIF(condition,true value, false value)CASE WHEN condition THEN true value ELSE false value END
BETWEEN BETWEEN(field,low value, high value)field BETWEEN lowvalue AND highvalue. Better yet, just use the SQL BETWEEN instead of the VFP between() in all cases when writing SQL (VFP or NOT)
True/False.T. / .F.No logical data type
1=1/1=2
Check something is NULLISNULL(checked_value)IS [NOT] NULL this syntax worked in VFP also
Get non NULL value from two expressionsNVL(checked_value,value_if_expression_is_null)

ISNULL(checked_value,value_if_expression_is_null)

Also COALESCE ( expression [ ,...n ] ) - returns the first nonnull expression among its arguments.


String comparison = for partial, == for exact. LIKE is supported since at least VFP v7 -- Mike Yearwood LIKE
Empty Dates{}Not supported. Use NULL instead
<new> Checking for an empty stringEMPTY(fieldname). EMPTY() has never been Rushmore optimizable. Try fieldname = space(len(fieldname)) or UPPER(fieldname) = SPACE(LEN(fieldname)) especially if you have an index on UPPER(fieldname). -- Mike Yearwood LEN(fieldname) = 0
Current Date and TimeDateTime()GetDate() or DATEADD(ms,-DATEPART(ms,GETDATE()),GETDATE()) because GetDate() return datetime with ms
Current DateDate()Date data type doesn't exist
<new> In SQL Server 2008 there are new DATE and TIME types
Add/Subtract from a dateUse arithmetic operators Date() + 1 or Date() - 1 DATEADD(day,1,Getdate()) or to substract use a negative integer
You can directly add/subtract dates from getdate():
select getdate() - 31, getdate() + 30
Regarding the last comment - you can not do this with Dates in SQL Server 2008
see Compatibility Clash in 2008
Compare two dateslogic symbols<,>,=DATEDIFF ( datepart , startdate , enddate )
Date constant or literalcurly braces and an uproot example: {^2006/01/31} Several format with single quotes example: 'April 15, 1998'
'15 April, 1998'
'980415'
'04/15/98'
<new> Get the integer portion of a numberINT()CAST(somenumber AS int)
Convert date to sortable stringDTOS(date-value) CONVERT(char(8), date-value, 112)
Replace text in a stringSTRTRAN()REPLACE()
Trim stringTRIM(), RTRIM()
ALLTRIM()
RTRIM()
LTRIM(RTRIM())
<new> Number of occurrences of a character in a stringOCCURS()
How many occurrences in a string
Pad a string with spacePADR(somestring,numchars)
PADL(somestring,numchars)
CAST(somestring AS char(numchars))
REPLICATE(SPACE(1), numchars - DATALENGTH(somestring )) + somestring , PADR(),PADL(),PADC() ></td></tr>  <tr><td>Convert an integer to fixed length zero padded</td><td>PADL(intval,numchars, '0')<br> </td><td> REPLICATE('0', numchars - DATALENGTH( CAST(intval AS varchar(numchars)) )) + CAST(intval AS varchar(numchars)) </td></tr>  <tr><td>Find text in a string</td><td>AT()<br> $</td><td>CHARINDEX(), PATINDEX()<br> LIKE </td></tr>  <tr><td><NEW=2454148> Return a string within in a string</td><td>SUBSTR()</td><td>SUBSTRING()</td></tr> <tr><td>A string length</td><td>LEN()</td><td>DATALENGTH()<br> LEN() - doesn't count trailing spaces</td></tr>  <tr><td>Checking a list of values</td><td>[NOT] INLIST(valuelookingfor, testval1, testval2, testval3)<br> IN / NOT IN works in VFP also<br> </td><td>valuelookingfor [NOT] IN (testval1, testval2, testval3)<br> <NEW=2454326> If value is in another table, then INNER JOIN / LEFT JOIN with IS NULL may be a better alternative<br> </td></tr>  <tr><td>Deleting all records</td><td>ZAP [IN nWorkArea | cTableAlias]</td><td> <a href=http://codebetter.com/blogs/raymond.lewallen/archive/2005/05/09/62960.aspx>TRUNCATE TABLE</a> tablename</td></tr> <tr><td>Determine last query rowcount</td><td>_TALLY</td><td>@@ROWCOUNT</td></tr> <tr><td>Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.</td><td>CHRTRAN()</td><td></td></tr> <tr><td>Removes all characters from a string except those specified.<br> </td><td>STRFILTER()</td><td><a href=
Convert an integer to fixed length zero paddedPADL(intval,numchars, '0')
REPLICATE('0', numchars - DATALENGTH( CAST(intval AS varchar(numchars)) )) + CAST(intval AS varchar(numchars))
Find text in a stringAT()
$
CHARINDEX(), PATINDEX()
LIKE
<new> Return a string within in a stringSUBSTR()SUBSTRING()
A string lengthLEN()DATALENGTH()
LEN() - doesn't count trailing spaces
Checking a list of values[NOT] INLIST(valuelookingfor, testval1, testval2, testval3)
IN / NOT IN works in VFP also
valuelookingfor [NOT] IN (testval1, testval2, testval3)
<new> If value is in another table, then INNER JOIN / LEFT JOIN with IS NULL may be a better alternative
Deleting all recordsZAP [IN nWorkArea | cTableAlias] TRUNCATE TABLE tablename
Determine last query rowcount_TALLY@@ROWCOUNT
Replaces each character in a character expression that matches a character in a second character expression with the corresponding character in a third character expression.CHRTRAN()
Removes all characters from a string except those specified.
STRFILTER()Handy String functions
Counts the words in a string.
GETWORDCOUNT()Handy String functions
Returns a specified word from a string.
GETWORDNUM()Handy String functions

January 23, 2012 02:08 AM

January 22, 2012

TechSpoken

Walkthrough, Policy Condition: Starting something new and trying to do it right

Things are starting to feel "normal" again here (whatever that means, and it doesn't mean much).  I'm going to post something M would probably have enjoyed, or at least argued with me about -- which amounted to enjoyment for both of us.

I'm trying to use a new-ish feature in SQL Server -- Policy Based Management -- and figuring out the best way to create my own policy condition.  Conditions are a building block of policies, and SQL Server comes with a whole bunch in-the-box.

If you don't see the default set of conditions, you haven't installed the policies that reference conditions.   When you Import Policies from the shipping set (check BOL for the location of these XML files in your SQL Server installation), they drag along the conditions they need.

But what if the conditions you need aren't included?  That's when the fun begins.  As usual in SQL Server, there are probably at least 5 ways to express the conditions you'll want to check; what's the best way? 

I'll walk through creating a condition here, and show you how I made a design decision when face with such a choice. 

Setup/requirements

The example policy and its underlying conditions that I'll use in this walkthrough aren't available in-the-box, as far as I could tell.  That's probably because this example checks for a problem that's incredibly stupid. Nobody should ever have it. 

On the other hand, that doesn't mean this is not a real (and realistic) example.  This problem does happen in my environment and maybe it happens in yours, too.

So here we go.

The problem to be solved, aka the policy to be checked:
System Databases containing User Code

Yeah, it's sad but true: there are several people who:

  •  have the rights to deploy code in my various SQL environments;
  • deploy objects manually, and ;
  • sometimes make mistakes. 

Specifically, they sometimes deploy the object without setting the right database context first.

They usually figure it out right away when they try to reference the newly-deployed (or newly-updated) object, and it doesn't do what they expect.  They quickly re-deploy. 

Meanwhile, some of these people have, or used to have, a default database of "Master".  After they've re-deployed, they're often blissfully ignorant of why the first version didn't show up in the correct database as expected, or just don't care. The mistakenly-deployed version is still sitting around in the system database, which just bugs me.

I decided that I wanted to do a periodic check of all my environments of any code in any of the system databases that shouldn't be there. 

Using a Central Management Server, this is easy to do with a SQL statement that hits every server in a managed group.  The statement to check the master database might look like this:

    select @@SERVERNAME as ServerName, count(*) as NonMSCount
    from master.sys.objects 
    where is_ms_shipped = 0

If you want to check all three system databases in one statement, you might write the following:

 

select @@SERVERNAME as ServerName, sum(NonMSCount) from
   (select count(*) as NonMSCount from master.sys.objects
       where
is_ms_shipped = 0
    union all
   
select count(*) from msdb.sys.objects
       where is_ms_shipped = 0 and name not like 'sys%'
    union all
    select count(*) from model.sys.objects
    where is_ms_shipped = 0) xx

... don't get too hung up on the actual SQL statements; I'm sure you can do it better.  The highlighted item, for example, is just my lazy way of accounting for the fact that msdb.dbo.sysdtslog90 is installed on demand with SSIS therefore is_ms_shipped is not 0  --  at least on my local box.  Your mileage may vary. 

The point here is that I am summing three numbers (a count of non-MS-provided database objects in each of the system databases).  If the total is not zero, I'll borrow from the immortal Ricky Ricardo and say "Lisa's got some 'splaining to do." I'm not going to take any automated action, I'm not going to yell at anybody in a grumpy email alert, there may be a good reason for that user code... I just want to review it. OK?

The politics of Policies

Why bother turning this easy code into a Policy?  Why not just issue the statement(s) you see above, manually?

It comes down to the advantage of declaratively, explicitly installing the policy into SQL Server (in this case, via a Central Management Server).  I could run the script every once in a while, and it would have the same result. 

I could even declare the intent in a Sharepoint page, where everybody would know the plan, assuming they read the Sharepoint page... which they will not.

But if I install the policy, with a suitable name, it will carry more weight with the relevant personnel.

Plus, it's actually easier to retrieve and run.

I could do a similar thing by creating a DTSX package and running that at intervals, of course.  It would also be very visible to the same personnel.  I love SSIS. But, in this case, a DTSX would be overkill, harder to maintain, and not nearly as cool, besides.

Policies are a declarative way of exposing, instituting, evaluating, and managing best practices. Unlike SSIS, they don't do anything else, they're tuned for this.

So how do we get started?

Here's the walkthrough

First, you create the conditions you want to check, and then you create the policy that references these conditions.

We have already designed the "conditions" we want to check in our policy, by writing the SQL statements above. 

In typical SQL Server Management Studio style, drill down through the Object Explorer in the Management node, where you'll find a Policy Management area. Opening this, you find Policies, Conditions, and Facets.  Right-click on the Conditions node to start creating a new Condition, and give it a suitable name:  

I've used the facet "Server" here, because it seems most appropriate to me.  Think of this basically as the scope of the command I'm going to run.  I need to run it once per server, not once per database on the server, right?  Hold that thought for a moment.

Note: there are lots of other facets, such as Data File, Application Role, Server Settings, and they all seem disparate, but the same thought process is going to hold true.  If you think of the facet as a collection of something over which you're going to run something like a For each..., you'll probably pick the right facet. 

You'll know if you've picked a really wrong facet for your purpose, in the next step, if the nested dialog doesn't give you any attributes that make sense for the scope you had in mind.  For example, if I pick the facet Remote Service Binding, I'm going to get an attribute called @CertificateUser and another one called @IsAnonymous.  Keep holding that thought.

On the second panel of this dialog, you'll give the condition a good description, I hope.  Take a look at the MS-created ones; they're complete with recommendations, URLs for further reference, etc.

In my screenshot, you can see this isn't a complete condition yet, because I haven't created an expression that represents what this condition is supposed to, well, express.  That's where our "several ways to do something" comes in.  We know what we want to say; how are we going to say it?

Do what the dialog suggests; "Click here to add a clause".  What the heck are you supposed to do here ?  The "Field" dropdown supplies attributes that belong to a Server (our chosen facet), but how do they relate to the SQL we're using for this condition?

 

They don't!  And that's okay.  Press the ellipsis to the right of the Field dropdown to get to the following nested dialog:

 

 

... as you can see, we have the use of a function to execute the SQL statement(s) of our choice.

What should the condition be?

You have at least the following choices:

  • use exactly the second SQL statement I created above, resulting in sum(NonMSCount), a single value (in other words, remove the ServerName column I added, which you won't need and which will make the result of the statement ineligible for a policy condition; only a single value result is allowed).  
    In the condition, you'll be comparing this value, using the = operator, with the expected value of 0 on the right side of the clause.
  • revise the SQL statement I created above to nest ExecuteSql statements in Add() functions, so that you can avoid the unions and the outer Sum().  The Advanced dialog is not exactly fun to type in; it's a little masochistic.  
    However, this  would work, and using the nested functions like this teaches you something about what you can actually do in this syntax, which is a lot, in other scenarios.  Your revision would be:

    Add(
        Add ( ExecuteSql( 'Numeric' , 'select COUNT(*) from model.sys.objects
                                    where is_ms_shipped = 0'),
            ExecuteSql ('Numeric' , 'select COUNT(*) from master.sys.objects
                                     where is_ms_shipped = 0')
            ),

        ExecuteSql('Numeric' , 'select COUNT(*) from msdb.sys.objects
                                 where is_ms_shipped = 0
                                 and name not like '''sys%'')
        )

  • Break up the original SQL statement into three clauses, one for each system database, like this -- I won't repeat the three ExecuteSql expressions under each clause, because you just put each one of the three you see above into each clause, and omit the Add() functions that put them all together above.  The three clauses look like this:

No matter which of the three you choose, once you have a fully-posable condition, you can reference it in a policy.

With any of these methods, once you've created (and saved) your condition, creating the policy based on it is simple:

Right-click on the Policies node in Object Explorer, to create a New Policy similarly to how you created a New Condition.  For our purposes, you just have to choose the condition you created earlier as the correct one to reference for the new policy; nothing else is required and at this level, which method you used to create your conditionn is completely irrelevant: 

 

 So, what difference will it make which method you used to create the condition?

What's the best practice here?

The first attempt I made, simply transferring my compound SQL statement into a single clause, was the easiest one for me to do. I just told the policy to do exactly what I'd been doing manually in SQL Management Studio. If I stopped there, however, I wouldn't really be taking advantage of what policies have to offer in terms of process and management.

The second attempt I made, adding the nested Add() functions, doesn't really provide any particular advantage.  Working through that version (with lots of sidebars and messing about) simply satisfied me with regards to how flexible and useful the condition syntax would be, to move things out of ExecuteSQL when appropriate.

Why did I care about the available condition expression syntax? SQL is easiest for us SQL jocks, but ExecuteSQL conditions can't be put in policies that need to execute on a schedule, rather than On Demand.  Not a big deal in this case, but worth learning for later.

Both of these methods have the same weakness: if the policy check fails, you're not going to know which system database has the errant object.   You're not even going to see anything much in the Evaluation Results dialog, because your Condition field expression is pretty convoluted.

By contrast, when you run a policy based on the third method, all you have to do is look at your results and you can see right away exactly which clause failed: 

Here, we learn that making the condition building blocks more granular is a better practice.  We'll keep that in mind for the future.

One reason you might not want multiple clauses, for some conditions, is that, if one of the clauses can't have an "automatic fix/apply" result, that will take away this type of resolution for all the clauses.  In our example scenario, there's no "automatic fix/apply" for any of our clauses, so there isn't any problem.

Even more ways to muddy the waters

Is "more granular" always better?

You have additional choices, if you want, and if you change the the facet against which you apply the condition:

  • One way to make the policy, and its referenced condition, more granular is to base the condition on the Database facet. When you create the policy using this condition, you have a chance to say against which target databases you want to use it :



    As you can see, you can create a new condition to indicate the correct target databases on the server you're evaluating.  In this case, your new condition to filter the targets could use either the @Name of the database or the @IsSystemObject attribute of the database.

    In this case, I didn't feel that was a correct resolution. Remember: I had a slight exception in the check that I wanted to make for the msdb database; I couldn't execute exactly the same code against each system database.

  • If you want to go all-out-granular, you could even choose to create different conditions, and execute a different policy, for facets aimed at the individual object types: one for Stored Procedure, one for User-Defined Types, etc. But, in my example scenario, declaring a separate policy for each object type would dilute the message my policy is trying to send: it doesn't matter what the object type is, I don't want the individuals in question to even think there is such a distinction.  Object-level is really the wrong scope for my purposes. Not to mention, it would be a PITA for me to evaluate all these policies separately!

 I hope this gives you some ideas about how you might use conditions you design yourself, and how to make some of the design decisions you'll face. 

If you're already using policies, you've probably already figured all this out and don't even realize it can be troublesome.  But I can tell you, when starting out, I looked at available guidance and didn't see what I was looking for.

Going further up and farther in

Using a SQL-based condition is not ideal, and may not take full advantage of what policies have to offer; you can't use them to enforce any policy, not just this one, automatically.  As you can see from the "Apply to targets" mechanism I've just discussed, and because the facets have lots of attributes and the policy condition expression syntax is quite rich, there may definitely be a way to define my condition/rule without using ExecuteSQL at all. 

Maybe I'll check that out some other time -- although I suspect it would run slower, and, in this case, I don't care about the restriction anyway.

Meanwhile, I would like Central Management Server queries and, possibly, policies attached to them, to be more flexible in their results.  What do I mean by that?  I think I'll post a separate example showing you, after thinking it through a little more.

Double-meanwhile, you'll doubtless let me know what you think.

January 22, 2012 06:24 PM

Alex Feldstein

Photo of the day

The guy goes (in a German accent): Hey Franz, meet Mr. Camera Guy!





and that is exactly what he said, in character, no kidding.

Shot at the 2012 Miami Art Deco Weekend on Ocean Drive - SoBe.

by Alex Feldstein (noreply@blogger.com) at January 22, 2012 10:01 AM

foxpro.catalyst «

January 21, 2012

VisualFoxProWiki

CrystalReportsFAQ

I have used Crystal Reports with three VFP applications. For the most part, it is a terrific reporting tool, but I am also aware of its limitations. I have written an FAQ for anyone interested in learning more about it. Please see http://www.ml-consult.co.uk/foxst-19.htm. -- Mike Lewis
The FAQ referred to above has now been updated for Crystal Reports XI (Jan '06)

You can also download a VFP class library that handles a lot of the details of dealing with CR here:
http://www.kirtlandsys.com/Tools%20Page.htm
<< Page not found >> at this link - Paul Mrozowski

 class= The whitepapers on my web site will help you get started. http://www.craigberntson.com -- Craig Berntson

January 21, 2012 04:01 PM

foxpro.catalyst «

VisualFoxProWiki

NameChanges

For a huge number of people changing their name is part of their life; a number that is likely to be underestimated by those who never changed their name. A name change disconnects us from our previous digital identity, because these are still largely linked to ones name. With a new name we partly have to start again building up a new identity and new credibility.

This list contains name changes in the FoxPro community to simplify the task of linking past achievements with current activities.

Current name Previous names
Christof Wollenhaupt Christof Lange

May I please ask to add people only with their permission.

January 21, 2012 10:27 AM

Alex Feldstein

Photo of the day


Lufthansa A380 coming into Miami International from Frankfurt on Dec 23

by Alex Feldstein (noreply@blogger.com) at January 21, 2012 10:00 AM

January 20, 2012

Beth Massi - Sharing the goodness that is VB

Using Different Edit Screens Based on Record Types (Table Inheritance)

I had a reader ask a question this week on how to use Visual Studio LightSwitch to open different Edit Detail screens based on the “type” of record. This is a very common thing to do especially for data models that use table inheritance (or sub-tables). For instance say we are building an application for a pet store to manage their inventory of animals. We need to collect shared properties of all the animals in an Animal table but we also want to set up table inheritance to Fish, Cat and Dog tables which collect specific properties of those types of animals. When a user selects an animal on a search screen, we need to display a screen that lets them work with the correct data from the specific table. LightSwitch provides a “Show as Link” on labels which automatically opens up the default details screen for that entity, but in our case we could have multiple screens. There are also a few techniques you need to know when dealing with these types of relationships in LightSwitch, particularly around the insert pipeline. In this post I will show you how you can achieve this functionality.

Create The Data Model

First let’s start by creating a simple inheritance data model for the pet store. We will build an Animal table that collects general properties of any animal in the store. Then we will build Cat, Dog and Fish tables to collect specific properties of those types of animals. The relationship between the Animal table and the others will be a ‘one to zero or one’ relationship.

For this example, the Animal table has two required properties, Name and Type. Type is a Choice List with the static values “Cat”, “Dog”, “Fish” to correspond to the type of record the animal is. We will use this to drive what records are inserted into which specific table as well as use it to determine which screens to display.

image

Next, create the Cat, Dog and Fish tables to collect properties specific to these types of animals.

image

Finally, set up the relationships from Animal to these tables as a “one to zero or one” relationship with a delete behavior of “Cascade Delete”.

image

Our data model now looks like this.

image

Create the Screens

Next we’ll need to enter new animals into the system. Create a New Data Screen and select Animal as the screen data. When you do this, LightSwitch will include all the one-to-one related tables as fields on the screen. However, we only want to require the user to enter the general Animal properties on this screen. Once they save, we will direct them to the correct Cat, Dog or Fish detail screen. So first delete all the items in the content tree of the Screen Designer except for Name and Type.

image

Next, create an Edit Details Screen and select the Animal screen data again. Name the screen CatDetail and uncheck “Use as Default Details Screen”.

image

Again you will see that LightSwitch reads these special relationships and adds all the fields from all four tables to the screen. We will need to make some changes. First, change the “Type” from an Auto Complete box to a Label. Once the user has entered the type of animal on the New Data screen, it cannot be changed. Next, delete all the fields related to Dog and Fish from the screen.

image

Repeat the same process to create the DogDetail and FishDetail screens, removing the fields from the screen that do not belong.

Finally, add a Search Data Screen and select the Animal as the screen data again. Select the “Name” content item and in the properties window uncheck “Show as Link”.

image

Instead of using the built-in “Show as Link” functionality, we need to create our own command. We can put commands anywhere on the screen and we can show them as buttons or links. (For more information see: “I Command You!” - LightSwitch Screen Commands Tips & Tricks) For instance we could put an edit button on the screen command bar, the grid command bar, or even in the row itself. Let’s add a command into the row itself.

Right-click on the Data Grid Row Command Bar in the content tree and select “Add Button…”. Create a new method called “Edit”.

image

We want to show the command as a link instead of a button so select the button in the content tree and change it to a link.

image

Write the Code

Now we need to write some code to pull this all together. Right-click on the button we just created and select “Edit Execute Code” to open the code editor. Here we will check what type of animal we have to open the corresponding screen.

Private Sub Edit_Execute()
    If Me.Animals.SelectedItem IsNot Nothing Then
        Select Case Me.Animals.SelectedItem.Type
            Case "Cat"
                Me.Application.ShowCatDetail(Me.Animals.SelectedItem.Id)
            Case "Dog"
                Me.Application.ShowDogDetail(Me.Animals.SelectedItem.Id)
            Case "Fish"
                Me.Application.ShowFishDetail(Me.Animals.SelectedItem.Id)
        End Select
    End If
End Sub

Next we need to write similar code on the New Data screen so that it opens the correct detail screen after the user saves a new animal record. Open the CreateNewAnimal screen and in the upper right drop down the “Write Code” button and select the CreateNewAnimal_Saved method. First comment out the call to ShowDefaultScreen and then write code to determine which screen we need to show instead:

Private Sub CreateNewAnimal_Saved()
    Me.Close(False)
    'Application.Current.ShowDefaultScreen(Me.AnimalProperty)

    Select Case Me.AnimalProperty.Type
        Case "Cat"
            Me.Application.ShowCatDetail(Me.AnimalProperty.Id)
        Case "Dog"
            Me.Application.ShowDogDetail(Me.AnimalProperty.Id)
        Case "Fish"
            Me.Application.ShowFishDetail(Me.AnimalProperty.Id)
    End Select
End Sub

Finally, we need to implement a business rule on Animal in the save pipeline. This rule is important so that a new record is added to the correct table based on the animal’s type. That way after the user saves the CreateNewAnimal screen, a record will be written to the correct table and the detail screen will open and allow the user to edit the specific fields in the Cat, Dog or Fish table. Double-click on Animals in the Solution Explorer under the Data Sources/ApplicationData node to open the Data Designer. Drop down the Write Code button and select the Animals_Inserting method and write this code:

Private Sub Animals_Inserting(entity As Animal)
    Select Case entity.Type
        Case "Cat"
            If entity.Cat Is Nothing Then
                entity.Cat = New Cat()
            End If
        Case "Dog"
            If entity.Dog Is Nothing Then
                entity.Dog = New Dog()
            End If
        Case "Fish"
            If entity.Fish Is Nothing Then
                entity.Fish = New Fish()
            End If
    End Select
End Sub

Run it!

Enter new animals on the Create New Animal screen and when you click Save, the correct detail screen will open allowing you to enter more specific details based on the type of animal.

image

On our search screen, we can click the Edit link on any of the rows and it will open to the correct details screen as well.

image

Wrap Up

I hope this post answered the reader’s question on how to open different detail screens depending on the record’s type. All it takes is implementing your own command. I also touched on one to one relationships and how to set up basic table inheritance. I encourage you to experiment more with this type of relationship. They come in particularly handy when you need to extend external data sources with additional properties or when you need to set up inheritance hierarchies. The trick is to get a record inserted into the right table when you insert the master / parent record. I’ll expand on a couple other techniques in a future post.

Enjoy!

by Beth Massi at January 20, 2012 02:59 PM

Alex Feldstein

Photo of the day


Jet ski daredevil at Haulover Cut (shot on Dec 25)
(more of this series in my Gallery)

by Alex Feldstein (noreply@blogger.com) at January 20, 2012 10:00 AM

The Problem Solver

Getting Started with WCF and Rest material

Thanks everyone for joining in with the DevelopMentor webinar I did last night on Getting Started with WCF and Rest.

If you want to take another look at the slides or samples you can download them using the links below:

 

For more info about the WCF Web API you can check the WCF CodePlex site.

 

Enjoy!

 

TheProblemSolver
DotNetEvents

by Maurice at January 20, 2012 08:24 AM

January 19, 2012

Ted Roche's weblog

Jack Frost doodles

Curly-queue frost on window pane

Can't decide if these are palms or Dr. Suess' truffula trees

L pointed out the curious frost that formed on the windows overnight in the sub-zero weather. I can’t decide if Jack Frost was dreaming of palm trees or Dr. Suess’ truffula trees.

by tedroche at January 19, 2012 04:41 PM

FoxCentral News

Html Help Builder 4.66 released

 West Wind Technologies has released version 4.66 of West Wind Html Help Builder. Help Builder produces documentation for Html Help (CHM), Web ready HTML and Word/PDF format for end user applications as well as developer documentation for FoxPro, .NET, Sql Server, Web Services and other environments. Version 4.66 adds many small user interface enhancements to the IDE and a host of new backup and project export features to Zip files. There are also a number of improvement for .NET imports including support for Code Contracts and multiple example code snippets. There are also a host of small UI improvements and a few bug fixes. Help Builder is available as shareware and registered users can download and re-install the latest version.

by West Wind Technologies at January 19, 2012 12:31 PM

Rick Strahl's FoxPro and Web Connection Web Log

How to work around Visual FoxPro's 16 Megabyte String Limit

If you take a look at the Visual FoxPro documentation and the System Limits you find that FoxPro's string length limit is somewhere around ~16mb. The following is from the FoxPro Documentation:

Maximum # of characters per character string or memory variable: 16,777,184

Now 16mb seems like a lot of data, but in certain environments like Web applications it's not uncommon to send or receive data larger than 16 megs. In fact, last week I got a message from a user of our Client Tools lamenting the fact that the HTTP Upload functionality does not allow for uploads larger than 16 megs. One of his applications is trying to occasionally upload rather huge files to a server using our wwHttp class. At the time I did not have a good solution for him due to the 16meg limit.

What does the 16meg Limit really mean?

The FoxPro documentation actually is not quite accurate! You can actually get strings much larger than 16megs into FoxPro. For example you can load up a huge file like the Office 2010 download from MSDN like this:

lcFile = FILETOSTR("e:\downloads\en_office_professional_plus_2010_x86_515486.exe")
? LEN(lcFile)

The size of this string: 681,876,016 bytes or 681megs! Ok that's a little extreme :-) but to my surprise that worked just fine; you can load up a really huge string in VFP if you need to. But when you get over 16megs the behavior of strings changes and you can't do all the things you normally do with strings.

Other operations do not work for example, the following which creates an 18meg string fails:

lcString = REPLICATE("1234567890",1800000)

with "String is too long to fit".

However the following which creates a 25 meg string does work:

lcString = REPLICATE("1234567890",1500000)
lcString = lcString + REPLICATE("1234567890",1000000)
? LEN(lcString)  && 25,000,000

The following is almost identical except it copies the longer string to another string which does not work:

lcString = REPLICATE("1234567890",1500000)
lcNewString = lcString + REPLICATE("1234567890",1000000) 

And that my friends is the real sticking point with large strings. You can create them, but once they get bigger than 16megs you can no longer assign them to a new variable. That might sound easy to avoid but it's actually tough to do. If you pass string to methods it's very likely that they are actually copied into temporary variables or added to another variable in a simulated buffer, and that is typically where large strings fail.

So what can we learn from this:

Doesn't Work:

  • Assigning a massive FoxPro string to another string fails
  • Some FoxPro commands like REPLICATE() can't create output larger than 16 megs

Works:

  • Assigning a massive string from a file using FileToString() works
  • Adding to the same large string (lcOutput = lcOutput + " more text") works and the string can grow
  • Calling methods that manipulate string work as long as the same string is assigned

There are some limitations but knowing that if you work with a single string instance that can grow large is actually good news. What this means is that if you're careful with how you use strings in FoxPro you can fairly easily get around the 16 meg string limit.

This actually worked well for me in the wwHttp class and the POST issue for larger than 16meg files but not string. Internally wwHttp uses a cPostBuffer property to hold the POST data. The failure was occuring in the send code which would copy the string to a temporary string and get the size, then pass that to the WinInet APIs. The fix for this was fairly easy: Rather than creating the temporary variables (which were redundant anyway) I simply used the class property directly throughout the code without any hand off and voila, now wwHttp supports POSTs for greater than 16 megs.

The code I use is kinda ugly because it's doing lots of string concatenation to build up the Post buffer. Something along these lines like this excerpt from wwHttp::AddPostKey:

************************************************************************
* wwHTTP :: AddPostKey
*********************************
***  Function: Adds POST variables to the HTTP request
***    Assume: depends on nHTTPPostMode setting
***      Pass: 
***    Return:
************************************************************************
FUNCTION AddPostKey(tcKey, tcValue, llFileName)
LOCAL lcOldAlias
tcKey=IIF(VARTYPE(tcKey)="C",tcKey,"")
tcValue=IIF(VARTYPE(tcValue)="C",tcValue,"")


IF tcKey="RESET" OR PCOUNT() = 0
   THIS.cPostBuffer = ""
   RETURN
ENDIF

*** If we post a raw buffer swap parms
IF PCOUNT() < 2
   tcValue = tcKey
   tcKey = ""
ENDIF

IF !EMPTY(tcKey)
   DO CASE
    *** Url Encoded
    CASE THIS.nhttppostmode = 1         
         THIS.cPostBuffer = this.cPostBuffer + IIF(!EMPTY(this.cPostBuffer),"&","") + ;
                            tcKey +"="+ URLEncode(tcValue) 
      *** Multi-part formvars and file
    CASE this.nHttpPostMode = 2
      *** Check for File Flag -  HTTP File Upload - Second parm is filename
      IF llFileName
           THIS.cPostBuffer = THIS.cPostBuffer + "--" + MULTIPART_BOUNDARY + CRLF + ;
            [Content-Disposition: form-data; name="]+tcKey+["; filename="] + JUSTFNAME(tcValue) + ["]+CRLF+CRLF
         this.cPostBuffer = this.cPostBuffer + FILETOSTR(FULLPATH(tcValue))
         this.cPostBuffer = this.cPostBuffer + CRLF
      ELSE
           this.cPostBuffer = this.cPostBuffer +"--" + MULTIPART_BOUNDARY + CRLF + ;
            [Content-Disposition: form-data; name="]+tcKey+["]+CRLF+CRLF
         this.cPostBuffer = this.cPostBuffer + tcValue
      ENDIF
   ENDCASE
ELSE
   *** If there's no Key post the raw buffer
   this.cPostBuffer = this.cPostBuffer +tcValue
ENDIF

ENDFUNC

AddPostKey can accept either a string value or a filename to load from. The file loading works by accepting the filename and then directly loading the file from within the function:

this.cPostBuffer = this.cPostBuffer + FILETOSTR(FULLPATH(tcValue))

This works fine because the file is directly loaded up into the buffer with no intermediate string variable.

You cannot however pass a string that is greater than 16 megs into this function because the code that adds the key basically does this with the tcValue parameter:

this.cPostBuffer = this.cPostBuffer + tcValue

which is assigning the larger than 16 meg string (tcValue in this case) to another variable and as discussed earlier that fails with "String too long to fit". Using a string to buffer your output to build up a larger string, there's no workaround for adding a larger than 16 meg string to another variable or buffer using variables. So my code now works with files loaded from disk, but not string parameters

Good but not good enough!

Files for Large Buffers

Based on the earlier examples I showed we know that we can easily load up massive content from a file. Thus FILETOSTR() offers an easy way to serve large files. Knowing that it's possible to build stream like class that allows you to accumulate string content in a file and then later retrieve it. To do this I created a wwFileStream class. Using the class looks like this:

*** Load library
DO wwapi

*** Create 20 meg string
lcString = REPLICATE("1234567890",1500000)
lcString = lcString + REPLICATE("1234567890",500000)

*** Create a stream
loStream = CREATEOBJECT("wwFileStream")

*** Write the 20meg  string
loStream.Write(lcString)

*** Add some more string data
loStream.WriteLine("...added content")

*** Now write a 16meg+ to the buffer as well
loStream.WriteFile("e:\downloads\ActiveReports3_5100158.zip")

*** Works
lcLongString = loStream.ToString()

*** 55+ megs
? loStream.nLength
? LEN(lcLongString)

*** Clear the file (auto when released)
loStream.Dispose()

Using this mechanism you can build up very large strings from files or strings regardless of what the size of the string is.

How wwFileStream works

Internally wwFileStream opens a low level file and tracks the handle. Each Write() operation does an FWRITE() to disk and the handle is released when the class goes out of scope.

The class implementation is pretty straight forward:

*************************************************************
DEFINE CLASS wwFileStream AS Custom
*************************************************************
*: Author: Rick Strahl
*:         (c) West Wind Technologies, 2012
*:Contact: http://www.west-wind.com
*:Created: 01/04/2012
*************************************************************

nHandle = 0
cFileName = "" 
nLength = 0


************************************************************************
*  Init
****************************************
FUNCTION Init()

this.cFileName = SYS(2023)  + "\" +  SYS(2015) + ".txt"
this.nHandle = FCREATE(this.cFileName)
this.nLength = 0

ENDFUNC
*   Init

************************************************************************
*  Destroy
****************************************
FUNCTION Destroy()
this.Dispose()
ENDFUNC
*   Destroy

************************************************************************
*  Dispose
****************************************
FUNCTION Dispose()

IF THIS.nHandle > 0
   TRY
   FCLOSE(this.nHandle)
   DELETE FILE (this.cFileName)
   CATCH
   ENDTRY
ENDIF
this.nLength = 0
ENDFUNC
*   Destroy

************************************************************************
*  Write
****************************************
FUNCTION Write(lcContent)
THIS.nLength = THIS.nLength + LEN(lcContent)
FWRITE(this.nHandle,lcContent)
ENDFUNC
*   Write

************************************************************************
*  WriteLine
****************************************
FUNCTION WriteLine(lcContent)
this.Write(lcContent)
this.Write(CHR(13) + CHR(10))
ENDFUNC
*   WriteLine

************************************************************************
*  WriteFile
****************************************
FUNCTION WriteFile(lcFileName)
lcFileName = FULLPATH(lcFileName)
this.Write(FILETOSTR( lcFileName ))
ENDFUNC
*   WriteFile

************************************************************************
*  ToString()
****************************************
FUNCTION ToString()
LOCAL lcOutput

FCLOSE(this.nHandle)
lcOutput = FILETOSTR(this.cFileName)

*** Reopen the file
this.nHandle = FOPEN(this.cFileName,1)
FSEEK(this.nHandle,0,2)

RETURN lcOutput
ENDFUNC
*   ToString()


************************************************************************
*  Clear
****************************************
FUNCTION Clear()

THIS.Dispose()
THIS.Init()

ENDFUNC
*   Clear

ENDDEFINE
*EOC wwFileStream 

The code is fairly self explanatory. The class creates a file in the temp folder and saves the handle. Any write operation then uses the file handle to FWRITE() either a string or the output from FILETOSTR(). ToString() can be called to retrieve the file, which closes the file, reads it then reopens it and points to the end. When the class is released the handle is closed and the handle released.

Using this class makes it easy to create large strings and hold onto them. The additional advantage is that memory usage is kept low as strings are loaded up only briefly and then immediately written to file and can be released. So if you're dealing with very large strings a class like this is actually highly recommended. In fact Web Connection uses this same approach for file based application output.

A matching MemoryStream Class

While the FileStream class works, it does have some overhead compared to memory based operation especially when you're dealing with small amounts of data. In the wwHttp class for example, I would not want to create a new wwFileStream for each POST operation. 99% of POST ops are going to be light weight, so it makes sense to only use the wwFileStream class selectively.

In order to do this I also created a wwMemoryStream class which has the same interface as wwFileStream and which uses a simple string property on the class to hold data. Since the classes have the same interface they are interchangable in use which makes them easily swappable.

The code for wwMemoryStream looks like this:

*************************************************************
DEFINE CLASS wwMemoryStream AS Custom
*************************************************************
*: Author: Rick Strahl
*:         (c) West Wind Technologies, 2012
*:Contact: http://www.west-wind.com
*:Created: 01/05/2012
*************************************************************

cOutput = ""
nLength = 0

************************************************************************
*  Destroy
****************************************
FUNCTION Destroy()
THIS.Dispose()
ENDFUNC
*   Destroy

************************************************************************
*  Dispose
****************************************
FUNCTION Dispose()
this.cOutput = ""
this.nLength = 0
ENDFUNC
*   Dispose

************************************************************************
*  Clear
****************************************
FUNCTION Clear()
this.cOutput = ""
this.nLength = 0
ENDFUNC
*   Clear

************************************************************************
*  Write
****************************************
FUNCTION Write(lcContent)
this.nLength = this.nLength + LEN(lcContent)
this.cOutput = this.cOutput + lcContent
ENDFUNC
*   Write

************************************************************************
*  WriteLine
****************************************
FUNCTION WriteLine(lcContent)
this.Write(lcContent)
this.Write(CRLF)
ENDFUNC
*   WriteLine

************************************************************************
*  WriteFile
****************************************
FUNCTION WriteFile(lcFileName)
this.Write(FILETOSTR( FULLPATH(lcFileName) ))
ENDFUNC
*   WriteFile

************************************************************************
*  ToString()
****************************************
FUNCTION ToString()
RETURN this.cOutput
ENDFUNC
*   ToString()

ENDDEFINE
*EOC wwMemoryStream 
It's now a cinch to create my class depending on the need.

In wwHttp I use wwMemoryStream by default since it addresses the 99% scenario. I added two properties to wwHttp: oPostStream and cPostStreamClass. The class is set to wwMemoryStream which is the default and can be overridden. Then internally when the time comes to create an instance of the stream class I use:

IF VARTYPE(this.oPostStream) != "O"
   this.oPostStream = CREATEOBJECT(this.cPostStreamClass)
ENDIF

This way the user can easily chose which of the streams to use simply by specifying:

loHttp.cPostStreamClass = "wwFileStream"

What's also nice about this approach is that the mechanism becomes extensible. If you want to store POST vars in another storage format you can simply create another subclass that implements the same methods and now can store your post variables in an INI file or in structured storage etc. Unlikely scenario for POST data, but very useful for other potential data storage scenarios.

BTW, the wwFileStream class is also a fairly useful generic file output tool. If you ever need to write output to files it provides a real easy OO way to do so, cleaning up after itself when you close it. I've used classes like (wwResponseFile) for years in various applications that need to create file output. It's very useful in many situations.

Summary

Even though Visual FoxPro has a 16 meg string limit, you now have some tools in your arsenal to work around this limit and work with larger strings. While you can work with larger strings, keep in mind that once you go past 16 megs you can't assign that string to anything else. It also gets much harder (and slower) to string manipulation on that string once you're beyond VFP's legal limit.

Still it's nice to know that the limit is not a final one and there are ways to work around it.

Resources


by Rick Strahl at January 19, 2012 11:56 AM