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;
618 for a
:= 1 to Length(Str
) do
619 if (a
= Length(Str
)) or (Str
[a
+1] = ' ') then
621 Result
:= Copy(Str
, 1, a
);
628 {function GetLines(Text: string; MaxChars: Word): SArray;
636 while Pos(' ', Text) <> 0 do Text := AnsiReplaceStr(Text, ' ', ' ');
640 SetLength(b, Length(b)+1);
641 b[High(b)] := GetStr(Text);
647 if a > High(b) then Break;
652 if Length(str) >= MaxChars then
656 SetLength(Result, Length(Result)+1);
657 Result[High(Result)] := Copy(str, 1, MaxChars);
658 Delete(str, 1, MaxChars);
664 while (a <= High(b)) and (Length(str+' '+b[a]) <= MaxChars) do
670 SetLength(Result, Length(Result)+1);
671 Result[High(Result)] := str;
675 function GetLines(Text: string; FontID
: DWORD
; MaxWidth
: Word): SArray
;
677 function TextLen(Text: string): Word;
681 e_CharFont_GetSize(FontID
, Text, Result
, h
);
689 SetLength(Result
, 0);
694 // Óäàëÿåì ìíîæåñòâåííûå ïðîáåëû:
695 while Pos(' ', Text) <> 0 do
696 Text := AnsiReplaceStr(Text, ' ', ' ');
700 SetLength(b
, Length(b
)+1);
701 b
[High(b
)] := GetStr(Text);
713 if TextLen(str
) > MaxWidth
then
714 begin // Òåêóùàÿ ñòðîêà ñëèøêîì äëèííàÿ => ðàçáèâàåì
717 SetLength(Result
, Length(Result
)+1);
720 while (c
< Length(str
)) and
721 (TextLen(Copy(str
, 1, c
+1)) < MaxWidth
) do
724 Result
[High(Result
)] := Copy(str
, 1, c
);
728 else // Ñòðîêà íîðìàëüíîé äëèíû => ñîåäèíÿåì ñî ñëåäóþùèìè
730 while (a
<= High(b
)) and
731 (TextLen(str
+' '+b
[a
]) < MaxWidth
) do
737 SetLength(Result
, Length(Result
)+1);
738 Result
[High(Result
)] := str
;
743 procedure Sort(var a
: SArray
);
748 if a
= nil then Exit
;
750 for i
:= High(a
) downto Low(a
) do
751 for j
:= Low(a
) to High(a
)-1 do
752 if LowerCase(a
[j
]) > LowerCase(a
[j
+1]) then
760 function Sscanf(const s
: String; const fmt
: String;
761 const Pointers
: array of Pointer): Integer;
768 function GetInt(): Integer;
771 while (n
<= Length(s
)) and (s
[n
] = ' ') do
774 while (n
<= Length(s
)) and (s
[n
] in ['0'..'9', '+', '-']) do
780 Result
:= Length(s1
);
783 function GetFloat(): Integer;
786 while (n
<= Length(s
)) and (s
[n
] = ' ') do
789 while (n
<= Length(s
)) and //jd >= rather than >
790 (s
[n
] in ['0'..'9', '+', '-', '.', 'e', 'E']) do
796 Result
:= Length(s1
);
799 function GetString(): Integer;
802 while (n
<= Length(s
)) and (s
[n
] = ' ') do
805 while (n
<= Length(s
)) and (s
[n
] <> ' ') do
811 Result
:= Length(s1
);
814 function ScanStr(c
: Char): Boolean;
816 while (n
<= Length(s
)) and (s
[n
] <> c
) do
820 Result
:= (n
<= Length(s
));
823 function GetFmt(): Integer;
829 while (fmt
[m
] = ' ') and (m
< Length(fmt
)) do
831 if (m
>= Length(fmt
)) then
834 if (fmt
[m
] = '%') then
838 'd': Result
:= vtInteger
;
839 'f': Result
:= vtExtended
;
840 's': Result
:= vtString
;
846 if (not ScanStr(fmt
[m
])) then
858 for i
:= 0 to High(Pointers
) do
867 L
:= StrToIntDef(s1
, 0);
868 Move(L
, Pointers
[i
]^, SizeOf(LongInt));
877 if GetFloat() > 0 then
879 X
:= StrToFloatDef(s1
, 0.0);
880 Move(X
, Pointers
[i
]^, SizeOf(Extended
));
889 if GetString() > 0 then
891 Move(s1
, Pointers
[i
]^, Length(s1
)+1);
904 function InDWArray(a
: DWORD
; arr
: DWArray
): Boolean;
910 if arr
= nil then Exit
;
912 for b
:= 0 to High(arr
) do
920 function InWArray(a
: Word; arr
: WArray
): Boolean;
926 if arr
= nil then Exit
;
928 for b
:= 0 to High(arr
) do
936 function InSArray(a
: string; arr
: SArray
): Boolean;
942 if arr
= nil then Exit
;
944 a
:= AnsiLowerCase(a
);
946 for b
:= 0 to High(arr
) do
947 if AnsiLowerCase(arr
[b
]) = a
then
954 function GetPos(UID
: Word; o
: PObj
): Boolean;
961 case g_GetUIDType(UID
) of
964 p
:= g_Player_Get(UID
);
965 if p
= nil then Exit
;
966 if not p
.Live
then Exit
;
973 m
:= g_Monsters_Get(UID
);
974 if m
= nil then Exit
;
975 if not m
.Live
then Exit
;
985 function parse(s
: String): SArray
;
995 for a
:= 1 to Length(s
) do
996 if (s
[a
] = ',') or (a
= Length(s
)) then
998 SetLength(Result
, Length(Result
)+1);
1001 Result
[High(Result
)] := Copy(s
, 1, a
-1)
1002 else // Êîíåö ñòðîêè
1003 Result
[High(Result
)] := s
;
1011 function parse2(s
: string; delim
: Char): SArray
;
1016 if s
= '' then Exit
;
1020 for a
:= 1 to Length(s
) do
1021 if (s
[a
] = delim
) or (a
= Length(s
)) then
1023 SetLength(Result
, Length(Result
)+1);
1025 if s
[a
] = delim
then Result
[High(Result
)] := Copy(s
, 1, a
-1)
1026 else Result
[High(Result
)] := s
;
1034 function g_GetFileTime(fileName
: String): Integer;
1038 if not FileExists(fileName
) then
1044 AssignFile(F
, fileName
);
1046 Result
:= FileGetDate(TFileRec(F
).Handle
);
1050 function g_SetFileTime(fileName
: String; time
: Integer): Boolean;
1054 if (not FileExists(fileName
)) or (time
< 0) then
1060 AssignFile(F
, fileName
);
1062 Result
:= (FileSetDate(TFileRec(F
).Handle
, time
) = 0);
1066 procedure SortSArray(var S
: SArray
);
1074 for i
:= Low(S
) to High(S
) - 1 do
1075 if S
[i
] > S
[i
+ 1] then begin
1084 function b_Text_Format(S
: string): string;
1092 for I
:= 1 to Length(S
) do
1094 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1104 Result
:= Result
+ #10;
1106 Result
:= Result
+ #1;
1108 Result
:= Result
+ #2;
1110 Result
:= Result
+ #3;
1112 Result
:= Result
+ #4;
1114 Result
:= Result
+ #18;
1116 Result
:= Result
+ #19;
1118 Result
:= Result
+ #20;
1120 Result
:= Result
+ #21;
1122 Result
:= Result
+ '\';
1124 Result
:= Result
+ '\' + S
[I
];
1128 Result
:= Result
+ S
[I
];
1130 // reset to white at end
1131 if Rst
then Result
:= Result
+ #2;
1134 function b_Text_Unformat(S
: string): string;
1141 for I
:= 1 to Length(S
) do
1143 if S
[I
] in [#1, #2, #3, #4, #10, #18, #19, #20, #21] then
1148 if (not Spec
) and (S
[I
] = '\') and (I
+ 1 <= Length(S
)) then
1165 '\': Result
:= Result
+ '\';
1167 Result
:= Result
+ '\' + S
[I
];
1171 Result
:= Result
+ S
[I
];