KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q58020: Can’t Search on Blank String Field in BASIC 7.00 ISAM

Article: Q58020
Product(s): See article
Version(s): 7.00
Operating System(s): MS-DOS
Keyword(s): ENDUSER | SR# S900119-140 | mspl13_basic
Last Modified: 2-FEB-1990

Blank string fields cannot be searched on with the ISAM file handler
that comes with Microsoft BASIC Professional Development System (PDS)
Version 7.00 for MS-DOS.

If a search is performed on a string field (whether the field is the
entire index or part of a combined one) and the entire field is filled
with spaces, the record will not be found and an end-of-file condition
will be returned.

To work around this problem, represent blank fields by inserting some
other character into them and searching on the presence of that
character in the field.

Due to the way the ISAM engine stores string fields in a database
table, completely blank string fields cannot be found when you use the
SEEKGT, SEEKGE, or SEEKEQ statements. This is the case whether the
string field represents the entire index or whether it is a field
(primary or not) included in a combined index. Also, the same behavior
is exhibited with fields that are unique and with those that have
duplicates.

This characteristic of the ISAM file handler is due to the way it
strips off leading and trailing spaces from a string field to conserve
disk space. For example, if the string " abc " (length of 5, with one
leading and one trailing space) is inserted into a string field with a
length of 10, "abc" (a length of 3) is actually written to the table.
Therefore, inserting a string consisting entirely of spaces results in
nothing being written to the table because every character is stripped
off.

The best workaround for this situation is to associate a special
character with string fields that are to be completely blank and set
the field equal to that character. Then, in all subsequent searches on
this field, use that character as the key.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.