Tuesday, February 11, 2014

Plugging Your VBScript Brain into PowerShell

It started with diapers and bottles of milk and soft food.  Then cereal and TV dinners in frotn of a real TV.  Then it was on to C, then C++, then I moved into LISP and Scheme, and AutoLISP and Visual Basic.  Then T-SQL and Batch/Cmd scripting.  Then coffee, and on to Javascript and KiXtart and Perl, and after mor coffee: VBscript.  And after the coffee ran out, it was beer and then PowerShell.  Quick tips, based on my self-conversion efforts thus far:

  1. Start naming your Sub and Function items using PowerShell syntax, but keeping in mind to glue the Noun/Verb scheme using an underscore ("_"), since you cannot use a hyphen for such things in VBScript.  Example:

    Function ComputerModel()
        ...
    End Function


    ...renamed...

    Function Get_ComputerModel()
        ...
    End Function
  2. Use consistent commenting throughout your code.  If you do that, you can more-easily "port" your code between languages (any language, actually).  It also allows for automated self-documentation.  While that may seem like an impressive phrase to toss around at parties (it is, by the say, haw haw, cough cough...) when you starting stacking up code into more complex "solutions", it will pay off handsomely when the suits come knocking for professional-looking docs.
  3. Eat. Drink. Sleep. Find a reason to laugh.

No comments: