When EMPTY is NOT equal to 0

Date:    Mon, 27 Mar 1995 15:39:09 -0700
From:    "Emilie A. Young" <eyoung@CSN.ORG>
Subject: cross-platform inconsistency
Sorry if this has been discussed here before, but I came across an interesting little inconsistency between the Windows and Mac versions of 4.0.4 the other day that I thought I'd share.

I've written a fairly simple but reasonably fast database engine for my current project that I'm porting from the mac to windows. The raw data is ascii text so I run a program on the data that codes the strings into numbers to reduce the search time. One of these codes is for several on/off types of fields (i.e. does it have a certain feature or not) that I code into 0 (doesn't have the feature) or 1 (has the feature). The user can decide on which and how many fields of the data they'd like to search. If they don't choose a search key for a particular field then that search key is set to EMPTY.

On the mac this works great but the search results I was getting back on the windows side seemed wrong. It took me awhile to figure out that DFW's evaluates EMPTY and 0 as the same thing. So when the user wanted to see only those items that _did not_ have a specific feature (so the ui sent a search key of "0" to the search routines) the search routines evaluated that to be EMPTY and decided not to search on that key.

For a demo of this try:

 set search_key = 0
 if search_key = EMPTY then
   put "I'm a windows machine"
 else
  put "I'm a mac"
 end if
It was easy enough to come up with a fix - either test for integerp instead of empty or code the data as 1 and 2 instead of 0 and 1.

I purposly structured this, my first major cross-platform project, to avoid some of the known hairy cross-platform problems but I have to say, aside from some gotchas like this and #$%*!! text formatting, I've still been amazed at how well the porting is going. The Macromind folks deserve a tip of the hat.