// A script for copying the PDF output from one place to another. // By PJ Healy, without credit to all that I stole from. // Put your Windows path to your destination folder (eg, webserver folder) here: LetReg(0,"H:\public_html\papers"); // If "WebPDFName: XXX.pdf appears in the first line of the file (in a comment) // then that XXX.pdf will be the name of the destination file. Otherwise, the // macro will use this (where %N is the file name of the current open file): LetReg(5,"Healy-%N.pdf"); // See if "WebPDFName: XXX.pdf" is in the first line. If so, use that filename. GetLine(1,1); FindInString("%!1", "WebPDFName: *\.pdf",2,3,1); LetRegNum(2, %!2 + 12); IfNum("%!2","%!3","<",!"ExtractByIndex(4,`%!1`,%!2,%!3); LetReg(5,`%!4`)"); PushTagsandRegisters; // Set up the MUI interface here MUIReset('Copy output file to...'); MUIAdd(0,0,660,140,'Copy output file...','TPanel'); MUISet('','left','150'); MUISet('','top','300'); MUISet('','width','660'); MUISet('','height','140'); MUIAdd(3,3,45,0,'FromLabel','TButton','Copy output file...','From:'); MUISet('FromLabel','on click',!"Call('BrowseFromPath');"); MUISet('FromLabel','default', '0'); MUIAdd(50,5,590,0,'FromPath','TEdit','Copy output file...'); MUISet('FromPath','caption','%P\%N.pdf'); MUISet('FromPath','auto select','1'); MUIAdd(3,33,45,0,'ToLabel','TButton','Copy output file...','To:'); MUISet('ToLabel','on click',!"Call('BrowseToPath');"); MUISet('ToLabel','default', '0'); MUIAdd(50,35,590,0,'ToPath','TEdit','Copy output file...'); MUISet('ToPath','caption','%!0\%!5'); MUISet('ToPath','auto select','1'); MUIAdd(35,65,130,40,'OverwriteGroup','TGroupBox','Copy output file...','Overwrite File if Exists?'); MUIAdd(15,15,40,20,'OverwriteYes','TRadioButton','OverwriteGroup','&Yes'); MUISet('OverwriteYes','checked','1'); MUIAdd(75,15,40,20,'OverwriteNo','TRadioButton','OverwriteGroup','&No'); MUIAdd(180,75,100,0,'CopyButton','TButton','Copy output file...','&Copy PDF to Web'); MUISet('CopyButton','on click',!"Call('DoIt')"); MUIAdd(300,75,100,0,'ViewButton','TButton','Copy output file...','Open &PDF'); MUISet('ViewButton','default', '1'); MUISet('ViewButton','on click',!"Call('OpenPDF')"); MUIAdd(420,75,100,0,'DVIButton','TButton','Copy output file...','Open &DVI'); MUISet('DVIButton','on click',!"Call('OpenDVI')"); MUIAdd(540,75,100,0,'CancelButton','TButton','Copy output file...','E&xit'); MUISet('CancelButton','on click',!'MUIHide(1)'); MUIShow; JMP('end_events'); :BrowseToPath:: ======================================================= Browse(7,"PDF Files|*.pdf|All Files|*.*",%!0); MUISet('ToPath','caption','%!7'); Return; :BrowseFromPath:: ===================================================== Browse(7,"PDF Files|*.pdf|All Files|*.*","%P"); MUISet('FromPath','caption','%!7'); Return; :DoIt:: ============================================================= MUIGet('FromPath','text',3); MUIGet('ToPath','text',4); MUIGet('OverwriteYes','checked',5); IfFileExists("%!3",'Relax;','Call("FileMissing")'); MUIGet('OverwriteYes','checked',6); IfGetNum('%!6',0,0,'Call("CheckOverwrite")','Relax;'); IfStr("%!9","exists","=","Relax;","CopyFile('%!3','%!4',%!5,1);IfFileExists('%!4','Prompt(`File copied successfully!`);','Prompt(`FAILURE: File was not copied.`);');") LetReg(9,""); // MUIHide(1); Return; :OpenPDF:: ========================================================= // MUIGet('FromPath','text',3); // Exe('%b\Exec\Acrobat OpenDoc.edt'); IfFileExists("%P\%N.pdf","Exe('%b\Exec\PDF\PDF Preview.edt');","Prompt('Cannot find %P\%N.pdf.');"); MUIHide(1); Return; :OpenDVI:: ========================================================= // MUIGet('FromPath','text',3); // Exe('%b\Exec\Acrobat OpenDoc.edt'); IfFileExists("%P\%N.dvi",> !`IfStr("%$('TeXify-Viewer');","1","=",> !``> IfStr("%$('TeXify-View_Search');","1","=",> !*Run(|%$('DVIView'); -1 -s "%!l %p\%n%t" "%P\%N.dvi"|,'%P');*,> !*Run(|%$('DVIView'); -1 "%P\%N.dvi"|,'%P');*);> ``);`,> // Something is wrong with your TeX system or your document> // Nothing WinEdt can do for you at this stage...> !`Prompt("There is no dvi file to open.");> IfFileExists("%b\_Run.log",> !*CloseFile("%b\_Run.log",1);> Open("%b\_Run.log",1,1,-1);GotoCL(1,1);TrackCaret;*);`); MUIHide(1); Return; :FileMissing:: ====================================================== Prompt('%!3 cannot be found. Action failed.'); Return; :CheckOverwrite:: ================================================== IfFileExists('%!4','Call("CantOverwrite")','Relax;'); Return; :CantOverwrite:: ====================================================== Prompt('%!4 exists and will not be overwritten. Copy failed.'); LetReg(9,"exists"); Return; :end_events:: ========================================================= PopTagsandRegisters; End;