-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSJ3LANG.PAS
181 lines (117 loc) · 2.74 KB
/
SJ3LANG.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
Unit sj3lang;
Interface
{ procedure ResetLanguage; }
procedure Init;
procedure LoadLanguage(languageindex:byte);
function lrstr(start,stop:integer):string;
function lnstr(index:integer):string;
function lstr(index:integer):string;
function lch(index,num:integer):char;
var numlanguages : byte;
lnames : array [0..25] of string[20];
Implementation
uses {crt,}sj3help;
const NumStr = 599;
type LangStr = string[59];
var plstr : array [0..NumStr] of ^LangStr;
function lstr(index:integer):string;
begin
if (index>=0) and (index<=numstr) then lstr:=plstr[index]^;
end;
function lch(index,num:integer):char;
var str1 : string;
begin
str1:=lstr(index);
lch:=str1[num];
end;
function lrstr(start,stop:integer):string;
begin
lrstr:=lstr(start+random(stop-start+1));
end;
function lnstr(index:integer):string;
var temp : integer;
begin
temp:=index;
while (lstr(temp)='?') and (temp<index+10) do inc(temp);
lnstr:=lstr(temp);
end;
procedure ResetLanguage;
var f1 : text;
str1 : string;
out : boolean;
begin
assign(f1,'LANGBASE.SKI');
{$I-}
reset(f1);
{$I+}
FileOK(IOResult,'LANGBASE.SKI');
numlanguages:=0;
out:=false;
repeat
if (eof(f1)) then out:=true
else readln(f1,str1);
if (length(str1) > 0) and (str1[1]='*') then
begin
inc(numlanguages);
readln(f1,str1);
lnames[numlanguages]:=str1;
end;
until (out);
close(f1);
end;
procedure LoadLanguage(languageindex:byte);
var f1 : text;
code, index, temp : integer;
first, out : boolean;
str1 : string;
begin
for temp:=0 to NumStr do plstr[temp]^:='?';
assign(f1,'LANGBASE.SKI');
reset(f1);
out:=false;
index:=0;
repeat
if (eof(f1)) then out:=true
else readln(f1,str1);
if (length(str1) > 0) and (str1[1]='*') and (str1[2] = chr(languageindex+64)) then
begin { oikea kieli l”ytyi! }
index:=1;
out:=true;
end;
until (out);
out:=false;
if (index>0) then { kunhan oikea kieli on l”ytyynty. }
repeat
if (eof(f1)) then out:=true
else readln(f1,str1);
if (length(str1) > 0) and (str1[1]='*') then out:=true; { kiitti, riitt„„ }
if (not out) then
begin
index:=0;
first:=true;
for temp:=1 to length(str1) do
begin
if (index>0) then plstr[index]^:=plstr[index]^+str1[temp];
if (str1[temp]=':') and (first) then
begin
first:=false;
val(copy(str1,1,temp-1),index,code);
if (code<>0) then index:=0;
if (index>0) then plstr[index]^:=''; { putsaa stringin }
end;
end;
end;
until (out);
close(f1);
end;
procedure NewLangs;
var temp : integer;
begin
for temp:=0 to NumStr do New(plstr[temp]);
end;
procedure Init;
begin
NewLangs;
ResetLanguage;
end;
end.