home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1999 Spring / macformat-077.iso / Shareware Plus / Development / Akua Sweets 131 / Akua Sweets Examples / Printing / Use Printer < prev   
Encoding:
Text File  |  1999-03-04  |  1.6 KB  |  60 lines  |  [TEXT/ToyS]

  1. (*
  2. V1.1 - Akua Sweets V1.31
  3. Run to store the current printer.
  4. Run again to set the printer to the stored printer.
  5. Hold the option key when running to store the current printer
  6.  over the previously stored printer.
  7. *)
  8.  
  9. property kasConfig : ""
  10.  
  11.  
  12. on run
  13.     if ((kasConfig is "") or (option key down of (input state))) then
  14.         set kasConfig to printer configuration
  15.         set newName to ("Use " & PrinterName(kasConfig))
  16.         if (length of newName > 31) then set newName to (the text 1 thru 30 of newName) & "…"
  17.         collate (path to me) renaming it to newName
  18.         set the icon of (path to me) to PrinterIcon(kasConfig)
  19.         display dialog "The printer will be set to \"" & ¬
  20.             PrinterName(kasConfig) & ¬
  21.             "\" when this script is run." buttons {"OK"} default button 1
  22.     else if (kasConfig is not "") then
  23.         set infW to (display drawing titled "Printer Switch" with dimensions {96, 86})
  24.         
  25.         -- Not good practice -- drawing into an info window :)
  26.         draw a picture into infW ¬
  27.             using data (PrinterIcon(kasConfig) as picture) ¬
  28.             inside of {16, 4, 80, 68}
  29.         
  30.         draw a string into infW ¬
  31.             using data PrinterName(kasConfig) ¬
  32.             offset by {48, 83} ¬
  33.             using state {text size:14}
  34.         
  35.         printer configuration kasConfig
  36.         
  37.         display info infW with disposal
  38.     else
  39.         beep
  40.     end if
  41. end run
  42.  
  43.  
  44. on PrinterName(prCfg)
  45.     set choice to desktop printer name of prCfg
  46.     if (choice is "") then set choice to (LAN printer name of prCfg)
  47.     if (choice is "") then set choice to print driver name of prCfg
  48.     return choice
  49. end PrinterName
  50.  
  51.  
  52. on PrinterIcon(pc)
  53.     try
  54.         set ic to desktop icon of pc
  55.     on error
  56.         set ic to the icon for (print driver alias of pc)
  57.     end try
  58.     return ic
  59. end PrinterIcon
  60.