Changeset 336 for tools/dbc_export/DBCExport.pas
- Timestamp:
- Feb 27, 2010, 10:32:23 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/dbc_export/DBCExport.pas
r335 r336 19 19 DBC: TDBC; 20 20 Database: TSqlDatabase; 21 DBCFileName: string; 22 NewDBCFileName: string; 21 23 constructor Create(TheOwner: TComponent); override; 22 24 destructor Destroy; override; … … 32 34 begin 33 35 // Quick check parameters 34 ErrorMsg := CheckOptions('h', 'help');35 if ErrorMsg <> '' then begin36 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; 39 41 40 42 // Parse parameters … … 43 45 Halt; 44 46 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 45 73 ShowDBC; 46 74 … … 53 81 inherited Create(TheOwner); 54 82 StopOnException := True; 83 Database := TSqlDatabase.Create;; 55 84 end; 56 85 57 86 destructor TDBCExport.Destroy; 58 87 begin 88 Database.Destroy; 59 89 inherited Destroy; 60 90 end; … … 62 92 procedure TDBCExport.WriteHelp; 63 93 begin 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'); 66 102 end; 67 103 … … 73 109 DBC := TDBC.Create; 74 110 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.'); 88 126 Free; 89 127 end;
Note:
See TracChangeset
for help on using the changeset viewer.