Rev 739 | Rev 744 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 739 | Rev 740 | ||
---|---|---|---|
Line 18... | Line 18... | ||
18 | function CompareNumericString(a, b: string): integer; |
18 | function CompareNumericString(a, b: string): integer; |
19 | 19 | ||
20 | procedure Beep; |
20 | procedure Beep; |
21 | 21 | ||
22 | function Trim(s: string): string; |
22 | function Trim(s: string): string; |
- | 23 | function TrimLineToWidth(s: string; width: integer): string; |
|
23 | function ZeroPad(i: LongInt; n: integer): string; |
24 | function ZeroPad(i: LongInt; n: integer): string; |
24 | function LeftPadStr(s: string; n: integer; ch: char): string; |
25 | function LeftPadStr(s: string; n: integer; ch: char): string; |
25 | function RightPadStr(s: string; n: integer; ch: char): string; |
26 | function RightPadStr(s: string; n: integer; ch: char): string; |
- | 27 | function RepeatStr(ch: char; n: integer): string; |
|
26 | 28 | ||
27 | function DeleteFile(filename: string): boolean; |
29 | function DeleteFile(filename: string): boolean; |
28 | function FileExists(filename: string): boolean; |
30 | function FileExists(filename: string): boolean; |
29 | 31 | ||
30 | function IsPositiveInteger(s: string): boolean; |
32 | function IsPositiveInteger(s: string): boolean; |
Line 108... | Line 110... | ||
108 | break; |
110 | break; |
109 | end; |
111 | end; |
110 | Trim := s; |
112 | Trim := s; |
111 | end; |
113 | end; |
112 | 114 | ||
- | 115 | function TrimLineToWidth(s: string; width: integer): string; |
|
- | 116 | begin |
|
- | 117 | (* TODO: Put into VTSUTILS, also use for VTSCUI menu *) |
|
- | 118 | if Length(s) > width then |
|
- | 119 | begin |
|
- | 120 | s := Copy(s, 1, width-3) + '...'; |
|
- | 121 | end; |
|
- | 122 | TrimLineToWidth := s; |
|
- | 123 | end; |
|
- | 124 | ||
113 | function ZeroPad(i: LongInt; n: integer): string; |
125 | function ZeroPad(i: LongInt; n: integer): string; |
114 | var |
126 | var |
115 | s: string; |
127 | s: string; |
116 | begin |
128 | begin |
117 | s := IntToStr(i); |
129 | s := IntToStr(i); |
Line 134... | Line 146... | ||
134 | s := s + ch; |
146 | s := s + ch; |
135 | end; |
147 | end; |
136 | RightPadStr := s; |
148 | RightPadStr := s; |
137 | end; |
149 | end; |
138 | 150 | ||
- | 151 | function RepeatStr(ch: char; n: integer): string; |
|
- | 152 | var |
|
- | 153 | i: integer; |
|
- | 154 | res: string; |
|
- | 155 | begin |
|
- | 156 | res := ''; |
|
- | 157 | for i := 1 to n do |
|
- | 158 | begin |
|
- | 159 | res := res + ch; |
|
- | 160 | end; |
|
- | 161 | RepeatStr := res; |
|
- | 162 | end; |
|
- | 163 | ||
139 | function DeleteFile(filename: string): boolean; |
164 | function DeleteFile(filename: string): boolean; |
140 | var |
165 | var |
141 | F: file; |
166 | F: file; |
142 | Ch: Char; |
167 | Ch: Char; |
143 | begin |
168 | begin |
Line 165... | Line 190... | ||
165 | begin |
190 | begin |
166 | Assign(F, filename); |
191 | Assign(F, filename); |
167 | {$I-} |
192 | {$I-} |
168 | Reset(F); |
193 | Reset(F); |
169 | {$I+} |
194 | {$I+} |
- | 195 | if IoResult = 0 then |
|
- | 196 | begin |
|
- | 197 | Close(F); |
|
- | 198 | FileExists := true; |
|
- | 199 | end |
|
- | 200 | else |
|
- | 201 | begin |
|
170 | FileExists := IoResult = 0; |
202 | FileExists := false; |
- | 203 | end; |
|
171 | end; |
204 | end; |
172 | 205 | ||
173 | function IsPositiveInteger(s: string): boolean; |
206 | function IsPositiveInteger(s: string): boolean; |
174 | var |
207 | var |
175 | i: integer; |
208 | i: integer; |