--- In [email protected], "ariegilbert" <[EMAIL PROTECTED]> wrote:
>
> I want to only print the output files, but am being interrupted
> by many inquires regarding program files that change during
> routine use; can I limit it to "a*.txt" somehow, and have it
> ignore the other files? how can I have it set the printer once,
> or better yet simply have it choose the default printer and then
> not ask again each time; but allow me to change it if/when i want
> to send output to another printer
Previous version assumed you had a special directory for output files.
I changed it a bit below, will now respond only to txt files that
start with an "a". Also, now the print dialog includes info on which
printer is in effect and allows it to be changed. If you opt to change
printers but press escape instead of selecting a printer, it is the
same as canceling.
> how does one quit / pause the script?
To run the script you can doubleclick the script file in Explorer, or
run it from a PowerPro bar or menu using the command:
.watchandprint or [EMAIL PROTECTED]
assuming its been saved as watchandprint.powerpro
Rerun it to quit watching. It is "paused" while the print dialog or
printer menu listing is displayed.
>
> also, where is the documentation for watchfolder?
In the PowerPro docs under File Plugin.
> You are the priestess! Thank you
You're welcome, glad I could help! Feel free to experiment and further
tweak it.
Regards,
Sheri
Function StartWatch()
if (anywindow(Scriptname)) do
messagebox("OK", "Please close currently open " ;;+
++ScriptName++ " dialogs.", ScriptName)
quit
endif
static hwf
static wf
if (hwf !=="") do
local ans=messagebox("YesNo Question", ;;+
"Currently Watching:\n"++wf++"\n\nQuit watching?", ;;+
case("Title", ScriptName))
if (ans==6) do
file.endwatchfolder(hwf)
hwf=""
quit
endif
else
messagebox("OK", "Select a folder to watch", ;;+
case("Title",Scriptname))
if (wf=="")
wf=env("userprofile")++?"\My Documents"
wf=inputfolder(wf)
if (wf=="")
quit
watchit()
endif
quit
Function Watchit(bypassmsg)
static wf
static hwf=file.watchfolder(wf, cbx("@printit"), "", ;;+
"file lastwrite size")
if (bypassmsg !==1)
messagebox("OK", "Now Watching "++wf++".", ;;+
case("Title", ScriptName))
quit
Function Printit()
static hwf=""
local regex_status
local chgfolder=_folder_
local chgfile=_file_
regex.pcrematch(?"^a.*\.txt$", chgfile)
if (file.validpath(chgfolder++?"\"++chgfile) ;;+
and regex_status=="Match") do
local pq=messagebox("YesNoCancel Question", ;;+
"Do you want to print "++chgfile++" to " ;;+
++defaultprinter++" now?\n\nYes=Print Now, " ;;+
++"No=Select Printer then Print, Cancel=Do Not Print", ;;+
case("Title",Scriptname))
if (pq==6) do
file.doverb(chgfolder++?"\"++chgfile, "Print", 1)
elseIf (pq==7) do
local x=SetDefaultPrinter()
if (x>-1)
file.doverb(chgfolder++?"\"++chgfile, "Print", 1)
endif
Watchit()
else
Watchit(1)
endif
quit
Function SetDefaultPrinter()
local printers=win.getprinters()
local printerv=vec.createfromlines(printers)
local choice=printerv.showmenu()
if (choice>-1) do
local choice=printerv[choice]
win.setdefaultprinter(choice)
endif
quit(choice)