home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 1997 April
/
Chip_1997-04_cd.bin
/
tema
/
602propc
/
disk12
/
data.12
/
WINTEXT
/
MAKRA
/
SOURCES
/
TISK.TXT
< prev
next >
Wrap
Text File
|
1996-12-17
|
4KB
|
172 lines
//***********************************************************************
//*
//* Nßzev makra: Tisk nesouvisl²ch oblastφ dokumentu
//* Autor: Software602 a.s.
//* Datum vytvo°enφ: 17.12.1996
//*
//* Nßzev souboru:
//* Nßzev programu:
//* Tisk:
//*
//* Popis: Tisk libovolnΘho rozsahu stran dokumentu
//* p°. pou₧itφ: 1-3,8,12-15,5,4
//*
//******************************************************************mt***
Program Tisk;
const
MAXLEN = 100;
MAXPAGES = 50;
CHAR_0 = 48;
CHAR_9 = 57;
CHAR_SPACE = 32;
ERR_BADCHAR = -1;
ERR_NOTPAGE = -2;
type
formStr = string[MAXLEN];
tPage = record
first,
last :short;
end;
var
formatS :formStr;
page :array[1..MAXPAGES] of tPage;
pgCount :integer;
infStr1, infStr2, infStr3 :string[100];
i :integer;
pgCn :integer;
chOddel, chPole :char;
function GetFormat(var s:formStr):boolean;
begin
s := "1";
if (GetTotPages > 1) then
s := s + "-" + int2str(GetTotPages);
GetFormat := Input_box_msg (
'Vlo₧te Φφsla/rozsah stran odd∞lenΘ Φßrkou:',
'P°iklad: 1,2,5-8,10', s, MAXLEN );
end;
function GetNumbers(s:formStr):short;
var
result, i :short;
tmp :string[MAXLEN];
err :short;
num :short;
OnlyLast :boolean;
begin
result := 0;
i := 1;
tmp := '';
err := 0;
OnlyLast := false;
StrTrim(s);
while (i <= StrLength(s)) and (err = 0) do begin
if((ord(s[i]) >= CHAR_0) and (ord(s[i]) <= CHAR_9)) then
(*** Φφslo : ***)
tmp := tmp + StrCopy(s, i, 1);
if(s[i] <> chOddel) and
((ord(s[i]) < CHAR_0) or (ord(s[i]) > CHAR_9)) and
(ord(s[i]) <> CHAR_SPACE) and (s[i] <> chPole) then
(*** neznßm² znak : ***)
err := ERR_BADCHAR
else if(s[i] = chOddel) or (i = StrLength(s)) then begin
(*** ukonΦovacφ znak nebo konec °et∞zce, p°elo₧ na Φφslo : ***)
num := Str2Int(tmp);
if (num > GetTotPages) or (num <= 0) then err := ERR_NOTPAGE
else begin
if not(OnlyLast) then begin
inc(result);
page[result].first := num;
end
else OnlyLast := false;
page[result].last := num;
tmp := '';
end;
end
else if (s[i] = chPole) then begin
(*** pole stran : ***)
num := Str2Int(tmp);
if (num > GetTotPages) or (num <= 0) then err := ERR_NOTPAGE
else begin
inc(result);
page[result].first := num;
end;
OnlyLast := true;
//inc(i);
tmp := '';
end;
inc(i);
end;
if(err <> 0) then GetNumbers := err else GetNumbers := result;
end;
begin
chOddel := ',';
chPole := '-';
formatS := '';
if (GetFormat(formatS)) then begin
pgCount := GetNumbers(formatS);
case (pgCount) of
ERR_BADCHAR:
Info_box('Chyba!', 'Chyba p°i Φtenφ dat!');
ERR_NOTPAGE:
Info_box('Chyba!', 'èpatnΘ Φφslo strany!');
else: if (pgCount > 0) then begin
i := 1;
pgCn := 0;
while (i <= pgCount) do begin
if(page[i].first = page[i].last)
then infStr2 := infStr2 + Int2Str(page[i].first)
else infStr2 := infStr2 + Int2Str(page[i].first) + '..'
+ Int2Str(page[i].last);
{ secteni stran : }
if (page[i].last >= page[i].first) then
inc(pgCn, (page[i].last - page[i].first) + 1)
else
inc(pgCn, (page[i].first - page[i].last) + 1);
if(i <> pgCount) then infStr2 := infStr2 + ', ';
i := i + 1;
end;
infStr1 := 'PoΦet stran: ' + Int2Str(pgCn);
infStr2 := 'JednotlivΘ strany: ' + infStr2;
infStr3 := infStr1 + #13#10 + infStr2 + #13#10#13#10 +
'Vytisknout?';
if(YesNo_box('PrintDoc', infStr3)) then begin
{ tisk : }
i := 1;
while (i <= pgCount) do begin
Print(false, 1, 0, page[i].first, page[i].last);
i := i + 1;
end;
end;
// Info_Box('PrintDoc', 'Konec makra PrintDoc.');
end;
end; { case }
end;
end.