Never be clever

by Peter Tyrrell Monday, February 25, 2008 3:51 PM

When programming, if you don't fully understand some technique, do not use it. And don't mistake intellisense for intelligence.

Case in point.

I wanted to know whether a particular barcode was contained in a list of barcodes. If not in that list, add to another list:

string barcode = "12345";
int index = barcodeList.BinarySearch(barcode);
if (index < 0)

Ooh, binary search. Visual Studio intellisense reports:

List<T>.BinarySearch(T item): Searches the entire sorted List<T> for an element using the default comparer and returns the zero-based index of the comparer.

Sounds good to me. Sign me up!

One teary-eyed debugging session later, as barcodes are being reported NOT found that SHOULD be found, I learn the full truth from MSDN:

BinarySearch() return value is the zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of Count.

Oh... shazbot.

Why didn't I just use List.Contains?

string barcode = "12345";
if (!barcodeList.Contains(barcode))

Because. I am an idiot.



Webpublisher FORCE_CRASH

by Peter Tyrrell Friday, February 22, 2008 4:51 PM

While perusing the Inmagic Webpublisher 10.00 input schema today (yes, that *is* how I like to spend my leisure time), I saw an undocumented action enumeration I've never seen before. Most actions are self-explanatory, like "query" and "insert".

So when I saw this:


how long do you think I sat there, resisting temptation?

Yeah. A fearful age when measured in nanoseconds.

So I hit Webpublisher with FORCE_CRASH a few times to no discernable effect. I was kind of disappointed. Expected sparks to fly out of my hard drive or *something*.


Miraculously clean field names for Inmagic Webpublisher XML

by Peter Tyrrell Thursday, February 21, 2008 3:27 PM

A few months ago I posted a C# routine that replaces diacritic characters with their non-diacritic equivalents. It helped me create valid field names for use with XML requests to Webpublisher, but it wasn't the whole story. There are other commandments that must be followed to get valid field names: spaces shall be replaced with underscores, hyphens shall be replaced with underscores, thou shalt not suffer a digit to start a field name without preceding it with an underscore, etc.

Here's the whole deal, wherein you pass in your unclean field names and get purified field names on the other side.

public static string[] CleanFieldNames(string[] fields)
    string[] output;
    int len = fields.Length;
    string exprStartsWithDigit = @"^\d";
    List<string> list = new List<string>();
    for (int i = 0; i < len; i++)
        string field = fields[i];
        // Replace spaces with underscores
        field = field.Replace(" ", "_");
        // Replace hyphens with underscores
        field = field.Replace("-", "_");
        // Precede digit at start of field name with underscore
        if (Regex.IsMatch(field, exprStartsWithDigit))
            field = string.Concat("_", field);
        // Replace extended chars with non-diacritic equivalent
        field = RemoveDiacritics(field);
    output = new string[list.Count];
    return output;
public static string RemoveDiacritics(string input)
    string stFormD = input.Normalize(NormalizationForm.FormD);
    int len = stFormD.Length;
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < len; i++)
        UnicodeCategory uc = CharUnicodeInfo.GetUnicodeCategory(stFormD[i]);
        if (uc != UnicodeCategory.NonSpacingMark)
    return (sb.ToString().Normalize(NormalizationForm.FormC));

N.B. I always adhere to what Inmagic calls "SOAP Format" when making XML requests to Webpublisher. This means I follow one set of rules as regards field names, and don't have to worry about output schema differences between CS Webpublisher and Dbtext Webpublisher. (CS Webpublisher must adhere to SOAP Format but it's optional with Dbtext Webpublisher.)

Tip: comment out textbase locations in dbtwpub.ini

by Peter Tyrrell Thursday, February 21, 2008 12:40 PM

Comment out a textbase location line in dbtwpub.ini by preceding it with an exclamation point.


!catalog=C:\Program Files\Inmagic\WebPubPro\Textbases

Handy when you want to make a temporary change but want to switch back easy later.

UPDATE: Apparently the semicolon is what folks at Inmagic use to comment out lines in INI files, and is considered standard.

Celebrating our history: City of Burnaby launches new heritage website

by Kathy Bryce Thursday, February 21, 2008 10:37 AM

The City of Burnaby has just launched a new Heritage Burnaby website available at As stated on the website "The goal is to provide a comprehensive and interactive community heritage website that brings together the 'personal history' of our citizens to create a wider understanding and appreciation of our city's 'collective memory'. Through Heritage Burnaby you can experience, learn and research about our community's unique history through online databases and exhibits that provide access to our heritage sites and landmarks, artifact collections, archival collections and the library's history resources."

Andornot Consulting was awarded the contract to provide software and database design services and began working on the project in July 2007. Preliminary design work involved comprehensive user-interface design and work-flow scenarios along with a multitude of data conversions from inter-related Access databases, Excel spreadsheets, and Word documents from the city archives, museum, and planning department. In just over 6 months, the new Heritage Burnaby system was running with multiple search interfaces and eye-catching image displays all seamlessly integrated within the new web site template created by Atomic Crayon.
"Our City's initial project concept of an online database of historic photographs was able to grow far beyond our own expectations through working with Andornot. The team worked to create a website design that took our initial small project to a higher level to provide the public with a user-friendly comprehensive and integrated database of our museum, archives and heritage collections. The framework conceptualized by our staff in concert with Andornot has created a website that allows us ultimate flexibility to continue to create an elaborate online celebration of the cultural heritage of our community". (Jim Wolf, Heritage Planner, City of Burnaby.)
Behind the scenes, the City is running Inmagic Content Server Professional with desktop access to all the databases for administrative staff through CS/TextWorks and web access through the firewall using CS WebPublisher PRO. Andornot was able to speed the development process through the use of several Andornot add-on products such as Archives Online, the WebPublisher Developer Kit (WPDK), and Image Manager. The custom databases created for the museum and heritage landmarks use the same style and structure as Archives Online and both link to shared thesauri for subjects, names, historical and current neighborhoods. The web interface provides multiple methods of accessing the databases with quick and advanced search options, plus canned searches on popular topics, and image maps with embedded canned searches to allow users to quickly find all resources for a particular neighborhood.

Images can be viewed either with brief descriptive information or in a gallery view. Image resizing is handled automatically from one master image and multiple images are displayed on the full displays. (Try the sample search for automobiles in the artifact collection.)

A key feature of the site is the OneSearch capability, allowing users to search across all four of the main collections simultaneously using Andornot's OneSearch add-on.

This has been an incredibly exciting project for Andornot and we have thoroughly enjoyed working with City staff to deliver this project on a very tight schedule so that it could be launched for BC Heritage Week. We had some intense brainstorming sessions which resulted in the expansion of the original scope and many more ideas for continued future developments.
"Working with Andornot was a great experience with a diverse staff team from several civic departments. Andornot met and exceeded all of our expectations for delivery of a comprehensive database product that was user friendly and easy to upload our various data collections and adapt to our new webpages. Our project was infused with a sense of fun and spirit by the Andornot team which is reflected in the website. We could not have chosen a better consultant or product for this project". (Jim Wolf, Heritage Planner, City of Burnaby.)
Please contact us for further information.

Month List