Hi. More than 10 years passed since last time I tried creating GUI stuff with Lazarus as a kid...
I'm trying to deserialize a pretty large (>1000 chars) string, but LastIndexOf() seems to be joking on me:
var FieldStart, FieldEnd: SizeInt;
begin
FieldName := 'Timetable'; // actually it's a function argument
FieldStart := S.IndexOf(FieldName + '=');
if FieldStart < 0 then exit;
FieldEnd := S.LastIndexOf(';', FieldStart);
if FieldEnd < 0 then exit;
And the string S:
Timetable={Stations={EList=station;HTFL={HashTable={{ID=3;EType=station;Name="Ст1";Directions={EList=direction;HTFL={HashTable={{ID=1;EType=direction;Name="NoDirection";Stations={};};};FreeList={};};};Routes={1};};{ID=2;EType=station;Name="Ст2";Directions={EList=direction;HTFL={HashTable={{ID=1;EType=direction;Name="NoDirection";Stations={};};};FreeList={};};};Routes={1};};{ID=1;EType=station;Name="Ст3";Directions={EList=direction;HTFL={HashTable={{ID=1;EType=direction;Name="NoDirection";Stations={};};};FreeList={};};};Routes={1};};{ID=4;EType=station;Name="Ст4";Directions={EList=direction;HTFL={HashTable={{ID=1;EType=direction;Name="NoDirection";Stations={};};};FreeList={};};};Routes={1};};};FreeList={};};};Routes={EList=route;HTFL={HashTable={{ID=1;EType=route;Name="П1";Stations={1,2,3,4};Trains={EList=train;HTFL={HashTable={{ID=3;EType=train;Name="1033";Schedule={{Station=1;NonStop=False;Arrival=62;Stop=184;Dep=306;Trav=428;};};};{ID=2;EType=train;Name="1032";Schedule={};};{ID=1;EType=train;Name="1031";Schedule={};};{ID=4;EType=train;Name="1034";Schedule={};};};FreeList={};};};};};FreeList={};};};};
FieldStart is set correctly to 0, but for some reason FieldEnd is -1. The char I'm looking for is literally the last one.
FPC 3.2.2, Lazarus 3.4