set allprinters to every printer
set printernames to name of every printer
end tell
set backvalue to ""
repeat with printername in printernames
set backvalue to backvalue & printername & (ASCII Character(13))
end repeat
set cell "PrinterList_Global" of current record to backvalue
---
This can be used to set the default printer on OSX.
2)
The second option uses the lpstat OSX command to get the printer names. This will give you a different list. But the printer names this one gives can be used for the "lp" OSX command. This will be important later when we get to fax sending.
---
set oldDelims to AppleScript's text item delimiters
set PrinterStatusList to {}
try
set cmd to "lpstat -p | grep ^printer"
set PrinterStatus to do shell script cmd as text
set AppleScript's text item delimiters to {" "}
repeat with i from 1 to count of paragraphs of PrinterStatus
set s to paragraph i of PrinterStatus
set p to text item 2 of s as list
copy p to end of PrinterStatusList
end repeat
on error
set PrinterStatus to ""
end try
set AppleScript's text item delimiters to oldDelims
set backvalue to ""
repeat with printername in PrinterStatusList
set backvalue to backvalue & printername & (ASCII Character(13))
end repeat
set cell "PrinterList_Global" of current record to backvalue
--
Okay, now you have the printer list. You can easily create a value list based on this, and let the user choose from it.
What about faxing??
This is where the lp command comes in.
With lp you can send a file (pdf), to a number.
The syntax is the following:
lp -d PrinterNameHere -o phone=PhoneNumberHere filepathandnameHere
You can call this from FileMaker using a do shell script AppleScript Command.
I attached a sample file for printer listing, the faxing is up to you, but based on this, you can easily create it.
You can download the demo file here. (right click - save as).
Thanks for this wonderful tutorial!
ReplyDeleteIn my case, I don't want to have the field on my layout. Is there a way to capture the text as some kind of script result and then set the field with another script?
Hi!
ReplyDeleteNo, you have to write in a field, no script result.
If you don't want it to appear on the layout, you can change
set cell "PrinterList_Global" of current record to backvalue
to
set field "PrinterList_Global" of table "Table Occurrence" to backvalue
Then use the other script to work with this.
If you need further information or help, feel free to drop me a line!
Regards
Adam
nice post very well written. i appreciate quality of writing u haveMarkham Developer
ReplyDeletenice post very well written. i appreciate quality of writing u havefrases
ReplyDeleteNice stuff you got, very interesting to read.
ReplyDeleteWell, I do have also in my sleeves, if you have time don't forget to visit
Houston Electricians