-
Notifications
You must be signed in to change notification settings - Fork 4
/
ubasic.pas
120 lines (110 loc) · 2.54 KB
/
ubasic.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
unit ubasic;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,zint,uhelper;
function ZBarcode_Create(): PointerTo_zint_symbol;
procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
implementation
function ZBarcode_Create(): PointerTo_zint_symbol;
var
symbol: PointerTo_zint_symbol;
i: Integer;
begin
symbol := GetMem (SizeOf (zint_symbol));
if not Assigned(symbol) then
begin
exit (nil);
end;
FillByte(symbol^, SizeOf (zint_symbol),0);
symbol^.symbology := BARCODE_CODE128;
symbol^.height := 0;
symbol^.whitespace_width := 0;
symbol^.border_width := 0;
symbol^.output_options := 0;
symbol^.rows := 0;
symbol^.width := 0;
strcpy (symbol^.fgcolour, '000000');
strcpy (symbol^.bgcolour, 'ffffff');
strcpy (symbol^.outfile, '');
symbol^.scale := 1.0;
symbol^.option_1 := -1;
symbol^.option_2 := 0;
symbol^.option_3 := 928;
symbol^.show_hrt := 1;
symbol^.input_mode := DATA_MODE;
strcpy (symbol^.primary, '');
FillByte (symbol^.encoded_data[0][0], SizeOf (symbol^.encoded_data),0);
i := 0;
while i < 178 do
begin
symbol^.row_height[i] := 0;
Inc (i);
end;
symbol^.bitmap := nil;
symbol^.bitmap_width := 0;
symbol^.bitmap_height := 0;
exit (symbol);
end;
procedure ZBarcode_Clear(symbol: PointerTo_zint_symbol);
var
j: Integer;
i: Integer;
begin
i := 0;
while i < symbol^.rows do
begin
j := 0;
while j < symbol^.width do
begin
unset_module (symbol, i, j);
Inc (j);
end;
Inc (i);
end;
symbol^.rows := 0;
symbol^.width := 0;
symbol^.text[0] := 0;
symbol^.errtxt[0] := #0;
if Assigned(symbol^.bitmap) then
begin
FreeMem (symbol^.bitmap);
end;
symbol^.bitmap := nil;
symbol^.bitmap_width := 0;
symbol^.bitmap_height := 0;
end;
procedure ZBarcode_Delete(symbol: PointerTo_zint_symbol);
var
l: PointerTo_zint_render_line;
line: PointerTo_zint_render_line;
s: PointerTo_zint_render_string;
TheString: PointerTo_zint_render_string;
begin
if Boolean(symbol^.bitmap <> nil) then
begin
FreeMem (symbol^.bitmap);
end;
if Boolean(symbol^.rendered <> nil) then
begin
line := symbol^.rendered^.lines;
while Assigned(line) do
begin
l := line;
line := line^.next;
FreeMem (l);
end;
TheString := symbol^.rendered^.strings;
while Assigned(TheString) do
begin
s := TheString;
TheString := TheString^.next;
FreeMem (s^.text);
FreeMem (s);
end;
FreeMem (symbol^.rendered);
end;
FreeMem (symbol);
end;
end.