Sign in Join
Wiki copytemporary

Extended Format Function/pl: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Extended Format Function/pl

OldNewLine
1+## Opis
2+
3+Moduł efmtf to zestaw klas i procedur umożliwiający formatowanie ciągów tekstowych na podstawie parametrów przekazanych w tablicy, z możliwością dodawania własnych reguł formatowania dla zmiennych obiektowych oraz wsparciem dla języka SQL. Moduł jest nadal zależny od standardowych funkcji FormatDateTime oraz Format.
4+
5+## Przykłady
6+
7+Formatowanie z adresowaniem zmiennych
8+
9+``` pascal
10+S := Fmt('string: {0:s}, integer: {1:d}, money: {2:m}, float: {2:f}', ['test', 1, 22.3]);
11+wynik: string: test, integer: 1, money: 22.30 zł, float: 22.3
12+```
13+
14+Adresowanie mieszane i domyślne formatowanie
15+
16+``` pascal
17+S := Fmt('string: {}, integer: {}, money: {:m}, float: {2}', ['test', 1, 22.3]);
18+wynik: string: test, integer: 1, money: 22.30 zł, float: 22.3
19+```
20+
21+Wsparcie dla SQL (parametry pisane z dużej litery):
22+
23+``` pascal
24+S := Fmt('SELECT * FROM employees WHERE FirstName = {:S} AND DateHired < {:TD};', ['John', Now]);
25+wynik: SELECT * FROM employees WHERE FirstName = 'John' AND DateHired < '2009-01-01';
26+```
27+
28+Wsparcie dla parametrów globalnych
29+
30+``` pascal
31+SetParam('test', 'World');
32+S := Fmt('Hello {$test}!');
33+
34+wynik: Hello World!
35+```
36+
37+Wsparcie dla formatowania zmiennych obiektowych:
38+
39+``` pascal
40+// funkcja formatująca
41+function FormFmt(AObject: TObject; Mode: Char; Param: string): string;
42+var
43+ f: TForm;
44+begin
45+ if AObject is TForm then
46+ begin
47+ f := TForm(AObject);
48+ if Param = 'caption' then
49+ Result := f.Caption
50+ else
51+ Result := f.Name;
52+ end;
53+end;
54+
55+// przykład
56+RegisterFunction(TForm, FormFmt);
57+S := Fmt('caption: {0:scaption}, name: {0:s}', [Form1]);
58+```
59+
60+Escaped String
61+
62+``` pascal
63+S := Fmt('\{2 + 2\} * 2, {:SE}', ['Hello'#13#10'World!']);
64+
65+wynik: {2 + 2} * 2, 'Hello\r\nWorld!'
66+```
67+
68+## Download
69+
70+- Wersja: 1 RC 1
71+- Źródło: <http://rapidshare.com/files/178670102/efmtf.zip>
72+
73+## Licencja
74+
75+- LGPL 2 lub nowsza
76+
77+## Zmiany
78+
79+- 2009-01-01 (1 RC 1): Wersja początkowa
80+
81+## Autor
82+
83+- Maciej Kaczkowski - maciejkaczkowski@gmail.com
84+
85+---
86+*From the Free Pascal wiki, page "Extended Format Function/pl", as it stood on 2020-02-14 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
87+Category: Old or unknown pages

Back to history