Author Archives: admin

Let’s get ready to Roomba

0
Filed under Roomba

I recently picked up one of these little guys after reading what seemed like nothing but 100% good press about them, and a good friend (and a bit of a hacker) saying they worked surprisingly well.

I’d thought about it for some time but always felt like they’d probably not work all that great.

I put a few RSS feeds up on CraigsList and eventually got a hit for an SE for 100$

We’ve had it now for about 2 months, and, well, it’s a bit like Star Wars Episode III. You really wanted it to be good. Hoped for a miracle to wrap things up nicely, but knew deep down, it just wasn’t going to be.

First off, they call it a robotic vacuum, but hold your hand up to the exhaust port and you don’t feel much exhaust. More like what gets blown by one of those cigarette lighter fan things you see in old delivery vans. A robotic sweeper would be more apropos.

The dust bin is also rather small, so it won’t do much cleaning before you end up doing some cleaning. And speaking of cleaning, I’ve never, ever had to brush out the brush in my real vacuum, nor have I ever had to use a pick to untangle hair from around the sweeper axle so it would turn properly. Any more maintenance than changing a bag out every 2-3 months and winding the cord up when I’m done with it is just too much maintenance for a dang vacuum (and some new ones wind the cord for you!).

Further, I’ve got the yellow high capacity battery, but I get a run time of about 30 minutes or less, not even enough to do a room decently. Maybe the battery’s shot, maybe not. Do I really want to pop 50$+ just to find out?

No, even though the SE model is the “third generation” Roomba, this is clear Gen One stuff.

In my mind, a robotic vacuum should:

  • Be about the same size and shape as the Roomba. That I like. Maybe a bit bigger to handle the rest.
  • Have a much bigger bin.
  • Have a more powerful vacuum.
  • Be a tad smarter about where it’s been and where it needs to go.
  • Be able to run for at least 3-4 hours. Long enough to clean, say, 1000-1500 sqft.
  • And of course, it should have built in WIFI!

That said, iRobot may get there eventually. Roombas have been a surprise seller for them, so that bodes well.

In the meantime, there’s that nifty serial port to play with!

Zip Library

0
Filed under ActiveX

I know, there’s a ton of zip libraries out there. And some are actually free, though, typically, those come with some pretty onerous licensing if you intend to use it in a commercial product.

.NET has some built in zip support I believe, but if you’re still playing in ActiveX land, one library to check out is FathZIP.

It’s 79$, is fast, seems very stable, and, the kicker, supports completely in-memory zipping and unzipping, so you don’t actually have to save a file as a temp file just to uncompress it.

Oh, and did I mention it’s 79$!

Excel XLSB Format

0
Filed under Office

For anyone that might not be familiar with the issue yet, Office 12 introduces a rather large number of new file formats.

There are formats that include macros (DOCM, XLSM, etc), formats that explicitly exclude macros (DOCX, XLSX, PPTX), and, for the Excel aficionados out there, a whole new binary format, XLSB.

This new binary format is not the old style XLS format, although both are binary and relatively proprietary. It is, however, based on a ZIP container file, just like the other new Office formats. This is a big difference from the older DOC and XLS files, which were OLE Structured storage files.

Stephane Rodriguez has written an excellent article on Code Project about the new format, with some good info on the old formats too.

Very interesting that the BIN files within the zip container turn out to be OLE Structure Storages almost exactly like what the old formats used, just wrapped up in a ZIP container instead of a Stuctured Storage container.

So much for really simplifying anything.

Fun with the Office 2007 Ribbon

0
Filed under Office

I was trying to exercise the repurposing functionality in the Office 2007 ribbon today.

Specifically, I wanted to intercept the FileDocumentInspect command on the Office Menu.

Now, I’ve already added a button to the ribbon, so I added the <commands> section just like all the examples I’ve found indicate:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
 <ribbon>
  <tabs>
   <tab idMso="TabHome">
    <group id="MyGroup" label="My Controls" insertAfterMso="GroupClipboard">
     <button id="MyButton" label="Hello, Word!"
      imageMso="HappyFace" onAction="HelloMacro" size="large"/>
    </group>
   </tab>
  </tabs>
 </ribbon>
 <commands>
  <command idMso="FileDocumentInspect" onAction="MySub"/>
 </commands>
</customUI>

Run the app, load up Word, no joy.

Is the example I found based on Beta bits? Have I mistyped a quote somewhere?
So I start hunting.

Eventually, I had what you might call an AHA moment.

If you have ever played with the .NET configuration stuff, you know that one of the infuriating aspects of it is that the XML sections can be “positional”, meaning that if you put a particular section after another section, it won’t work, but put it BEFORE and all is good. I suppose there might be a rational explanation for this, and for that matter, I suppose there might be a rational reason I’d want two different files to be distinguishable only by case<g>, but sorry, I just don’t see it.

Anyway, put the commands section BEFORE the ribbon section and all is right in the world again:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">
 <commands>
  <command idMso="FileDocumentInspect" onAction="MySub"/>
 </commands>
 <ribbon>
  <tabs>
   <tab idMso="TabHome">
    <group id="MyGroup" label="My Controls" insertAfterMso="GroupClipboard">
     <button id="MyButton" label="Hello, Word!"
      imageMso="HappyFace" onAction="HelloMacro" size="large"/>
    </group>
   </tab>
  </tabs>
 </ribbon>
</customUI>

Positionally dependent XML. Gotta love it.

Changing an existing group in the Office 2007 Ribbon

0
Filed under Office

I ran into this several weeks ago and initially blew it off as something I was probably not doing right.

I was trying to add my own button to an existing group on one of the Word 2007 tabs.

Nothing I tried would work. I finally gave up and just created a new, 1 button group with my button in it.

Fine.

Today, I ran across this PDF of a presentation by Ken Getz. On one of the slides towards the end, he makes an offhand comment about not being able to customize an existing group in the Ribbon.

Instead, he goes on, you could hide the existing group, and recreate it entirely, then add your own button(s).

He does not recommend doing so, though, because other addin’s might end up wanting to alter the original group and the results would be less that perfect.

So, I guess you just can’t.

Flight Sims

3
Filed under Helicopters

If you’re at all into radio controlled models (specifically planes or helicopters) you need to check out FMS.

Maybe I’m just late to the party with this one. It’s been out in various incarnations for quite some time now.

The website even lists the latest version as being released around July of 2005, but, well, wow!

I got into RC helicopters some time ago, but was always stymied by the process of just getting used to steering the dang thing, mush less hovering, or god forbid, any kind of acrobatics. As the saying goes, Crash a plane, fix a wing, Crash a helicopter, fix the whole damn thing.

So, my models and radio sat for quite some years.

Then I happened into a hobby shop recently and stumbled across an RC flight simulator demo they had going. This was a commercial package weighing in at 200$ but it included a cheap but effective radio control style joystick that plugged into to the PC’s USB port. Now that was hot! Practice flying on a PC but using a radio style joystick.

I came home and started googling.

One thing led to another and I came across the freeware FMS, Flying model Simulator.

A quick install and it was clear this could actually let me learn to fly and get used to the controls enough so that taking the real thing out wouldn’t be as scary as, say that Gem Sweater video.

But what about the controls? I really liked the idea of controlling the simulator with actual RC joysticks, but, I thought, even better if I could actually use my real radio for the controls.

Lo and behold, Simblaster.

For about 40$, you get a usb dongle with an phono style plug that plugs right in the back of my radio (an older model Galaxy Computer 8 PCM, but they’ve got versions for other radios too).

This is one of the few gizmos I’ve bought that has just plain worked, right out of the box, with basically nothing else to do.

A few more weekends getting used to flying a helicopter out and then back at me on the sim and I might just have to take the real model back out the park!

Hummingbird DOCS Open PCDType.tlb

0
Filed under DMS, DOCSOpen, TypeLibs

So I’m moving along quite nicely integrating some code to handle document checkins into the DOCS Open Document Management System via their API, when I hit a nasty little snag.

I try to run the app and get a compile time error at

x$ = string$(78, 10)

Saying that STRING$ is not a valid function.

Huh?!

A little digging and come to find out, the DOCS Open api typelib PCDTYPE.TLB contains a constant definition of STRING. Of course, that is overriding the VBA definition and boom, a problem.

I could go through my app and replace all STRING$ occurrances with VBA.STRING$… I could, but that seems just flat nasty.

Matt Curland’s PowerVB to the rescue again. Load up TLB Editor included with the book, one quick change to rename the bogus constants, and then a good scrubbing of the registry to remove all traces of the old TLB and we’re back in business.

Of course, you wouldn’t want to redistribute the modified TLB file, but, since all the definitions in it are compiled into your VB app, you wouldn’t have to do that anyway.

Technically, you should be able to alter the precedence of references (such that the VBA class definitions would have more weight than the PCDTYPE entries).

Alas, that didn’t seem to work in this case (I’m guessing because the VBA reference is a built in).

Moral: If you’re still messing with VB6 on occasion (I know you’re out there!), Matt’s book is a must have. And you can probably get it cheap on the bargain racks now.

Formatting Code Snippets in a Blog Entry with CSS

0
Filed under Blogging, CSS

Since this blog is a relatively new thing for me, I’ve picked up quite a few tidbits while setting it all up.

One thing I just ran into is formatting code chunks. I’m guessing there’s loads of different ways to do it, but in my case, I just wanted something easy to tag, and with a nice format, but not necessarily “pretty printed” with color, keyword highlighting etc.

In researching it, I came across Nikhil Kothari’s blog. He has a number of nice things there, so check it out for everything else as well, but I noticed he was formatting code almost like what I had in mind.

The CSS he uses is:

pre {
 font: inherit;
 color: inherit;                        
 white-space: inherit;
 margin: 0;
}

The problem I had with this is that it tends to allow the text to flow over past it’s containing block on the right, which, to me, doesn’t look all that good.

Plus, to set off the code more, I’d prefer it indented to the left and right.

A little CSS reading later and I came up with this:

pre {
   font-family: 'Lucida Console', Courier;
   font-size: 10pt;
   color: inherit;
   white-space: no-wrap;
   margin: 0 3em 0 3em;
   overflow: hidden;
}

It gets the font right, the indents right, and just chops the text at the right edge. I suppose for some purposes, it might be better to wrap the code, but at least for what I need right now, it seems perfect.

Just Added: The above doesn’t quite work in all cases. Appearently, in IE6, overflow:hidden isn’t necessarily supported properly. You might also need to specify a Width property. In my case, I used:

pre {                        
   font-family: 'Lucida Console', Courier;
   font-size: 10pt;
   color: inherit;
   white-space: no-wrap;
   margin: 0 3em 0 3em;
width: 80%; overflow: hidden; }

Which seems to do the job just fine.

Indenting

0
Filed under VB Feng Shui

Why is it that VB (and VBScript) seems to be more prone to poor code styling than most other languages.

I suppose it’s likely because Basic is, if I recall correctly, the most widely used language out there. And if something’s that widespread, well, bad things are just bound to happen, and happen more often.

I was looking at some code recently (I read lots of code) and saw this (the function name and a few comments have been removed but otherwise this is exactly as I found it, and I’m not even concerned with what the code does for this purpose):

Function XXXX(Optional AutoRestart As Bo olean = True, Optional CreateNew As Boolean) As Boolean
InitCommonControls
On Error Resume Next
Dim XML             As String
Dim ManifestCheck   As String
Dim strManifest     As String
Dim FreeFileNo      As Integer

If cIDECheck = True Then AutoRestart = False
If AutoRestart = True Then CreateNew = False

XML = (" " & vbCrLf & "<assembly>" & vbCrLf & "<assemblyidentity>" & vbCrLf & "    <description>EXEDESCRIBTION</description>" & vbCrLf & "    <dependency>" & vbCrLf & "    <dependentassembly>" & vbCrLf & "    <assemblyidentity>" & vbCrLf & "    </dependentassembly>" & vbCrLf & "    </dependency>" & vbCrLf & "</assembly>" & vbCrLf & "")

strManifest = App.Path & "\" & App.EXEName & ".exe.manifest"    'set the name of the manifest
ManifestCheck = Dir(strManifest, vbNormal + vbSystem + vbHidden + vbReadOnly + vbArchive) 'check the app manifest file.
If ManifestCheck = "" Or CreateNew = True Then           'if not found.. make a new one
XML = Replace(XML, "EXENAME", App.EXEName & ".exe")             'Replaces the string "EXENAME" with the program's exe file name.
XML = Replace(XML, "EXEVERSION", App.Major & "." & App.Minor & "." & App.Revision & ".0") 'Replaces the "EXEVERSION" string.
XML = Replace(XML, "EXEDESCRIBTION", App.FileDescription)       'Replaces the app Describtion.
FreeFileNo = FreeFile      
If ManifestCheck <> "" Then
SetAttr strManifest, vbNormal
Kill strManifest
End If
Open strManifest For Binary As #(FreeFileNo) 'open the file
Put #(FreeFileNo), , XML    'uses 'put' to set the file content.. note that 'put' (binary mode) is much faster than 'print'(output mode)
Close #(FreeFileNo)         'close the file.
SetAttr strManifest, vbHidden + vbSystem
If ManifestCheck = "" Then
XXXX = False            
Else
XXXX = True
End If
If AutoRestart = True Then  
Shell App.Path & "\" & App.EXEName & ".exe " & Command$, vbNormalFocus  'restart the program and bypass command line parameters (if any)
End                         
End If
Else                'the manifest file exists.
XXXX = True      'return true.
End If
End Function

Now, I’m sure this code functions just fine and is probably quite useful, but how can even the guy that wrote this come back and read it, quickly, 6 months from now?

I indented the same code and took screen shots to compare them side by side (the highlighter is mine):

CodeNoIndent CodeIndent

Note how the highlighter (and your eye) is naturally drawn into the curves of the indentation.

By comparison, the unindented code yields a straight line. There are no clues to tell your eyes where to look.

A guiding principle in feng shui is that straight lines are generally bad. Many books on the subject call them poison arrows because, it’s believed, straight lines tend to direct negative chi (energy) toward whatever they’re pointing at.

In the same way that you generally do not want an arrow straight walkway directly from the street to your front door, you do not want an arrow straight eyeball walkway that directs the eye right by the code it’s supposed to be reading.

Long story short, it’s good to be a lazy programmer, but it’s certainly possible to be too lazy.

Visual Basic’s got a bit of a bad rap as it is. A little less of this might go a long way towards helping that.