e1ce980bc548a2f5e0e7ed16a7f745daab755fe0
9 GAME_VERSION
= '0.667';
15 UID_MAX_PLAYER
= $7FFF;
16 UID_MAX_MONSTER
= $FFFF;
19 TDirection
= (D_LEFT
, D_RIGHT
);
20 WArray
= array of Word;
21 DWArray
= array of DWORD
;
22 String20
= String[20];
24 function g_CreateUID(UIDType
: Byte): Word;
25 function g_GetUIDType(UID
: Word): Byte;
26 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
27 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
28 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
29 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
30 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
31 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
32 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
33 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
34 function g_CollideMonster(X
, Y
: Integer; Width
, Height
: Word): Boolean;
35 function g_CollideItem(X
, Y
: Integer; Width
, Height
: Word): Boolean;
36 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
37 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
38 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
39 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
40 procedure IncMax(var A
: Integer; B
, Max
: Integer); overload
;
41 procedure IncMax(var A
: Single; B
, Max
: Single); overload
;
42 procedure IncMax(var A
: Integer; Max
: Integer); overload
;
43 procedure IncMax(var A
: Single; Max
: Single); overload
;
44 procedure IncMax(var A
: Word; B
, Max
: Word); overload
;
45 procedure IncMax(var A
: Word; Max
: Word); overload
;
46 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt); overload
;
47 procedure IncMax(var A
: SmallInt; Max
: SmallInt); overload
;
48 procedure DecMin(var A
: Integer; B
, Min
: Integer); overload
;
49 procedure DecMin(var A
: Single; B
, Min
: Single); overload
;
50 procedure DecMin(var A
: Integer; Min
: Integer); overload
;
51 procedure DecMin(var A
: Single; Min
: Single); overload
;
52 procedure DecMin(var A
: Word; B
, Min
: Word); overload
;
53 procedure DecMin(var A
: Word; Min
: Word); overload
;
54 procedure DecMin(var A
: Byte; B
, Min
: Byte); overload
;
55 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
56 function Sign(A
: Integer): ShortInt; overload
;
57 function Sign(A
: Single): ShortInt; overload
;
58 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
59 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
60 function GetAngle2(vx
, vy
: Integer): SmallInt;
61 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
62 procedure Sort(var a
: SArray
);
63 function Sscanf(const s
: string; const fmt
: string;
64 const Pointers
: array of Pointer): Integer;
65 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
66 function InWArray(a
: Word; arr
: WArray
): Boolean;
67 function InSArray(a
: string; arr
: SArray
): Boolean;
68 function GetPos(UID
: Word; o
: PObj
): Boolean;
69 function parse(s
: string): SArray
;
70 function parse2(s
: string; delim
: Char): SArray
;
71 function g_GetFileTime(fileName
: String): Integer;
72 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
73 procedure SortSArray(var S
: SArray
);
74 function b_Text_Format(S
: string): string;
75 function b_Text_Unformat(S
: string): string;
80 Math
, g_map
, g_gfx
, g_player
, SysUtils
, MAPDEF
,
81 StrUtils
, e_graphics
, g_monsters
, g_items
;
83 function g_PatchLength(X1
, Y1
, X2
, Y2
: Integer): Word;
85 Result
:= Min(Round(Hypot(Abs(X2
-X1
), Abs(Y2
-Y1
))), 65535);
88 function g_CollideLevel(X
, Y
: Integer; Width
, Height
: Word): Boolean;
97 for a
:= 0 to High(gWalls
) do
98 if gWalls
[a
].Enabled
and
99 not ( ((Y
+ Height
<= gWalls
[a
].Y
) or
100 (Y
>= gWalls
[a
].Y
+ gWalls
[a
].Height
)) or
101 ((X
+ Width
<= gWalls
[a
].X
) or
102 (X
>= gWalls
[a
].X
+ gWalls
[a
].Width
)) ) then
109 function g_CollidePlayer(X
, Y
: Integer; Width
, Height
: Word): Boolean;
115 if gPlayers
= nil then Exit
;
117 for a
:= 0 to High(gPlayers
) do
118 if (gPlayers
[a
] <> nil) and gPlayers
[a
].Live
then
119 if gPlayers
[a
].Collide(X
, Y
, Width
, Height
) then
126 function g_CollideMonster(X
, Y
: Integer; Width
, Height
: Word): Boolean;
132 if gMonsters
= nil then Exit
;
134 for a
:= 0 to High(gMonsters
) do
135 if (gMonsters
[a
] <> nil) and gMonsters
[a
].Live
then
136 if g_Obj_Collide(X
, Y
, Width
, Height
, @gMonsters
[a
].Obj
) then
143 function g_CollideItem(X
, Y
: Integer; Width
, Height
: Word): Boolean;
152 for a
:= 0 to High(gItems
) do
153 if gItems
[a
].Live
then
154 if g_Obj_Collide(X
, Y
, Width
, Height
, @gItems
[a
].Obj
) then
161 function g_TraceVector(X1
, Y1
, X2
, Y2
: Integer): Boolean;
165 Xerr
, Yerr
, d
: LongWord;
171 Assert(gCollideMap
<> nil, 'g_TraceVector: gCollideMap = nil');
178 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
179 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
184 if dx
> dy
then d
:= dx
else d
:= dy
;
204 if (y
> gMapInfo
.Height
-1) or
205 (y
< 0) or (x
> gMapInfo
.Width
-1) or (x
< 0) then
207 if ByteBool(gCollideMap
[y
, x
] and MARK_BLOCKED
) then
214 function g_CreateUID(UIDType
: Byte): Word;
225 Result
:= UID_MAX_GAME
+$1+Random(UID_MAX_PLAYER
-UID_MAX_GAME
+$1);
228 if gPlayers
<> nil then
229 for i
:= 0 to High(gPlayers
) do
230 if gPlayers
[i
] <> nil then
231 if Result
= gPlayers
[i
].UID
then
242 Result
:= UID_MAX_PLAYER
+$1+Random(UID_MAX_MONSTER
-UID_MAX_GAME
-UID_MAX_PLAYER
+$1);
245 if gMonsters
<> nil then
246 for i
:= 0 to High(gMonsters
) do
247 if gMonsters
[i
] <> nil then
248 if Result
= gMonsters
[i
].UID
then
258 function g_GetUIDType(UID
: Word): Byte;
260 if UID
<= UID_MAX_GAME
then
263 if UID
<= UID_MAX_PLAYER
then
266 Result
:= UID_MONSTER
;
269 function g_Collide(X1
, Y1
: Integer; Width1
, Height1
: Word;
270 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
272 Result
:= not ( ((Y1
+ Height1
<= Y2
) or
273 (Y2
+ Height2
<= Y1
)) or
274 ((X1
+ Width1
<= X2
) or
275 (X2
+ Width2
<= X1
)) );
278 function g_CollideAround(X1
, Y1
: Integer; Width1
, Height1
: Word;
279 X2
, Y2
: Integer; Width2
, Height2
: Word): Boolean;
281 Result
:= g_Collide(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
282 g_Collide(X1
+1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
283 g_Collide(X1
-1, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
284 g_Collide(X1
, Y1
+1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
) or
285 g_Collide(X1
, Y1
-1, Width1
, Height1
, X2
, Y2
, Width2
, Height2
);
288 function c(X1
, Y1
, Width1
, Height1
, X2
, Y2
, Width2
, Height2
: Integer): Boolean;
290 Result
:= not (((Y1
+ Height1
<= Y2
) or
291 (Y1
>= Y2
+ Height2
)) or
292 ((X1
+ Width1
<= X2
) or
293 (X1
>= X2
+ Width2
)));
296 function g_Collide2(X1
, Y1
, X2
, Y2
, X3
, Y3
, X4
, Y4
: Integer): Boolean;
298 //Result := not (((Y2 <= Y3) or (Y1 >= Y4)) or ((X2 <= X3) or (X1 >= X4)));
299 Result
:= c(X1
, Y1
, X2
-X1
, Y2
-Y1
, X3
, Y3
, X4
-X3
, Y4
-Y3
);
302 function g_CollidePoint(X
, Y
, X2
, Y2
: Integer; Width
, Height
: Word): Boolean;
306 Result
:= (x
>= 0) and (x
<= Width
) and
307 (y
>= 0) and (y
<= Height
);
310 procedure IncMax(var A
: Integer; B
, Max
: Integer);
312 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
315 procedure IncMax(var A
: Single; B
, Max
: Single);
317 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
320 procedure DecMin(var A
: Integer; B
, Min
: Integer);
322 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
325 procedure DecMin(var A
: Word; B
, Min
: Word);
327 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
330 procedure DecMin(var A
: Single; B
, Min
: Single);
332 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
335 procedure IncMax(var A
: Integer; Max
: Integer);
337 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
340 procedure IncMax(var A
: Single; Max
: Single);
342 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
345 procedure IncMax(var A
: Word; B
, Max
: Word);
347 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
350 procedure IncMax(var A
: Word; Max
: Word);
352 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
355 procedure IncMax(var A
: SmallInt; B
, Max
: SmallInt);
357 if A
+B
> Max
then A
:= Max
else A
:= A
+B
;
360 procedure IncMax(var A
: SmallInt; Max
: SmallInt);
362 if A
+1 > Max
then A
:= Max
else A
:= A
+1;
365 procedure DecMin(var A
: Integer; Min
: Integer);
367 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
370 procedure DecMin(var A
: Single; Min
: Single);
372 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
375 procedure DecMin(var A
: Word; Min
: Word);
377 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
380 procedure DecMin(var A
: Byte; B
, Min
: Byte);
382 if A
-B
< Min
then A
:= Min
else A
:= A
-B
;
385 procedure DecMin(var A
: Byte; Min
: Byte); overload
;
387 if A
-1 < Min
then A
:= Min
else A
:= A
-1;
390 function Sign(A
: Integer): ShortInt;
392 if A
< 0 then Result
:= -1
393 else if A
> 0 then Result
:= 1
397 function Sign(A
: Single): ShortInt;
401 if Abs(A
) < Eps
then Result
:= 0
402 else if A
< 0 then Result
:= -1
406 function PointToRect(X
, Y
, X1
, Y1
: Integer; Width
, Height
: Word): Integer;
408 X
:= X
-X1
; // A(0;0) --- B(W;0)
413 if Y
< 0 then // Ñëåâà ñâåðõó: ðàññòîÿíèå äî A
414 Result
:= Round(Hypot(X
, Y
))
416 if Y
> Height
then // Ñëåâà ñíèçó: ðàññòîÿíèå äî D
417 Result
:= Round(Hypot(X
, Y
-Height
))
418 else // Ñëåâà ïîñåðåäèíå: ðàññòîÿíèå äî AD
425 if y
< 0 then // Ñïðàâà ñâåðõó: ðàññòîÿíèå äî B
426 Result
:= Round(Hypot(X
, Y
))
428 if Y
> Height
then // Ñïðàâà ñíèçó: ðàññòîÿíèå äî C
429 Result
:= Round(Hypot(X
, Y
-Height
))
430 else // Ñïðàâà ïîñåðåäèíå: ðàññòîÿíèå äî BC
435 if Y
< 0 then // Ïîñåðåäèíå ñâåðõó: ðàññòîÿíèå äî AB
438 if Y
> Height
then // Ïîñåðåäèíå ñíèçó: ðàññòîÿíèå äî DC
440 else // Âíóòðè ïðÿìîóãîëüíèêà: ðàññòîÿíèå 0
445 function g_GetAcidHit(X
, Y
: Integer; Width
, Height
: Word): Byte;
447 tab
: array[0..3] of Byte = (0, 5, 10, 20);
453 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID1
, False) then a
:= a
or 1;
454 if g_Map_CollidePanel(X
, Y
, Width
, Height
, PANEL_ACID2
, False) then a
:= a
or 2;
459 function g_Look(a
, b
: PObj
; d
: TDirection
): Boolean;
461 if ((b
^.X
> a
^.X
) and (d
= D_LEFT
)) or
462 ((b
^.X
< a
^.X
) and (d
= D_RIGHT
)) then
468 Result
:= g_TraceVector(a
^.X
+a
^.Rect
.X
+(a
^.Rect
.Width
div 2),
469 a
^.Y
+a
^.Rect
.Y
+(a
^.Rect
.Height
div 2),
470 b
^.X
+b
^.Rect
.X
+(b
^.Rect
.Width
div 2),
471 b
^.Y
+b
^.Rect
.Y
+(b
^.Rect
.Height
div 2));
474 function GetAngle(baseX
, baseY
, pointX
, PointY
: Integer): SmallInt;
479 a
:= abs(pointX
-baseX
);
480 b
:= abs(pointY
-baseY
);
482 if a
= 0 then c
:= 90
483 else c
:= RadToDeg(ArcTan(b
/a
));
485 if pointY
< baseY
then c
:= -c
;
486 if pointX
> baseX
then c
:= 180-c
;
491 function GetAngle2(vx
, vy
: Integer): SmallInt;
502 c
:= RadToDeg(ArcTan(b
/a
));
514 {function g_CollideLine(x1, y1, x2, y2, rX, rY: Integer; rWidth, rHeight: Word): Boolean;
516 table: array[0..8, 0..8] of Byte =
517 ((0, 0, 3, 3, 1, 2, 2, 0, 1),
518 (0, 0, 0, 0, 4, 7, 2, 0, 1),
519 (3, 0, 0, 0, 4, 4, 1, 3, 1),
520 (3, 0, 0, 0, 0, 0, 5, 6, 1),
521 (1, 4, 4, 0, 0, 0, 5, 5, 1),
522 (2, 7, 4, 0, 0, 0, 0, 0, 1),
523 (2, 2, 1, 5, 5, 0, 0, 0, 1),
524 (0, 0, 3, 6, 5, 0, 0, 0, 1),
525 (1, 1, 1, 1, 1, 1, 1, 1, 1));
527 function GetClass(x, y: Integer): Byte;
531 if x < rX then Result := 7
532 else if x < rX+rWidth then Result := 0
535 else if y < rY+rHeight then
537 if x < rX then Result := 6
538 else if x < rX+rWidth then Result := 8
543 if x < rX then Result := 5
544 else if x < rX+rWidth then Result := 4
550 case table[GetClass(x1, y1), GetClass(x2, y2)] of
553 2: Result := Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1));
554 3: Result := Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1));
555 4: Result := Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1));
556 5: Result := Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1));
557 6: Result := (Abs((rY-y1))/Abs((rX+rWidth-x1)) <= Abs((y2-y1))/Abs((x2-x1))) and
558 (Abs((rY+rHeight-y1))/Abs((rX-x1)) >= Abs((y2-y1))/Abs((x2-x1)));
559 7: Result := (Abs((rY+rHeight-y1))/Abs((rX+rWidth-x1)) >= Abs((y2-y1))/Abs((x2-x1))) and
560 (Abs((rY-y1))/Abs((rX-x1)) <= Abs((y2-y1))/Abs((x2-x1)));
561 else Result := False;
565 function g_CollideLine(x1
, y1
, x2
, y2
, rX
, rY
: Integer; rWidth
, rHeight
: Word): Boolean;
580 if dx
> 0 then incX
:= 1 else if dx
< 0 then incX
:= -1 else incX
:= 0;
581 if dy
> 0 then incY
:= 1 else if dy
< 0 then incY
:= -1 else incY
:= 0;
586 if dx
> dy
then d
:= dx
else d
:= dy
;
606 if (x
>= rX
) and (x
<= (rX
+ rWidth
- 1)) and
607 (y
>= rY
) and (y
<= (rY
+ rHeight
- 1)) then Exit
;
613 function GetStr(var Str
: string): string;
617 for a
:= 1 to Length(Str
) do
618 if (a
= Length(Str
)) or (Str
[a
+1] = ' ') then
620 Result
:= Copy(Str
, 1, a
);
627 {function GetLines(Text: string; MaxChars: Word): SArray;
635 while Pos(' ', Text) <> 0 do Text := AnsiReplaceStr(Text, ' ', ' ');
639 SetLength(b, Length(b)+1);
640 b[High(b)] := GetStr(Text);
646 if a > High(b) then Break;
651 if Length(str) >= MaxChars then
655 SetLength(Result, Length(Result)+1);
656 Result[High(Result)] := Copy(str, 1, MaxChars);
657 Delete(str, 1, MaxChars);
663 while (a <= High(b)) and (Length(str+' '+b[a]) <= MaxChars) do
669 SetLength(Result, Length(Result)+1);
670 Result[High(Result)] := str;
674 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
676 function TextLen(Text: string): Word;
680 e_CharFont_GetSize(FontID
, Text, Result
, h
);
688 SetLength(Result
, 0);
693 // Óäàëÿåì ìíîæåñòâåííûå ïðîáåëû:
694 while Pos(' ', Text) <> 0 do
695 Text := AnsiReplaceStr(Text, ' ', ' ');
699 SetLength(b
, Length(b
)+1);
700 b
[High(b
)] := GetStr(Text);
712 if TextLen(str
) > MaxWidth
then
713 begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì
716 SetLength(Result
, Length(Result
)+1);
719 while (c
< Length(str
)) and
720 (TextLen(Copy(str
, 1, c
+1)) < MaxWidth
) do
723 Result
[High(Result
)] := Copy(str
, 1, c
);
727 else // Ñòðîêà íîðìàëüíîé äëèíû => ñîåäèíÿåì ñî ñëåäóþùèìè
729 while (a
<= High(b
)) and
730 (TextLen(str
+' '+b
[a
]) < MaxWidth
) do
736 SetLength(Result
, Length(Result
)+1);
737 Result
[High(Result
)] := str
;
742 procedure Sort(var a
: SArray
);
747 if a
= nil then Exit
;
749 for i
:= High(a
) downto Low(a
) do
750 for j
:= Low(a
) to High(a
)-1 do
751 if LowerCase(a
[j
]) > LowerCase(a
[j
+1]) then
759 function Sscanf(const s
: String; const fmt
: String;
760 const Pointers
: array of Pointer): Integer;
767 function GetInt(): Integer;
770 while (n
<= Length(s
)) and (s
[n
] = ' ') do
773 while (n
<= Length(s
)) and (s
[n
] in ['0'..'9', '+', '-']) do
779 Result
:= Length(s1
);
782 function GetFloat(): Integer;
785 while (n
<= Length(s
)) and (s
[n
] = ' ') do
788 while (n
<= Length(s
)) and //jd >= rather than >
789 (s
[n
] in ['0'..'9', '+', '-', '.', 'e', 'E']) do
795 Result
:= Length(s1
);
798 function GetString(): Integer;
801 while (n
<= Length(s
)) and (s
[n
] = ' ') do
804 while (n
<= Length(s
)) and (s
[n
] <> ' ') do
810 Result
:= Length(s1
);
813 function ScanStr(c
: Char): Boolean;
815 while (n
<= Length(s
)) and (s
[n
] <> c
) do
819 Result
:= (n
<= Length(s
));
822 function GetFmt(): Integer;
828 while (fmt
[m
] = ' ') and (m
< Length(fmt
)) do
830 if (m
>= Length(fmt
)) then
833 if (fmt
[m
] = '%') then
837 'd': Result
:= vtInteger
;
838 'f': Result
:= vtExtended
;
839 's': Result
:= vtString
;
845 if (not ScanStr(fmt
[m
])) then
856 for i
:= 0 to High(Pointers
) do
865 L
:= StrToIntDef(s1
, 0);
866 Move(L
, Pointers
[i
]^, SizeOf(LongInt));
875 if GetFloat() > 0 then
877 X
:= StrToFloatDef(s1
, 0.0);
878 Move(X
, Pointers
[i
]^, SizeOf(Extended
));
887 if GetString() > 0 then
889 Move(s1
, Pointers
[i
]^, Length(s1
)+1);
902 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
908 if arr
= nil then Exit
;
910 for b
:= 0 to High(arr
) do
918 function InWArray(a
: Word; arr
: WArray
): Boolean;
924 if arr
= nil then Exit
;
926 for b
:= 0 to High(arr
) do
934 function InSArray(a
: string; arr
: SArray
): Boolean;
940 if arr
= nil then Exit
;
942 a
:= AnsiLowerCase(a
);
944 for b
:= 0 to High(arr
) do
945 if AnsiLowerCase(arr
[b
]) = a
then
952 function GetPos(UID
: Word; o
: PObj
): Boolean;
959 case g_GetUIDType(UID
) of
962 p
:= g_Player_Get(UID
);
963 if p
= nil then Exit
;
964 if not p
.Live
then Exit
;
971 m
:= g_Monsters_Get(UID
);
972 if m
= nil then Exit
;
973 if not m
.Live
then Exit
;
983 function parse(s
: String): SArray
;
993 for a
:= 1 to Length(s
) do
994 if (s
[a
] = ',') or (a
= Length(s
)) then
996 SetLength(Result
, Length(Result
)+1);
999 Result
[High(Result
)] := Copy(s
, 1, a
-1)
1000 else // Êîíåö ñòðîêè
1001 Result
[High(Result
)] := s
;
1009 function parse2(s
: string; delim
: Char): SArray
;
1014 if s
= '' then Exit
;
1018 for a
:= 1 to Length(s
) do
1019 if (s
[a
] = delim
) or (a
= Length(s
)) then
1021 SetLength(Result
, Length(Result
)+1);
1023 if s
[a
] = delim
then Result
[High(Result
)] := Copy(s
, 1, a
-1)
1024 else Result
[High(Result
)] := s
;
1032 function g_GetFileTime(fileName
: String): Integer;
1036 if not FileExists(fileName
) then
1042 AssignFile(F
, fileName
);
1044 Result
:= FileGetDate(TFileRec(F
).Handle
);
1048 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
1052 if (not FileExists(fileName
)) or (time
< 0) then
1058 AssignFile(F
, fileName
);
1060 Result
:= (FileSetDate(TFileRec(F
).Handle
, time
) = 0);
1064 procedure SortSArray(var S
: SArray
);
1072 for i
:= Low(S
) to High(S
) - 1 do
1073 if S
[i
] > S
[i
+ 1] then begin
1082 function b_Text_Format(S
: string): string;
1090 for I
:= 1 to Length(S
) do
1092 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1102 Result
:= Result
+ #10;
1104 Result
:= Result
+ #1;
1106 Result
:= Result
+ #2;
1108 Result
:= Result
+ #3;
1110 Result
:= Result
+ #4;
1112 Result
:= Result
+ #18;
1114 Result
:= Result
+ #19;
1116 Result
:= Result
+ #20;
1118 Result
:= Result
+ #21;
1120 Result
:= Result
+ '\';
1122 Result
:= Result
+ '\' + S
[I
];
1126 Result
:= Result
+ S
[I
];
1128 // reset to white at end
1129 if Rst
then Result
:= Result
+ #2;
1132 function b_Text_Unformat(S
: string): string;
1139 for I
:= 1 to Length(S
) do
1141 if S
[I
] in [#1, #2, #3, #4, #10, #18, #19, #20, #21] then
1146 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1163 '\': Result
:= Result
+ '\';
1165 Result
:= Result
+ '\' + S
[I
];
1169 Result
:= Result
+ S
[I
];