Wednesday, May 19, 2010

Perl - Debugging Scripts

Issue: Using perl script and you need help finding a problem.

Quick: Use the built in debugger tools

Visual/Learning:
perl -w scriptName    This will give you warnings about the script if there are any.
perl -d scriptName     Will put you in debug mode
w                               Lists code.  another w lists the next lines of code and so on
.                                 Resets code listing to current execution point
s                                Steps through code
n                               Steps through code and treats subroutines as a single step
p $variableName      Prints value of the variable
x %data                   Prints array data
x \%data                  Prints better looking array contents
b 20                         Set breakpoint at 20
L                           List all break points
d or D                      Deletes breakpoints
c                              Continues to break point
c 12                        Continues to line 12

Some links to debugger tutorials
Short Tutorial
Longer Tutorial

Thursday, May 13, 2010

Regular Expressions Searching

Issue: a "Regular Expression" is a way of building complex searches but they are also confusing to use.  Below are some search expressions that I have found useful.  And links to some tutorials.

Quick/Visual/Learning:

/btarget/b  - will find the whole word target in a text string (works with start/end line, spaces, special char
 examples -- target @target -target-

(^| +)target( +$) - will find target at start/end of line or with spaces before/after. Will not match special characters.
example --    target

Here is a tutorial on regular expression searches

Tuesday, May 11, 2010

Moved Outlook Cached Names (Autocomplete list) To Another Computer

Issue:   You get a new computer (or Outlook Profile) and now Outlook no longer auto completes the frequently used names that you type into the To field.

Quick: go to drive:\Documents and Settings\user name\Application Data\Microsoft\Outlook copy profile name.nk2

Visual/Learning:
Link to Microsoft Tip
-----------text from the link ---------
On the computer with the saved AutoComplete names, go to drive:\Documents and Settings\user name\Application Data\Microsoft\Outlook.


Note Depending on your file settings, this folder might be hidden. To view the files in this folder, do one of the following:

Microsoft Windows XP
Click Start, and then click My Computer.
On the Tools menu, click Folder Options.
Click the View tab, and then, under Advanced settings, under Hidden files and folders, click Show hidden files and folders.

Microsoft Windows 2000
Double-click My Computer on your desktop.
On the Tools menu, click Folder Options.
Click the View tab, and then click Show hidden files and folders.
Right-click profile name.nk2, and then click Copy.



Tip You can copy the file to removable media, such as a floppy disk or a CD, and then copy the file to the correct location on the other computer. Or you can attach the file to an e-mail message and send the message to yourself. On the new computer, open the attachment in Outlook, and then save it to the correct location.


On the computer where you want to populate the AutoComplete feature, copy the file to drive:\Documents and Settings\user name\Application Data\Microsoft\Outlook.

If the Outlook user profile name is different on the computer where you are moving the .nk2 file, you must rename the file with the same Outlook user profile name after you copy it to the correct folder. For example, if you move Kim Akers.nk2 from the original computer with an Outlook user profile name of Kim Akers, and you copy the Kim Akers.nk2 file to the new computer, you must rename it with the Outlook profile name being used on the new computer.

When prompted about replacing the existing file, click Yes.

Open Outlook to view changes.
------------- End Text from link-------------

Wednesday, May 5, 2010

Outlook Forms

Issue:
Quick:
Visual:
Learning:






Upadte Existing Outlook Forms

Issue: You have a bunch of Outlook forms in a folder and you want to update them to a new form layout.

Quick: Download Omsgclas.exe utility

Visual/Learning:
As an example you might have a bunch of help desk forms stored in a folder.  Over time the form layout may change to make the form easier to use.  The problem is that if you need to open an old form the layout is not updated automatically but is the old, harder to use version of the form. 
Microsoft has a knowledge base article on how to fix this (Update existing outlook forms to a new form)
and utility to help as well.

--------------Here is a snipit of text from the Microsoft page on how to do this with a script as well -----
Create a VBScript routine


There are three tasks to this solution.

Create a new item to store the VBScript code.

Enter the VBScript code and save the form.

Run the VBScript code.

Back to the top

Create a new item to store the VBScript code

On the File menu, point to New, and then click Mail Message.

On the Tools menu, point to Forms, and then click Design This Form to enter form design mode.

Back to the top

Enter the VBScript Code and Save the Form

On the Form menu, click View Code.

In the Script Editor, type the following code. You do not need to enter the lines that begin with an apostrophe, since these lines are comments that are ignored when executed.

Sub Item_Open



' Change the following line to your new Message Class

NewMC = "IPM.Contact.MyNewForm"



Set CurFolder = Application.ActiveExplorer.CurrentFolder

Set AllItems = CurFolder.Items

NumItems = CurFolder.Items.Count



' Loop through all of the items in the folder

For I = 1 to NumItems



Set CurItem = AllItems.Item(I)



' Test to see if the Message Class needs to be changed

If CurItem.MessageClass <> NewMC Then



' Change the Message Class

CurItem.MessageClass = NewMC



' Save the changed item

CurItem.Save



End If



Next



MsgBox "Done."



End Sub





On the File menu, click Close.

On the File menu, click Save As. Make sure the default setting for file type is Outlook Template (.oft), and then select a location to save the file. Enter a file name for the form and then click OK.

Close the item by clicking the X in the upper-right corner of the item window and then click No when prompted to save changes.

Back to the top

Run the VBScript code

Open the folder that contains the items you wish to update.

To run the VBScript code, open the item again by using Windows Explorer to locate the file and then double-click the .oft file. The code will run automatically because it was entered into an Item_Open event procedure. If you receive a macro warning, click Enable Macros.

Wait while the code changes the message class for all of the items in the currently selected folder. Depending on the number of items, this may take several minutes. When the code finishes, you should receive a message that says Done.

Note If you wish to edit the VBScript code later to change the name of the message class, hold down the SHIFT key when you open the item. This prevents the VBScript code from executing and you can go into design mode, make changes to the VBScript code, and save the form.
 
------  End of Snipit from Microsoft page --------------