-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFINDPLN.PAS
More file actions
136 lines (126 loc) · 3.23 KB
/
FINDPLN.PAS
File metadata and controls
136 lines (126 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{ @author: Sylvain Maltais (support@gladir.com)
@created: 2022
@website(https://www.gladir.com/avionix)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program FindPln;
Uses Strings;
Const
PlaneList:Array[0..26]of PChar=(
'Airbus A380','Boeing 247','Boeing 307','Boeing 707','Boeing 717',
'Boeing 727','Boeing 737','Boeing 737 MAX','Boeing 747',
'Boeing 757','Boeing 767','CRJ-100ER','CRJ-100LR','CRJ-200ER',
'CRJ-200LR','CRJ-700','CRJ-900','CRJ-1000','Concorde','DH.83',
'DH.84','DH.86','F-18','Falcon 2000','Falcon 5X','Falcon 7X',
'Falcon 8X'
);
Var
LineNumber:LongInt;
Option:Set of (_Lines);
BeginWord,I,J:Integer;
FoundMultiWord:Boolean;
SourceFile:Text;
FileName,CurrLine,CurrWord:String;
Function StrToUpper(S:String):String;
Var
I:Byte;
Begin
For I:=1 to Length(S)do Begin
If S[I] in['a'..'z']Then S[I]:=Chr(Ord(S[I])-32);
End;
StrToUpper:=S;
End;
Function IsLetter(Chr:Char):Boolean;Begin
IsLetter:=Chr in ['A'..'Z','a'..'z','‚','ˆ','Š','…','ƒ','“','‡'];
End;
Procedure CompileWord;
Var
I:Integer;
Begin
For I:=Low(PlaneList) to High(PlaneList) do Begin
If StrToUpper(StrPas(PlaneList[I]))=StrToUpper(CurrWord)Then Begin
If FileName<>''Then Begin
If(_Lines in Option)Then Begin
WriteLn('Avion trouve dans la ligne numero ',LineNumber,' :');
End;
End;
WriteLn(StrPas(PlaneList[I]));
Exit;
End;
End;
End;
Procedure ParseLineDetectPlane;
Var
J:Integer;
Begin
CurrWord:='';
BeginWord:=1;
For I:=1 to Length(CurrLine)do Begin
If(IsLetter(CurrLine[I]))Then CurrWord:=CurrWord+CurrLine[I]
Else
Begin
FoundMultiWord:=False;
For J:=Low(PlaneList) to High(PlaneList) do Begin
If(StrLen(PlaneList[J])>Length(CurrWord))and
(StrToUpper(StrPas(PlaneList[J]))=
StrToUpper(Copy(CurrLine,BeginWord,StrLen(PlaneList[J]))))Then Begin
FoundMultiWord:=True;
Break;
End;
End;
If(FoundMultiWord)Then Begin
CurrWord:=CurrWord+CurrLine[I]
End
Else
Begin
CompileWord;
CurrWord:='';
BeginWord:=I+1;
End;
End;
End;
CompileWord;
End;
BEGIN
If(ParamStr(1)='/?')or(ParamStr(1)='--help')or(ParamStr(1)='-h')or
(ParamStr(1)='/h')or(ParamStr(1)='/H')Then Begin
WriteLn('FINDPLN : Cette commande permet de detecter les avions ',
'mentionne dans un texte.');
WriteLn;
WriteLn('Syntaxe : FINDPLN "message"');
WriteLn(' FINDPLN /FILE:fichier [/LINES]');
WriteLn;
WriteLn(' /FILE: Ce parametre permet d''indiquer le fichier a analyser');
WriteLn(' /LINES Ce parametre permet d''afficher le numero de ligne');
End
Else
Begin
Option:=[];
LineNumber:=0;
FileName:='';
CurrLine:='';
For I:=1 to ParamCount do Begin
If StrToUpper(ParamStr(I))='/LINES'Then Include(Option,_Lines);
If StrToUpper(Copy(ParamStr(I),1,6))='/FILE:'Then Begin
FileName:=Copy(ParamStr(I),7,255);
End
Else
Begin
If CurrLine=''Then CurrLine:=ParamStr(I)
Else CurrLine:=CurrLine+' '+ParamStr(I);
End;
End;
If FileName<>''Then Begin
Assign(SourceFile,FileName);
Reset(SourceFile);
While Not EOF(SourceFile)do Begin
Inc(LineNumber);
ReadLn(SourceFile,CurrLine);
ParseLineDetectPlane;
End;
Close(SourceFile);
End
Else
ParseLineDetectPlane;
End;
END.