Ignore:
Timestamp:
Nov 29, 2023, 2:35:44 PM (12 months ago)
Author:
chronos
Message:
  • Modified: HighDpi branch updated to trunk version.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/highdpi/Packages/CevoComponents/StringTables.pas

    r303 r463  
    1616    constructor Create;
    1717    destructor Destroy; override;
    18     function LoadFromFile(const FileName: String): boolean;
    19     function GetHandle(const Item: string): integer;
    20     function LookupByHandle(Handle: integer; Index: integer = -1): string;
     18    function LoadFromFile(const FileName: String): Boolean;
     19    function GetHandle(const Item: string): Integer;
     20    function LookupByHandle(Handle: Integer; Index: Integer = -1): string;
    2121    function Lookup(const Item: string; Index: Integer = -1): string;
    22     function Search(const Content: string; var Handle, Index: integer): boolean;
     22    function Search(const Content: string; var Handle, Index: Integer): Boolean;
    2323  end;
    2424
     
    4545end;
    4646
    47 function TStringTable.LoadFromFile(const FileName: String): boolean;
     47function TStringTable.LoadFromFile(const FileName: String): Boolean;
    4848begin
    4949  Result := True;
     
    5656end;
    5757
    58 function TStringTable.GetHandle(const Item: string): integer;
     58function TStringTable.GetHandle(const Item: string): Integer;
    5959var
    6060  I: Integer;
     
    6767end;
    6868
    69 function TStringTable.LookupByHandle(Handle: integer; Index: integer): string;
     69function TStringTable.LookupByHandle(Handle: Integer; Index: Integer): string;
    7070var
    71   s: string;
     71  S: string;
    7272begin
    7373  if Index < 0 then begin
     
    7777    end else begin
    7878      if Pos(' ', Lines[Handle]) = 0 then S := ''
    79         else s := Copy(Lines[Handle], Pos(' ', Lines[Handle]) + 1, MaxInt);
     79        else S := Copy(Lines[Handle], Pos(' ', Lines[Handle]) + 1, MaxInt);
    8080      while ((Handle + 1) < Lines.Count) and (Copy(Lines[Handle + 1], 1, 1) <> '#') do begin
    8181        Inc(Handle);
    8282        if (Length(Lines[Handle]) > 0) and (Lines[Handle][1] <> '''') then begin
    83           if (s <> '') and (s[Length(s)] <> '\') then
    84             s := s + ' ';
    85           s := s + Lines[Handle];
     83          if (S <> '') and (S[Length(S)] <> '\') then
     84            S := S + ' ';
     85          S := S + Lines[Handle];
    8686        end;
    8787      end;
     
    116116{ might become necessary for 1.3
    117117
    118   function TStringTable.Lookup(const Fallback: TStringTable; const Item: string; Index: integer): string;
     118  function TStringTable.Lookup(const Fallback: TStringTable; const Item: string; Index: Integer): string;
    119119  var
    120   Handle: integer;
     120  Handle: Integer;
    121121  begin
    122122  Handle:=Gethandle(Item);
    123   if Handle>=0 then result:=LookupByHandle(Handle, Index)
    124   else result:='';
    125   if result='' then
    126   result:=Fallback.Lookup(Item, Index);
     123  if Handle>=0 then Result:=LookupByHandle(Handle, Index)
     124  else Result:='';
     125  if Result='' then
     126  Result:=Fallback.Lookup(Item, Index);
    127127  end;
    128128
    129   function TStringTable.TryLookup(const Item: string; Index: integer): string;
     129  function TStringTable.TryLookup(const Item: string; Index: Integer): string;
    130130  var
    131   Handle: integer;
     131  Handle: Integer;
    132132  begin
    133133  Handle:=Gethandle(Item);
    134   if Handle>=0 then result:=LookupByHandle(Handle, Index)
    135   else result:='';
     134  if Handle>=0 then Result:=LookupByHandle(Handle, Index)
     135  else Result:='';
    136136  end; }
    137137
    138138function TStringTable.Search(const Content: string;
    139   var Handle, Index: integer): boolean;
     139  var Handle, Index: Integer): Boolean;
    140140var
    141   h, i: integer;
     141  H, I: Integer;
    142142  UContent: string;
    143143begin
    144144  UContent := UpperCase(Content);
    145   h := Handle;
    146   if h < 0 then
    147     i := 0
     145  H := Handle;
     146  if H < 0 then
     147    I := 0
    148148  else
    149     i := Index + 1;
     149    I := Index + 1;
    150150  repeat
    151     if h + i + 1 >= Lines.Count then
     151    if H + I + 1 >= Lines.Count then
    152152    begin
    153       result := false;
    154       exit;
     153      Result := False;
     154      Exit;
    155155    end;
    156     if Copy(Lines[h + i + 1], 1, 1) = '#' then
     156    if Copy(Lines[H + I + 1], 1, 1) = '#' then
    157157    begin
    158       h := h + i + 1;
    159       i := -1;
     158      H := H + I + 1;
     159      I := -1;
    160160    end;
    161     if (h >= 0) and not ((Length(Lines[h + i + 1]) > 0) and (Lines[h + i + 1][1] in ['#', ':', ';'])) and
    162       (Pos(UContent, UpperCase(Lines[h + i + 1])) > 0) then
     161    if (H >= 0) and not ((Length(Lines[H + I + 1]) > 0) and (Lines[H + I + 1][1] in ['#', ':', ';'])) and
     162      (Pos(UContent, UpperCase(Lines[H + I + 1])) > 0) then
    163163    begin
    164       Index := i;
    165       Handle := h;
     164      Index := I;
     165      Handle := H;
    166166      Result := True;
    167167      Exit;
Note: See TracChangeset for help on using the changeset viewer.