equal
deleted
inserted
replaced
28 |
28 |
29 procedure SplitBySpace(var a, b: shortstring); |
29 procedure SplitBySpace(var a, b: shortstring); |
30 procedure SplitByChar(var a, b: shortstring; c: char); |
30 procedure SplitByChar(var a, b: shortstring; c: char); |
31 procedure SplitByCharA(var a, b: ansistring; c: char); |
31 procedure SplitByCharA(var a, b: ansistring; c: char); |
32 |
32 |
|
33 function ExtractFileDir(s: shortstring) : shortstring; |
|
34 function ExtractFileName(s: shortstring) : shortstring; |
|
35 |
33 function EnumToStr(const en : TGearType) : shortstring; overload; |
36 function EnumToStr(const en : TGearType) : shortstring; overload; |
34 function EnumToStr(const en : TVisualGearType) : shortstring; overload; |
37 function EnumToStr(const en : TVisualGearType) : shortstring; overload; |
35 function EnumToStr(const en : TSound) : shortstring; overload; |
38 function EnumToStr(const en : TSound) : shortstring; overload; |
36 function EnumToStr(const en : TAmmoType) : shortstring; overload; |
39 function EnumToStr(const en : TAmmoType) : shortstring; overload; |
37 function EnumToStr(const en : TStatInfoType) : shortstring; overload; |
40 function EnumToStr(const en : TStatInfoType) : shortstring; overload; |
146 // get string without surrounding whitespace |
149 // get string without surrounding whitespace |
147 len:= right - left + 1; |
150 len:= right - left + 1; |
148 |
151 |
149 Trim:= copy(s, left, len); |
152 Trim:= copy(s, left, len); |
150 |
153 |
|
154 end; |
|
155 |
|
156 function GetLastSlashPos(var s: shortString) : integer; |
|
157 var lslash: integer; |
|
158 c: char; |
|
159 begin |
|
160 |
|
161 // find last slash |
|
162 lslash:= Length(s); |
|
163 while lslash >= 1 do |
|
164 begin |
|
165 c:= s[lslash]; |
|
166 if (c = #47) or (c = #92) then |
|
167 break; |
|
168 dec(lslash); end; |
|
169 |
|
170 GetLastSlashPos:= lslash; |
|
171 end; |
|
172 |
|
173 function ExtractFileDir(s: shortstring) : shortstring; |
|
174 var lslash: byte; |
|
175 begin |
|
176 |
|
177 if Length(s) = 0 then |
|
178 exit(s); |
|
179 |
|
180 lslash:= GetLastSlashPos(s); |
|
181 |
|
182 if lslash <= 1 then |
|
183 exit(''); |
|
184 |
|
185 s[0]:= char(lslash - 1); |
|
186 |
|
187 ExtractFileDir:= s; |
|
188 end; |
|
189 |
|
190 function ExtractFileName(s: shortstring) : shortstring; |
|
191 var lslash, len: byte; |
|
192 begin |
|
193 |
|
194 len:= Length(s); |
|
195 |
|
196 if len = 0 then |
|
197 exit(s); |
|
198 |
|
199 lslash:= GetLastSlashPos(s); |
|
200 |
|
201 if lslash < 1 then |
|
202 exit(s); |
|
203 |
|
204 if lslash = len then |
|
205 exit(''); |
|
206 |
|
207 len:= len - lslash; |
|
208 ExtractFilename:= copy(s, lslash + 1, len); |
151 end; |
209 end; |
152 |
210 |
153 procedure SplitBySpace(var a,b: shortstring); |
211 procedure SplitBySpace(var a,b: shortstring); |
154 begin |
212 begin |
155 SplitByChar(a,b,' '); |
213 SplitByChar(a,b,' '); |