There is a ton of great .NET content available on the web; everything from simple code snippets to full blown apps. I really appreciate that people put the time into this stuff and make it available. But I have one request: would it kill you to include the namespace references in your sample code? There are thousands of classes in .NET - I hate having to try and figure out where these classes are hiding in order to get my code to compile (esp. since I’m normally looking at this code because I'm not familiar with the class or classes required to do whatever it is I'm trying to accomplish. Having said that, I never realized VS would actually help resolve these references for me. If you right-click on a type (in this case, I right-clicked on File), there is a Resolve Namespace option on the content menu:

 

namespace

Very nice!
 
Categories: .NET

October 15, 2007
@ 09:25 PM
When I was thinking about putting up a blog, one of the things I really debated was if I wanted to create two different blogs: one which focused on VFP, other on .NET. I was (and still am) a bit worried that the VFP content will drive away .NET developers, and the .NET content will scare away VFP developers. Ultimately, I decided to just include both in the same blog. Since I’m using both on a daily basis, there is a lot of overlap for me between the two. Then I’d have to decide which blog a post was more applicable for. And where would I put content that might be applicable to both (for example, I’ve got some things about SQL Server I’m planning on talking about)? Hopefully I can make this interesting to both sets (and if not, that’s OK too). Well, I guess there are probably 3 or 4 people who are like me, using both VFP and .NET so this might be perfect for them .
 
Categories: Other

October 13, 2007
@ 09:58 PM
I sent myself a few code snippets and a couple of blog ideas from work (Outlook using Word integration). To keep the code formatting I just pasted the content into Live Writer and told it to keep the HTML formatting. That turned out to be a bad idea - I forgot what a horrible job Word does with HTML markup. I ended up leaving the code markup as-is, since I don't want to manually reformat it, but I did change the rest of it. Reminder to self: "Don't paste from Word".
 
Categories: Other

A while back I needed a routine which would display the first few hundred characters of a longer chunk of text. Obviously, it's easy enough to do that with the Substring method of a string. However, I wanted to do this on a word boundary (I didn't want to end up with half of the word being displayed). So I wrote a simple routine which broke up the string into an array (using Split()), then rebuilt the string (keeping track of the length along the way). Maybe 25 lines or code or so. It seemed to work OK, so I was good to go.

The other day I realized I needed to adjust the code to strip out HTML markup before displaying the text - you can imagine how "nice" that might look if I happened to chop off an ending tag somewhere. I knew I had a third party library to do this; there are a lot of really useful little routines hiding in the West Wind Web Store .NET 2.0. So I took a look through the library and found what I was looking for. While looking for it, I noticed another routine which appeared to do exactly the same thing I wanted. Except it was like 5 lines and much easier to understand. Doh!

30 seconds later I rewrote my routine. Here it is...

        public static string TruncateString(string source, int maxLength, string ending)
        {
            // Do we even have to truncate it?

            if (source.Length <= maxLength)
                return source;

            string text = source.Substring(0, maxLength);

            text = text.Substring(0, text.LastIndexOf(" ")); 

            return text;
        }


 
Categories: .NET

October 12, 2007
@ 07:56 PM

We had our monthly FoxPro user group meeting last night, and, like always, there were some cool new things shown and talked about that I’ve now got to play with. Cathy Pountney was kind enough to drive over from the Grand Rapids area to do a session on extending VFP 9’s report writer through extensions and hooking into the generation process with listeners. She demo’d some code which added a new print dialog box which allowed the user to pick/configure the printer before printing, being able to print a document range (ex. 1-10, 11), “Print to Fit” which resizes a report to fit on 1 page, duplex printing, booklet printing, and being able to print multiple pages per sheet of paper. Really cool stuff. She’ll be giving this same presentation at Southwest Fox next week, so if you’re planning on going, don’t miss this session.

One of the “hey, I didn’t know about that command” that came up was SYS(2600). This command lets you pass in a integer (pointer) and then returns the memory pointed to by the pointer as a string. It can also write data into the memory point. This is pretty slick since it allows you to easily interface with win32 API calls that require you to pass in pointers to structures, or use API calls that return pointers to structures. By setting/getting this memory as a string, you can then easily parse apart the structure to get the data back.

To be able to do anything useful with this, you’re also going to need the ability to allocate/de-allocate some memory (and get a pointer to it). The easiest way to do this is through a few API calls:

#DEFINE GMEM_ZEROINIT     0x40    && Init memory contents to zero

DECLARE INTEGER GlobalAlloc IN kernel32.dll ;
        INTEGER wFlags, ;
        INTEGER dwBytes       

DECLARE INTEGER GlobalFree IN kernel32.dll ;
        INTEGER hMem 

lnPointer = GlobalAlloc(GMEM_ZEROINIT, 110)

?lnPointer

IF lnPointer > 0

   * You should see a a bunch of squares (nulls)

   ?SYS(2600, lnPointer, 110)
   SYS(2600, lnPointer, 100, REPLICATE("X", 100))

   * Now you should see 100 X's followed by 10 nulls

   ?SYS(2600, lnPointer, 110) 

   GlobalFree(lnPointer)

ENDIF          

A side note: You may see some apps use LocalAlloc/LocalFree instead of GlobalAlloc/GlobalFree. They are essentially the same thing at this point (that is, there isn’t any difference between the two of them). This is one of those “backwards compatibility” things. If you want to know more: http://msdn2.microsoft.com/en-us/library/ms810603.aspx

There were a couple of other cool utilities/products that came up as well that I’ll be trying out/writing about.


 
Categories: VFP

  I was doing some searching the other day for pricing on MSDN Professional vs MSDN Premium editions, comparing what was included, etc. Pro seemed to be around $1000 vs upwards of $2000 for Premium (depending on the specific version picked). Here's a comparision of the differences. For me, I was really hoping to be able to get Vista, Outlook, and things like Expression. Unfortunately, those are only available with the Premium edition. $1000 was doable, but there was no way I was going to spend $2K on software (it's still not a bad deal, all things considered). I could get the Pro version and just buy what I wanted, but that still pushed the price up to the Premium edition range.

I remember running across some great deals for the MSDN Universal subscription a few years ago on E-bay, so I thought I'd poke around there to see if there was something similar for the Premium edition. I ran across an ad for the Premium version for around $950. "Not bad" I thought, then started looking at the description to make sure it wasn't the Educational version or anything weird. Part of the way down I read some of the requirements: I needed to agree to develop a commercial software app., place a product announcement on my website, make a best effort to pass one of the MS software tests.

Hey! That suddenly started sounding really familiar. Yep, those end up being the same requirements for Microsoft's Empower program. That you can get directly from Microsoft. For $375.

Yep, these guys are really just signing you up for the Empower program for a mere $525 more (handling charge, I guess). Un-Effing believable.


 
Categories: Software

October 11, 2007
@ 01:20 AM

Do you remember the show "Connections" with James Burke? It used to be on TLC at some point (according to the linked Wikipedia article, 1997). It was a show about seemingly unrelated things that were all connected. For example, how a Polish dirt farmer in 1743 stubbed his toe on a sharp rock, which led to a nasty infection, which led to someone creating the Pierogi, which led to the German's bombing Pearl Harbor*, which led to the Ironman Triathlon. Or something like that. Anyway, I really thought it was a cool show and it seems software development (and I.T. in general) follow the same sorts of patterns.

Take this blog for example. A set of seemingly disconnected events** led me to it. People have been blogging for years now. I'm a Johnny-come-lately to the game. Why? And why now? For me, it started with e-mail sites like Hotmail being blocked at work...

(for those that don't get the historical set of connections example, take web surfing as another example. How many times have you started searching for some Javascript code only to find yourself 3 hours later at some Japanese midget porn site. That happens at least once a week for me).

* Yes, I know the German's didn't bomb Pearl Harbor. Everyone knows it was the Swedes.

** I reserve the right to jump around a lot. And I'll try to eventually get around to tying everything together. Either that or get bored with the whole thing and stop. Definitely one or the other.


 
Categories: Other

October 8, 2007
@ 09:10 PM

Just a test to see how things look. And check to see if they work. There are still a few issues to iron out, but it's mostly functional.


 
Categories: