Changeset 336 for tools


Ignore:
Timestamp:
Feb 27, 2010, 10:32:23 AM (14 years ago)
Author:
george
Message:
  • Přidáno: Načítání parametrů volání z příkazové řádky.
Location:
tools/dbc_export
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • tools/dbc_export/DBCExport.lpi

    r335 r336  
    3030      </local>
    3131    </RunParams>
    32     <Units Count="14">
     32    <Units Count="15">
    3333      <Unit0>
    3434        <Filename Value="DBCExport.pas"/>
    3535        <IsPartOfProject Value="True"/>
    3636        <UnitName Value="DBCExport"/>
    37         <CursorPos X="44" Y="22"/>
    38         <TopLine Value="1"/>
     37        <CursorPos X="42" Y="50"/>
     38        <TopLine Value="38"/>
    3939        <EditorIndex Value="0"/>
    40         <UsageCount Value="29"/>
     40        <UsageCount Value="30"/>
    4141        <Loaded Value="True"/>
    4242        <SyntaxHighlighter Value="Delphi"/>
     
    116116        <CursorPos X="1" Y="1"/>
    117117        <TopLine Value="71"/>
    118         <EditorIndex Value="3"/>
    119         <UsageCount Value="20"/>
     118        <EditorIndex Value="4"/>
     119        <UsageCount Value="21"/>
    120120        <Loaded Value="True"/>
    121121        <SyntaxHighlighter Value="Delphi"/>
     
    125125        <IsPartOfProject Value="True"/>
    126126        <UnitName Value="UDBC"/>
    127         <CursorPos X="32" Y="92"/>
    128         <TopLine Value="20"/>
    129         <EditorIndex Value="1"/>
    130         <UsageCount Value="20"/>
     127        <CursorPos X="3" Y="19"/>
     128        <TopLine Value="3"/>
     129        <EditorIndex Value="2"/>
     130        <UsageCount Value="21"/>
    131131        <Loaded Value="True"/>
    132132        <SyntaxHighlighter Value="Delphi"/>
     
    137137        <CursorPos X="1" Y="8"/>
    138138        <TopLine Value="1"/>
    139         <EditorIndex Value="2"/>
    140         <UsageCount Value="20"/>
     139        <EditorIndex Value="3"/>
     140        <UsageCount Value="21"/>
    141141        <Loaded Value="True"/>
    142142        <SyntaxHighlighter Value="None"/>
    143143      </Unit13>
     144      <Unit14>
     145        <Filename Value="/usr/share/fpcsrc/packages/fcl-base/src/custapp.pp"/>
     146        <UnitName Value="CustApp"/>
     147        <CursorPos X="1" Y="63"/>
     148        <TopLine Value="47"/>
     149        <EditorIndex Value="1"/>
     150        <UsageCount Value="10"/>
     151        <Loaded Value="True"/>
     152      </Unit14>
    144153    </Units>
    145     <JumpHistory Count="6" HistoryIndex="5">
     154    <JumpHistory Count="17" HistoryIndex="16">
    146155      <Position1>
    147156        <Filename Value="UDBC.pas"/>
     
    168177        <Caret Line="8" Column="29" TopLine="1"/>
    169178      </Position6>
     179      <Position7>
     180        <Filename Value="DBCExport.pas"/>
     181        <Caret Line="15" Column="38" TopLine="8"/>
     182      </Position7>
     183      <Position8>
     184        <Filename Value="DBCExport.pas"/>
     185        <Caret Line="46" Column="12" TopLine="35"/>
     186      </Position8>
     187      <Position9>
     188        <Filename Value="DBCExport.pas"/>
     189        <Caret Line="64" Column="1" TopLine="46"/>
     190      </Position9>
     191      <Position10>
     192        <Filename Value="DBCExport.pas"/>
     193        <Caret Line="62" Column="52" TopLine="46"/>
     194      </Position10>
     195      <Position11>
     196        <Filename Value="DBCExport.pas"/>
     197        <Caret Line="103" Column="33" TopLine="87"/>
     198      </Position11>
     199      <Position12>
     200        <Filename Value="DBCExport.pas"/>
     201        <Caret Line="102" Column="10" TopLine="81"/>
     202      </Position12>
     203      <Position13>
     204        <Filename Value="DBCExport.pas"/>
     205        <Caret Line="19" Column="13" TopLine="3"/>
     206      </Position13>
     207      <Position14>
     208        <Filename Value="DBCExport.pas"/>
     209        <Caret Line="103" Column="33" TopLine="87"/>
     210      </Position14>
     211      <Position15>
     212        <Filename Value="DBCExport.pas"/>
     213        <Caret Line="47" Column="31" TopLine="27"/>
     214      </Position15>
     215      <Position16>
     216        <Filename Value="DBCExport.pas"/>
     217        <Caret Line="35" Column="22" TopLine="27"/>
     218      </Position16>
     219      <Position17>
     220        <Filename Value="DBCExport.pas"/>
     221        <Caret Line="50" Column="37" TopLine="37"/>
     222      </Position17>
    170223    </JumpHistory>
    171224  </ProjectOptions>
     
    191244      <VerifyObjMethodCallValidity Value="True"/>
    192245    </CodeGeneration>
    193     <Linking>
    194       <LinkSmart Value="True"/>
    195     </Linking>
    196246    <Other>
    197247      <Verbosity>
  • tools/dbc_export/DBCExport.pas

    r335 r336  
    1919    DBC: TDBC;
    2020    Database: TSqlDatabase;
     21    DBCFileName: string;
     22    NewDBCFileName: string;
    2123    constructor Create(TheOwner: TComponent); override;
    2224    destructor Destroy; override;
     
    3234begin
    3335  // Quick check parameters
    34   ErrorMsg := CheckOptions('h', 'help');
    35   if ErrorMsg <> '' then begin
    36     ShowException(Exception.Create(ErrorMsg));
    37     Halt;
    38   end;
     36  //ErrorMsg := CheckOptions('h', 'help');
     37  //if ErrorMsg <> '' then begin
     38  //  ShowException(Exception.Create(ErrorMsg));
     39  //  Halt;
     40  //end;
    3941
    4042  // Parse parameters
     
    4345    Halt;
    4446  end;
     47  if HasOption('f', 'file') then begin
     48    DBCFileName := GetOptionValue('f', 'file');
     49    NewDBCFileName := Copy(DBCFileName, 1, Length(DBCFileName) -
     50      Length(ExtractFileExt(DBCFileName))) + '-2.dbc';
     51  end else begin
     52    WriteLn('Source DBC file not specified.');
     53    Halt;
     54  end;
     55  if HasOption('n', 'newfile') then begin
     56    NewDBCFileName := GetOptionValue('n', 'newfile');
     57  end;
     58
     59  if HasOption('s', 'schema') then begin
     60    Database.Database := GetOptionValue('s', 'schema');
     61  end else Database.Database := 'wowpreklad';
     62  if HasOption('u', 'user') then begin
     63    Database.UserName := GetOptionValue('u', 'user');
     64  end else Database.UserName := 'root';
     65  if HasOption('p', 'password') then begin
     66    Database.Password := GetOptionValue('p', 'password');
     67  end else Database.Password := '';
     68  if HasOption('t', 'host') then begin
     69    Database.Hostname := GetOptionValue('t', 'host');
     70  end else Database.Hostname := 'localhost';
     71
     72
    4573  ShowDBC;
    4674
     
    5381  inherited Create(TheOwner);
    5482  StopOnException := True;
     83  Database := TSqlDatabase.Create;;
    5584end;
    5685
    5786destructor TDBCExport.Destroy;
    5887begin
     88  Database.Destroy;
    5989  inherited Destroy;
    6090end;
     
    6292procedure TDBCExport.WriteHelp;
    6393begin
    64   { add your help code here }
    65   WriteLn('Usage: ', ExeName, ' -h');
     94  WriteLn('Usage: ', ExtractFileName(ExeName), ' [options]');
     95  WriteLn('  -h --help      Show this help');
     96  WriteLn('  -u --user      Database user name');
     97  WriteLn('  -p --password  Database password name');
     98  WriteLn('  -s --schema    Database schema name');
     99  WriteLn('  -t --host      Database host name');
     100  WriteLn('  -f --file      Source DBC file name');
     101  WriteLn('  -n --newfile   New created DBC file name');
    66102end;
    67103
     
    73109  DBC := TDBC.Create;
    74110  with DBC do begin
    75     LoadFromFile('Spell.dbc');
    76     //LoadColumnStrings(1);
    77     //LoadColumnStrings(127);
    78     (*for Y := 0 to Length(Cells) - 1 do begin
    79       Text := '';
    80       for X := 0 to Length(Cells[Y]) - 1 do
    81        if VarIsStr(Cells[Y, X]) then Text := Text + Cells[Y, X] + ', '
    82         else Text := Text + IntToStr(Cells[Y, X]) + ', ';
    83       WriteLn(Text);
    84     end;
    85     *)
    86     WriteLn('Save');
    87     SaveToFile('Spell2.dbc');
     111    if FileExists(DBCFileName) then begin
     112      LoadFromFile(DBCFileName);
     113      //LoadColumnStrings(1);
     114      //LoadColumnStrings(127);
     115      (*for Y := 0 to Length(Cells) - 1 do begin
     116        Text := '';
     117        for X := 0 to Length(Cells[Y]) - 1 do
     118         if VarIsStr(Cells[Y, X]) then Text := Text + Cells[Y, X] + ', '
     119          else Text := Text + IntToStr(Cells[Y, X]) + ', ';
     120        WriteLn(Text);
     121      end;
     122      *)
     123      WriteLn('Save');
     124      SaveToFile(NewDBCFileName);
     125    end else WriteLn('File ' + DBCFileName + ' not exists.');
    88126    Free;
    89127  end;
Note: See TracChangeset for help on using the changeset viewer.