dosname = name;
database = indatabase;
if (destroy == false)
if (file.exists())
throw new xBaseJException("NDX file already exists");
if (destroy == true)
if (file.exists())
if (file.delete() == false)
throw new xBaseJException("Can't delete old NDX file");
key_length = 0;
stringKey = new String(NDXString);
set_key_definition(NDXString);
unique_key = (byte) (unique ? 64 : 0);
while (strtok.hasMoreElements())
{
char type;
tempch1 = (String) strtok.nextElement();
Field Field = database.getField(tempch1);
type = Field.getType();
if (type == 'M')
throw new xBaseJException("Can't make memo field part of a key");
if (type == 'L')
throw new xBaseJException("Can't make logical ield part of a key");
if (type == 'F')
throw new xBaseJException("Can't make float field part of a key");
if (key_type == ' ')
key_type = type;
else
if (key_type == 'D' && type == 'N')
key_type = 'N';
else
if (key_type == 'N' && type == 'D')
key_type = 'N'; // date key type really doesn't change
else
if (key_type != type)
key_type = 'C';
key_length += Field.getLength();
keyControl.addElement(Field);
}
if (key_type == 'D' || key_type == 'N')
{
keyType = 'N';
key_length = 16;
}
else
{
keyType = 'C';
}
len = (((key_length - 1) / 4) + 1) * 4;
if (len < 1)
{
throw new xBaseJException("key length too short");
} /* endif */
if (len > 100)
{
throw new xBaseJException("key length too int");
} /* endif */
len += 8;
next_available = 1;