VBA ne Perl

osfameron on 2002-05-30T10:22:09

Continuing on my Off-Topic rant: I hate VBA.

On the other hand, I've managed to get a reasonably complex parser written in it.
Taking a name - Osfameron.Adon@mycompany.com - it will split it into First, Mid, and Last names. Trivial? But our email address books have oddities like Dutch names having the prefix added to the first name - Wijnand-van-der.Valk@mycompany.com... And of course these prefixes should be part of the Middle name (to make alphabetising surnames less 'V' heavy...) whereas French prefixes shouldn't ("Le Brun")

With the various rules that we need to follow for this, it's a tricky but fundamentally doable task for Perl and Regular Expressions, but a horrible tarpit for VBA.

On topic?: Perl helped me write this application:

  • First I wrote helper functions to recreate some of the functionality of Perl lists, and to avoid having to manually parse everything in every sub.
  • I've learned how to manipulate lists in Perl, and you can play with lists the Perl way in VBA too, which is invaluable.
  • Perl coding practise encouraged me to split things into subroutines. This is painful in VBA - my colleague who I thought of as a VB guru actually advised me to use Cut and Paste instead in some cases... and I will admit that one Function is about 150 lines long because I just couldn't bear to refactor it. But I tried...
But no matter how you apply the Perlish way to VBA, it is not Perl... Some of the things I missed from Perl were:
  • use strict;
    (I don't think that
    Option Explicit
    is the same)
  • Exception handling a little more sophisticated than
    On Error Goto
  • warnings, diagnostics, helpful error messages.
  • Not having to use the default IDE. (Tasty Vim goodness).
Programmers are always encouraged to learn other languages to get to grips with their features and constructs. I'm wondering whether I could recommend learning VB as a counter-example...?


Prefix parsing

vsergu on 2002-05-30T11:52:53

Isn't there some overlap between Dutch and French surname prefixes? At least de, as in de Klerk and de Gaulle?

Re:Prefix parsing

osfameron on 2002-05-30T13:18:30

Yes, I thought of that only an hour ago... I guess I need a flag for "Dutch style" or "French style" parsing of 'de' prefixes, phew!

French/Dutch Prefix parsing

osfameron on 2002-05-30T15:12:44

Hmmm, in our email address-list most of the names are set up so that
French:   Charles.De-Gaulle
Dutch:    Wijnand-de.Witte
e.g. there are 2 differences:
  1. French 'De' is usually Title Case, while Dutch 'de' is usually lower case.
  2. More consistently, the Dutch name is coded Firstname-de, and the French De-Lastname
I've made use of the 1st fact to make all "De" part of the last name. However I can't use the 2nd fact without a rewrite because of the (rather crufty) procedure I used to parse the names...

It'll do for now (the name coding isn't mission critical though I'd like it to be >99% accurate), and I'll have to spend some time looking at my algorithm.