WPCubed Product Support

Bug in CreateTableOfContents, same page numbers

In the CreateTableOfContents procedure, bookmark names are created by using GetTickCount to create a unique bookmark identifier. This is somewhat dangerous because the time between to GetTickCount calls could be smaller than a tick...(I use a dual core 3GHz computer)
I have the symptom, that identical page numbers are shown for different head lines. They might use the same bookmark identifier.
I would suggest to add a counter to the tick value which is incremented after each call to GetTickCount.

e.g.:

bobj.Name := BookMarkId + IntToStr(GetTickCount + Increment);
Inc(Increment);

or set Increment initally to GetTickCount and only use Increment

or do not use GetTickCount at all and only use the increment value...

#1 ♥ 0
4.3k Views 2 users read 2 min
support

Hi,

You are right - it was a quick implementation and was then forgotten.

It would be better to have just an increment with a basis string which depends on the date. Don't know the calculation algorithm for a GUID though.

Julian

#2 ♥ 0

here's the code for creating GUIDs

uses
IdGlobal;

[...]
var
id: TGUID;

begin
CoCreateGUID(id);
guid:= GUIDToString(id);
end;

but that is overkill, I would just increment, that will do.

#3 ♥ 0
support

Thanks,

the new V5.17 now uses a simple incremented integer which is initialized with GetTickCount- That should work much better.

Julian

#4 ♥ 0
This category is archived. No new posts are possible.