You've already forked lazarus-ccr
applications
bindings
components
Comba_Animation
aboutcomponent
acs
beepfp
callite
captcha
chelper
chemtext
cmdline
cmdlinecfg
colorpalette
cryptini
csvdocument
epiktimer
everettrandom
examplecomponent
exctrls
extrasyn
fpexif
fpsound
fpspreadsheet
fractions
freetypepascal
geckoport
gradcontrols
grid_semaphor
gridprinter
industrialstuff
iosdesigner
iphonelazext
jujiboutils
jvcllaz
kcontrols
lazautoupdate
lazbarcodes
lazmapviewer
lclextensions
longtimer
manualdock
mbColorLib
mplayer
multithreadprocs
nicechart
nicegrid
nicesidebar
nvidia-widgets
onguard
orpheus
playsoundpackage
poweredby
powerpdf
rgbgraphics
richmemo
richview
rtfview
rx
scrolltext
smnetgradient
spktoolbar
splashabout
svn
systools
tdi
thtmlport
tparadoxdataset
tvplanit
xdev_toolkit
CFHelpers.pas
CvtHelp.pas
HelpUtil.pas
PrefsUtil.pas
PropListUtil.pas
ReadMe.txt
RtfDoc.pas
TestRtfDoc.pas
ViewDoc.pas
ViewWith.pas
XDevStatus.html
create_app_mac.sh
dfmtolfm.ini
dfmtolfm.pas
filelist.txt
makepasx.pas
makever.pas
zlibar
zmsql
examples
image_sources
lclbindings
wst
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@366 8e941d3f-bd1b-0410-a28a-d453659cc2b4
73 lines
1.6 KiB
ObjectPascal
73 lines
1.6 KiB
ObjectPascal
program ViewWith;
|
|
|
|
{
|
|
Test program for ViewDoc unit.
|
|
}
|
|
|
|
{$IFDEF FPC}
|
|
{$MODE Delphi}
|
|
{$ELSE}
|
|
{$APPTYPE CONSOLE}
|
|
{$ENDIF}
|
|
{$R+,Q+}
|
|
|
|
uses
|
|
SysUtils,
|
|
ViewDoc;
|
|
|
|
var
|
|
VwrIdx : Integer;
|
|
Viewer : Integer;
|
|
Options : TViewerOptions;
|
|
InStr : string;
|
|
ErrorMsg : string;
|
|
Done : Boolean;
|
|
|
|
begin
|
|
|
|
if ParamCount < 2 then
|
|
begin
|
|
WriteLn('Usage: ViewWith viewername docfilename [-t] [-d]');
|
|
Exit;
|
|
end;
|
|
|
|
Viewer := 0;
|
|
for VwrIdx := 1 to GetViewerCount do
|
|
begin
|
|
if SameText(ParamStr(1), GetViewerName(VwrIdx)) then
|
|
Viewer := VwrIdx;
|
|
end;
|
|
if Viewer = 0 then
|
|
WriteLn('Specified viewer not supported - using first viewer found');
|
|
|
|
Options := [];
|
|
if FindCmdLineSwitch('t', ['-'], True) then {Treat file as template?}
|
|
Options := Options + [ovwUseAsTemplate];
|
|
|
|
if FindCmdLineSwitch('d', ['-'], True) then {Delete file before exiting?}
|
|
begin
|
|
Options := Options + [ovwAddToDeleteList];
|
|
Write('File will be deleted when done viewing - is this okay (Y/N)? ');
|
|
ReadLn(InStr);
|
|
if CompareText(InStr, 'y') <> 0 then
|
|
Exit;
|
|
end;
|
|
|
|
if not ViewDocument(ParamStr(2), Viewer, Options, ErrorMsg) then
|
|
begin
|
|
WriteLn(ErrorMsg);
|
|
Exit;
|
|
end;
|
|
|
|
if FindCmdLineSwitch('d', ['-'], True) and FileExists(ParamStr(2)) then
|
|
begin
|
|
repeat
|
|
Write('Press Enter when ready to delete file (or Ctrl+C to exit): ');
|
|
ReadLn(InStr);
|
|
Done := DeleteViewedDocs;
|
|
if not Done then
|
|
WriteLn(' Unable to delete file - may still be open in viewer');
|
|
until Done;
|
|
end;
|
|
end.
|
|
|