This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
STRINGS.PAS
124 lines (111 loc) · 2.96 KB
/
STRINGS.PAS
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
{$A-,B-,D-,E-,F-,I-,L-,N-,O-,R-,S-,V-}
{$M 16384,0,655360}
unit Strings;
interface
const
zero=ord('0');
alpha=['a'..'z'];
digit=['0'..'9'];
type Command=(NoCom,Chap,Cend,Cexer,
Cchange,Cls,Cwait,Cdelay,
Cright,Cvariant,Cformat,
Cans,Cunknown);
ByteSet=set of byte;
Workmode=(mainmode,exermode1,exermode2,
helpmode,glsmode,chchmode);
procedure CutSpaces(var s:string);
function GetWord(var s:string):string;
function GetInt(var s:string):word;
procedure GetSet(var s:string;var bs:byteset);
function Com(var s:string):Command;
procedure Error;
const
Comname : array[NoCom..Cunknown] of string[16] =
('','chap','end','exe','change','cls','wait',
'delay','right','variants','format','ans','');
menu : array[Workmode] of string =
('F1\-Help\ F2\-¢ë¡à âì à §¤¥«\ F3\-१ã«ìâ â\ F4\-á«®¢ àì\ '+
#17'ÄÙ\-¯à®¤®«¦ âì\ Esc\-¢ë室',
'F1\-Help\ F3\-⥪áâ\ F4\-á«®¢ àì\ '+
#17'ÄÙ\-§ ª®ç¨âì\ Esc\-¯à¥à¢ âì',
'F1\-Help\ F3\-⥪áâ\ F4\-á«®¢ àì\ ஡¥«\-®â¬¥â¨âì\ '+
#17'ÄÙ\-§ ª®ç¨âì\ Esc\-¯à¥à¢ âì',
'F1\-®£« ¢«¥¨¥\ '#24#25#27#26'\-¢ë¡à âì\ '+
#17'ÄÙ\-¢®©â¨\ F2\-¯®á«¥¤¨© íªà \ Esc\-¢ë室',
'F1\-Help\ F4\-®£« ¢«¥¨¥\ '#24#25#27#26'\-¢ë¡à âì\ '+
#17'ÄÙ\-¢®©â¨\ F2\-¯®á«¥¤¨© íªà \ Esc\-¢ë室',
'F1\-Help\ '#24#25'\-¢ë¡à âì\ '#17'ÄÙ\-¢®©â¨ \Esc\-¯à¥à¢ âì');
implementation
procedure CutSpaces(var s:string);
var
i,l:byte;
begin
l:=length(s);i:=0;
while (i<l) and (s[i+1]=' ') do Inc(i);
delete(s,1,i);
end;
function GetWord(var s:string):string;
var
i,l:byte;
w:string;
begin
w:='';
CutSpaces(s);
l:=length(s);i:=1;
while (i<=l) and (s[i] in alpha) do begin
w:=w+s[i];
Inc(i);
end;
delete(s,1,i-1);
GetWord:=w;
end;
function GetInt(var s:string):word;
var
i,l:byte;
n:word;
begin
l:=length(s);
i:=1;n:=0;
while (i<=l) and (s[i] in digit) do begin
n:=n*10+ord(s[i])-zero;
Inc(i);
end;
delete(s,1,i-1);
GetInt:=n;
if s[1]=',' then delete(s,1,1);
end;
procedure GetSet(var s:string;var bs:byteset);
var
i,l,n1,n2:byte;
begin
bs:=[];
while (length(s)>0) and (s[1] in digit) do begin
n1:=GetInt(s);
if (s[1]='.') and (s[2]='.') then begin
delete(s,1,2);
n2:=GetInt(s);
bs:=bs+[n1..n2];
end
else
bs:=bs+[n1];
end;
end;
function Com(var s:string):Command;
var
w:string;
i:byte;
c:Command;
begin
delete(s,1,1);
w:=GetWord(s);c:=NoCom;
while (Comname[c]<>w) and (c<=Cans) do Inc(c);
Cutspaces(s);
Com:=c;
end;
procedure Error;
begin
writeln('Žè¨¡ª ');
halt;
end;
end.