List Index Out of Range in CDX Indexes
Posted by Wolfgang Krause on 2002-02-14 15:37:46
While appending to a table with a cdx index, a "List Index Out of Range" error is raised.
status: CLOSED Urgency: HIGH As Of: 2002-02-14 15:37:46
Comment:
The problem is generated because the index keys are not properly trimmed of trailing spaces under certain conditions. There is a correction to be made in gs6_cdx.pas.
The method to be modified is GSobjCDXTag.IntNodeBuild. Check below to see the changed section.
Be sure the compiled/updated dcu files are in the library search path if it is different that the source directory.
=====================================================================
procedure GSobjCDXTag.IntNodeBuild(DataBuf: GSptrCDXDataBlk; PIK:
GSobjIndexKey);
var
i : integer;
v : integer;
s : array[0..255] of char;
n : longint;
r : longint;
p: GSobjIndexKeyData;
sp: integer; {!!RFG 090597}
begin
i := 0;
while i < DataBuf^.Entry_Ct do
begin
v := (i*EntryLength);
system.move(DataBuf^.IntData[v], s[0], KeyLength);
s[KeyLength] := #0;
{$IFDEF FOXGENERAL}
if (CollateType = General) and (KeyType = 'C') then
begin
sp := KeyLength - 1;
while (sp > 0) and (s[sp] = ' ') do dec(sp);
while (sp > 0) and (s[sp] < #16) do
begin
s[sp] := chr(ord(s[sp]) or $F0);
dec(sp);
end;
end;
{$ENDIF}
v := v+KeyLength;
system.move(DataBuf^.IntData[v], r, 4);
r := FlipLongint(r);
v := v+4;
system.move(DataBuf^.IntData[v], n, 4);
n := FlipLongint(n);
if KeyType = 'C' then
begin
{--------------------------------------------------
Make changes here. The TrimRight () does not work
with PChar, so we must trim manually
---------------------------------------------------}
{ TrimRight(s);}
v := StrLen(s);
while (v<>0) and (s[v-1] = ' ') do
begin
dec(v);
s[v] := #0;
end;
{---- End Changes ------}
end
else
begin
v := SizeOf(Double);
while (v > 0) and (s[pred(v)] = #0) do dec(v);
end;
p := GSobjIndexKeyData.Create(0);
p.Tag := n;
p.Xtra := r;
p.PutBinary(@s,v);
if KeyType = 'C' then p.TypeOfVar := gsvtText; {\%FIX0014}
PIK.Add(p);
inc(i);
end;
end;
==============================================================

