How to make and use file DSNs for Inmagic ODBC

by Peter Tyrrell Sunday, January 25, 2009 12:24 PM

There are three ways to set up a DSN for ODBC connections: System DSN, User DSN, and File DSN. The first two store the connection settings in the registry, while the third stores all the connection info in a text file. The latter can be easily copied, filed with its parent project, put in source control, and modified by a build process. Plus just having that file there is a reminder that an ODBC connection is an application requirement. (Oh, I *have* forgotten.)

Create the file DSN

You can create a file DSN by opening the ODBC Data Source Administrator dialog (listed as "Data Sources (ODBC)" from the Windows Start Menu), but I have encountered problems doing it that way.* It's easy to do from scratch, anyway.

  1. Create a text file with a .dsn extension: MyFileDsn.dsn
  2. Fill in the contents as follows:
   1: [ODBC]
   2: DRIVER=Inmagic DB/Text Driver (*.tba)
   3: READONLY=1
   4: SERVER=NotTheServer
   5: DBQ=c:\project\textbases\
   7: UID=


  • Each key-value pair is on its own line separated by a carriage return. Ignore the fact that the view you're looking at on the blog may be wrapping.
  • The Inmagic ODBC driver must be installed on any machine using this connection.
  • ReadOnly can be set to 1 for readonly access. READONLY=0 means write access as well.
  • PWD can be blank if the textbase(s) don't use passwords.
  • UID is always blank.

* E.g. password not being written to the file DSN, and the potential for confusion between 64bit and 32bit ODBC Data Sources, since a 64bit machine has both and has separate Admin dialogs.

Use the file DSN

Pass a connection string to your application which points to the file you created:

   1: // C# file DSN example
   2: string connectionString = "filedsn=c:\MyFileDsn.dsn";


Tags: Inmagic ODBC

Index Popups 2008.2.9.10 Update

by Peter Tyrrell Wednesday, September 10, 2008 12:44 PM

Index popups for Inmagic Webpublisher Pro have been updated to fix some subtle bugs:

  • Entering certain characters in find box causes invalid XML errors.
  • Previous Page and Last Page do not work with some secondary fieldnames, or when fieldname is provided whose sentence case does not match actual field exactly.
  • Passwords are not passed through after the initial page. (Ok, not so subtle this one.)
  • Code fields can cause invalid XML errors.
  • Last Page fails if icsweb.ini/dbtwpub.ini SoapFormat=0 or SoapFormat=n and fieldname requires modification for XML use.

Unfixable issue:

  • Previous Page fails if icsweb.ini/dbtwpub.ini SoapFormat=0 or SoapFormat=n and fieldname requires modification for XML use. (Can only fix by changing SoapFormat=1 due to Webpublisher restrictions on fetching index lists with a key delta.)

Download Index Popups 2008.2.9.10 (~600 kB)


Virtual PC 2007 networking tip

by Peter Tyrrell Friday, September 05, 2008 5:21 PM

If you want to interact with a virtual machine as part of your network, you need to adjust its networking settings to specifically use one of the host machine's network adapters.

Don't set the adapter to "Shared networking (NAT)". This isolates the virtual machine behind the virtual networking adapter. You'll find you can't even ping the VM from the host.

Good for interacting


Bad for interacting



DB/Text trace log format method

by Peter Tyrrell Tuesday, August 05, 2008 11:15 PM

Further to my post of May 2007, where I described how to create a trace log in DB/Text and handle exceptions, here is a method that is handy for building more complex log statements.

   1: // construct formatted log statement
   2: function logFormat(val, arg1, arg2, arg3)
   3: {
   4:     var formattedVal = val;
   5:     if (arg1 != null)    {
   6:         formattedVal = formattedVal.replace("{0}", arg1);
   7:     }
   8:     if (arg2 != null) {
   9:         formattedVal = formattedVal.replace("{1}", arg2);
  10:     }
  11:     if (arg3 != null) {
  12:         formattedVal = formattedVal.replace("{2}", arg3);
  13:     }
  14:     log(formattedVal);
  15: }
  17: // write log statement to form box
  18: function log(val)
  19: {
  20:     var box = Form.boxes("boxDebugLog");
  21:     if (box == null)
  22:         return;    
  24:     if (box.content != '')
  25:     {
  26:         box.content += "\n";    
  27:     }    
  28:     box.content += val;
  29: }


logFormat takes a string value and up to 3 arguments, and replaces tokens found in the string value with those arguments. It's based on C#'s string.Format method, and others like it.


It's easier to read (and write) a format string that contains tokens than a string concatenated together with plus signs.

   1: var count = 10;
   2: var name = "Peter";
   3: var duration = 30;
   5: function LogTheOldWay()
   6: {
   7:     log(name + " was lashed with a wet noodle " + count + " times for " + duration + " seconds.");
   8: }
  10: function LogTheNewWay()
  11: {    
  12:     logFormat("{0} was lashed with a wet noodle {1} times for {2} seconds.", name, count, duration);
  13: }


My example above only proves how piddly my skills really are. There's a *much* better way of doing this that allows for n arguments instead of a maximum of three. I had forgotten that every javascript function has a local property called arguments that contains all parameters passed to the function as an array.

   1: function logFormat(val)
   2: {
   3:     var formattedVal = val;
   4:   for(i = 1; i < arguments.length; i++)
   5:   {
   6:     formattedVal = formattedVal.replace("{" + (i - 1) + "}", arguments[i]);
   7:   }
   8:   return formattedVal;
   9: }

"Static" properties in javascript. Kinda.

by Peter Tyrrell Tuesday, August 05, 2008 10:55 PM

The following gives me the ability to access javascript properties in a static kind of way. Not really, since the object has been instantiated, but at least I don't have to define a specific object, then call its constructor all the time to new it up and get at its properties.

   1: // declare globally
   2: var Artist = {
   3:     Fields: {
   4:         Id: "ID",
   5:         FullName: "Term",
   6:         FirstName: "First Name",
   7:         LastName: "Last Name",
   8:         Birth: "Date of Birth",
   9:         Death: "Date of Death"
  10:     }
  11: };


I like to store DB/Text field names in this way, as they become (pseudo) strongly-typed and the magic strings are stored in one place only, instead of scattered across my code like dandelion seeds.

It can be difficult to work in javascript after C# and other full-featured languages. This is the closest I could come to static properties or a struct. If I weren't scripting in DB/Text, a proprietary closed system, I would be using jQuery or mootools, which put the joy back in joyvascript.


Now I can access field names statically as follows. Look ma, no constructors!

   1: function SomeMethod()
   2: {
   3:     var idFieldName = Artist.Fields.Id;
   4: }

Month List