Code cleanup

This commit is contained in:
mysticbbs 2012-02-26 16:15:03 -05:00
parent 7f60eb3e69
commit b77f9578b7
1 changed files with 83 additions and 81 deletions

View File

@ -24,38 +24,39 @@ Program MakeLang;
{$I M_OPS.PAS} {$I M_OPS.PAS}
Uses Uses
DOS, DOS,
m_Strings; m_Strings;
{$I RECORDS.PAS} {$I RECORDS.PAS}
Var Var
ConfigFile : File of RecConfig; ConfigFile : File of RecConfig;
PromptFile : File of PromptRec; PromptFile : File of PromptRec;
Config : RecConfig; Config : RecConfig;
Prompt : PromptRec; Prompt : PromptRec;
Done : Array[0..mysMaxLanguageStr] of Boolean; Done : Array[0..mysMaxLanguageStr] of Boolean;
tFile : Text; tFile : Text;
A : Integer; A : Integer;
Temp : String; Temp : String;
FName : NameStr; FName : NameStr;
FExt : ExtStr; FExt : ExtStr;
FDir : DirStr; FDir : DirStr;
Begin Begin
WriteLn; WriteLn;
WriteLn ('MAKELANG (' + OSID + ') - Mystic Language Compiler v', mysVersion); WriteLn ('MAKELANG (' + OSID + ') - Mystic Language Compiler v', mysVersion);
WriteLn ('Copyright (C) 1997-2012 By James Coyle. All Rights Reserved.'); WriteLn ('Copyright (C) 1997-2012 By James Coyle. All Rights Reserved.');
WriteLn; WriteLn;
Assign (ConfigFile, 'mystic.dat'); Assign (ConfigFile, 'mystic.dat');
{$I-}Reset (ConfigFile);{$I+} {$I-}Reset (ConfigFile);{$I+}
If IoResult <> 0 Then Begin
WriteLn ('ERROR: MYSTIC.DAT not found. Run from main BBS directory.'); If IoResult <> 0 Then Begin
Halt(1); WriteLn ('ERROR: MYSTIC.DAT not found. Run from main BBS directory.');
End; Halt(1);
Read (ConfigFile, Config); End;
Close (ConfigFile);
Read (ConfigFile, Config);
Close (ConfigFile);
If Config.DataChanged <> mysDataChanged Then Begin If Config.DataChanged <> mysDataChanged Then Begin
WriteLn('ERROR: Data files are not current and must be upgraded.'); WriteLn('ERROR: Data files are not current and must be upgraded.');
@ -63,75 +64,76 @@ Begin
End; End;
If ParamCount <> 1 Then Begin If ParamCount <> 1 Then Begin
WriteLn ('Usage: MAKELANG [language_file]'); WriteLn ('Usage: MAKELANG [language_file]');
Halt(1); Halt(1);
End; End;
FSplit (ParamStr(1), FDir, FName, FExt); FSplit (ParamStr(1), FDir, FName, FExt);
Assign (tFile, FName + FExt); Assign (tFile, FName + FExt);
{$I-} Reset (tFile); {$I+} {$I-} Reset (tFile); {$I+}
If IoResult <> 0 Then Begin
WriteLn ('ERROR: Language file (' + FName + FExt + ') not found.');
Halt(1);
End;
Write ('Compiling language file: '); If IoResult <> 0 Then Begin
WriteLn ('ERROR: Language file (' + FName + FExt + ') not found.');
Halt(1);
End;
Assign (PromptFile, Config.DataPath + FName + '.lng'); Write ('Compiling language file: ');
{$I-} ReWrite (PromptFile); {$I+}
If IoResult <> 0 Then Begin Assign (PromptFile, Config.DataPath + FName + '.lng');
WriteLn; {$I-} ReWrite (PromptFile); {$I+}
WriteLn;
WriteLn (^G'ERROR: Cannot run while Mystic is loaded.');
Halt(1);
End;
Prompt := ''; If IoResult <> 0 Then Begin
WriteLn;
WriteLn;
WriteLn (^G'ERROR: Cannot run while Mystic is loaded.');
Halt(1);
End;
For A := 0 to mysMaxLanguageStr Do Begin Prompt := '';
Done[A] := False;
Write (PromptFile, Prompt);
End;
Reset (PromptFile); For A := 0 to mysMaxLanguageStr Do Begin
Done[A] := False;
Write (PromptFile, Prompt);
End;
While Not Eof(tFile) Do Begin Reset (PromptFile);
ReadLn (tFile, Temp);
If Copy(Temp, 1, 3) = '000' Then A := 0 Else While Not Eof(tFile) Do Begin
If strS2I(Copy(Temp, 1, 3)) > 0 Then A := strS2I(Copy(Temp, 1, 3)) Else ReadLn (tFile, Temp);
A := -1;
If A <> -1 Then Begin If Copy(Temp, 1, 3) = '000' Then A := 0 Else
If A > mysMaxLanguageStr Then Begin If strS2I(Copy(Temp, 1, 3)) > 0 Then A := strS2I(Copy(Temp, 1, 3)) Else
WriteLn; A := -1;
WriteLn;
WriteLn (^G'ERROR: String #', A, ' was not expected. Language file not created.');
Close (PromptFile);
Erase (PromptFile);
Halt(1);
End;
Done[A] := True; If A <> -1 Then Begin
Seek (PromptFile, A); If A > mysMaxLanguageStr Then Begin
Prompt := Copy(Temp, 5, Length(Temp)); WriteLn;
Write (PromptFile, Prompt); WriteLn;
End; WriteLn (^G'ERROR: String #', A, ' was not expected. Language file not created.');
End;
Close (tFile);
Close (PromptFile); Close (PromptFile);
Erase (PromptFile);
Halt(1);
End;
WriteLn ('Done.'); Done[A] := True;
Seek (PromptFile, A);
Prompt := Copy(Temp, 5, Length(Temp));
Write (PromptFile, Prompt);
End;
End;
For A := 0 to mysMaxLanguageStr Do Begin Close (tFile);
If Not Done[A] Then Begin Close (PromptFile);
WriteLn;
WriteLn (^G'ERROR: String #', A, ' was not found. Language file not created.'); WriteLn ('Done.');
Erase (PromptFile);
End; For A := 0 to mysMaxLanguageStr Do Begin
End; If Not Done[A] Then Begin
WriteLn;
WriteLn (^G'ERROR: String #', A, ' was not found. Language file not created.');
Erase (PromptFile);
End;
End;
End. End.