litceysel.ru
добавить свой файл
  1 ... 14 15 16 17 18 19

Полуфабрикаты макросов для Recorder’а

Sub МакросНажатьFile()

'

' МакросНажатьFile Макрос

' Макрос записан 16.05.02 Vladimir I. Gromyko

'

Documents.Open FileName:="01.doc", ConfirmConversions:=False, ReadOnly:= _

False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _

"", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _

Format:=wdOpenFormatAuto

End Sub

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Sub Макрос1()

'

' Макрос1 Изучаем символы

' Макрос записан 03.04.2003 Grom

'

w = Asc("a")

MsgBox w

w = Chr(32)

MsgBox w

'MsgBox (Debug.Print AscB(MidB("1.2.Ответить", 1, 10)))

'Debug.Print AscB(MidB("1.2.Ответить", 1, 10));

End Sub

Инструментарий для печати


unit Unit2on1;


interface


uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, FileCtrl, Spin;


type

TForm2on1 = class(TForm)

Button: TButton;

GroupBox1: TGroupBox;

InDrive: TDriveComboBox;

InDir: TDirectoryListBox;

GroupBox2: TGroupBox;

OutDrive: TDriveComboBox;

OutDir: TDirectoryListBox;

GroupBox3: TGroupBox;

GroupBox4: TGroupBox;

Label1: TLabel;

EMirrCheckBox: TCheckBox;

Label2: TLabel;

Label3: TLabel;

ETX: TSpinEdit;

ETY: TSpinEdit;

GroupBox5: TGroupBox;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

OMirrCheckBox: TCheckBox;

OTX: TSpinEdit;

OTY: TSpinEdit;

procedure ButtonClick(Sender: TObject);

end;


var

Form2on1: TForm2on1;

buf:array[0..59999]of byte;

bufmax,bufcurr,finsize:integer;

eoffin:boolean;


implementation


{$R *.DFM}


procedure ureadln(var f:file;var s:string);

label l;

begin

s:='';

l:while(bufcurr10)do

begin

if(buf[bufcurr]<>13)then s:=s+chr(buf[bufcurr]);

inc(bufcurr)

end;

if(bufcurr
begin

if finsize>=60000 then bufmax:=60000 else bufmax:=finsize;

finsize:=finsize-bufmax;

blockread(f,buf,bufmax);

bufcurr:=0;

goto l

end

end;


procedure TForm2on1.ButtonClick(Sender: TObject);

var searchrec:tsearchrec;

fin:file;

fout:textfile;

emirrs,omirrs,odir,idir,p1z,p2z,p1x,p2x,s1,s2:string;

i,currpage,npages:integer;

begin

if emirrcheckbox.checked then emirrs:=' -1 1 scale'else emirrs:='';

if omirrcheckbox.checked then omirrs:=' -1 1 scale'else omirrs:='';

p1z:=inttostr(ETY.value);

p2z:=inttostr(OTY.value);

p1x:=inttostr(ETX.value);

p2x:=inttostr(OTX.value);

omirrs:=emirrs;

if length(indir.directory)=3 then idir:=indir.directory[1]+indir.directory[2] else idir:=indir.directory;

if length(outdir.directory)=3 then odir:=outdir.directory[1]+outdir.directory[2] else odir:=outdir.directory;

if findfirst(idir+'\*.ps',faanyfile,searchrec)=0 then

repeat

form2on1.caption:=searchrec.name;

if fileexists(odir+'\'+searchrec.name) then

begin

MessageDlg('File '+odir+'\'+searchrec.name+' is already exists!',mtError,[mbOk],0);


exit

end;

assignfile(fout,odir+'\'+searchrec.name);

rewrite(fout);

assignfile(fin,idir+'\'+searchrec.name);

reset(fin,1);

eoffin:=false;

bufcurr:=60000;

bufmax:=60000;

finsize:=filesize(fin);

{ repeat ureadln(fin,s1)

until(length(s1)>10)and(s1[1]='%')and(s1[2]='%')and(s1[3]='P')and(s1[4]='a')and(s1[5]='g')and(s1[6]='e')and(s1[7]=':')and(s1[8]=' ')and(s1[length(s1)]='1')and(s1[length(s1)-1]=' ');

i:=9;

s2:='';

while s1[i]in['0'..'9']do

begin

s2:=s2+s1[i];

inc(i)

end;

}

bufcurr:=60000;

bufmax:=60000;

finsize:=filesize(fin);

ureadln(fin,s1);

while pos('%%Pages:',s1)=0 do

begin

writeln(fout,s1);

ureadln(fin,s1)

end;

s2:='';

for i:=10 to length(s1) do s2:=s2+s1[i];

i:=strtoint(s2);

npages:=i;

s1:='%%Pages: '+inttostr(i div 2+i mod 2);

while pos('/bop',s1)=0 do

begin

writeln(fout,s1);

ureadln(fin,s1)

end;

s2:='';

for i:=1 to pos('/bop',s1)+3 do s2:=s2+s1[i];

i:=pos('/bop',s1)+4;

while(s1[i]<>'{')do

begin

s2:=s2+s1[i];

inc(i)

end;

if npages mod 2=1 then s2:=s2+'{dup dup '+inttostr(npages-1)+' eq {2}{2 mod}ifelse /currpage 2 1 roll def 'else s2:=s2+'{dup 2 mod /currpage 2 1 roll def ';

if pos('save',s1)=0 then

begin

for i:=i+1 to length(s1)do s2:=s2+s1[i];

i:=1;

writeln(fout,s2);

s2:='';

ureadln(fin,s1)

end else inc(i);

for i:=i to pos('save',s1)+3 do s2:=s2+s1[i];


s2:=s2+' currpage 1 eq {'+p1x+' '+p1z+' translate 270 rotate'+emirrs+'}{'+p2x+' '+p2z+' translate 270 rotate'+omirrs+'}ifelse';

for i:=pos('save',s1)+4 to length(s1)do s2:=s2+s1[i];

s1:=s2;

while pos('showpage',s1)=0 do

begin

writeln(fout,s1);

ureadln(fin,s1)

end;

s2:='';

for i:=1 to pos('showpage',s1)-1 do s2:=s2+s1[i];

s2:=s2+'currpage 0 gt {showpage}if';

for i:=pos('showpage',s1)+8 to length(s1) do s2:=s2+s1[i];

s1:=s2;

currpage:=1;

while not eoffin do

begin

while not eoffin and(pos('%%Page:',s1)<>1) do

begin

writeln(fout,s1);

ureadln(fin,s1)

end;

if eoffin then writeln(fout,s1)else

begin

i:=length(s1);

s2:='';

while s1[i] in['0'..'9'] do

begin

s2:=s1[i]+s2;

dec(i)

end;

if strtoint(s2)=currpage then

begin

if currpage mod 2=1 then

begin

s2:='';

for i:=1 to i do s2:=s2+s1[i];

writeln(fout,s2+inttostr(currpage div 2+1))

end;

form2on1.caption:=searchrec.name+' - page '+inttostr(currpage);

inc(currpage)

end

else writeln(fout,s1);

ureadln(fin,s1)

end

end;

closefile(fin);

closefile(fout)

until findnext(searchrec)<>0;

form2on1.caption:='OK'

end;


end.



<< предыдущая страница   следующая страница >>