Ignore:
Timestamp:
Sep 17, 2007, 9:00:30 PM (18 years ago)
Author:
RBRi
Message:

#24

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Components/ACLLanguageUnit.pas

    r231 r249  
    4848    function getValue(const aLabel : String; const aDefaultValue : String) : String;
    4949    procedure setValue(const aLabel : String; const aValue : String);
     50    procedure readFrom(aTextFile : TextFile);
    5051    procedure saveTo(const aTextFile : TextFile);
    5152  end;
     
    248249
    249250
     251  procedure TLanguageItemList.readFrom(aTextFile : TextFile);
     252  var
     253    tmpLine : string;
     254    tmpLabel : string;
     255    tmpValue : string;
     256    tmpLineParts : TStringList;
     257  begin
     258    tmpLineParts := TStringList.Create;
     259
     260    while not Eof(aTextFile) do
     261    begin
     262      ReadLn(aTextFile, tmpLine);
     263
     264      tmpLineParts.clear;
     265      StrExtractStringsQuoted(tmpLineParts, tmpLine);
     266
     267      if tmpLineParts.count > 0 then
     268      begin
     269        tmpLabel := tmpLineParts[0];
     270
     271        // TODO trim leading blanks
     272        if tmpLabel[1] <> LANGUAGE_COMMENT_CHAR then
     273        begin
     274          // Got a name, read the value and store.
     275          tmpValue := '';
     276          if tmpLineParts.count > 0 then
     277          begin
     278            tmpValue := tmpLineParts[1];
     279          end;
     280
     281          setValue(tmpLabel, tmpValue);
     282        end;
     283      end;
     284    end;
     285
     286    tmpLineParts.Destroy;
     287  end;
     288
     289
    250290  procedure TLanguageItemList.saveTo(const aTextFile : TextFile);
    251291  var
     
    459499  var
    460500    tmpTextFile : TextFile;
    461     tmpLine : string;
    462     tmpLabel : string;
    463     tmpValue : string;
    464     tmpLineParts : TStringList;
    465501  begin
    466502    filename := aFileName;
     
    478514    Reset(tmpTextFile);
    479515
    480     tmpLineParts := TStringList.Create;
    481 
    482     while not Eof(tmpTextFile) do
    483     begin
    484       ReadLn(tmpTextFile, tmpLine);
    485 
    486       tmpLineParts.clear;
    487       StrExtractStringsQuoted(tmpLineParts, tmpLine);
    488 
    489       if tmpLineParts.count > 0 then
    490       begin
    491         tmpLabel := tmpLineParts[0];
    492 
    493         // TODO trim leading blanks
    494         if tmpLabel[1] <> LANGUAGE_COMMENT_CHAR then
    495         begin
    496           // Got a name, read the value and store.
    497           tmpValue := '';
    498           if tmpLineParts.count > 0 then
    499           begin
    500             tmpValue := tmpLineParts[1];
    501           end;
    502 
    503           languageItems.setValue(tmpLabel, tmpValue);
    504         end;
    505       end;
    506     end;
    507 
    508     tmpLineParts.Destroy;
     516    languageItems.readFrom(tmpTextFile);
     517
    509518    CloseFile(tmpTextFile);
    510519  end;
Note: See TracChangeset for help on using the changeset viewer.