PrinterSwitch 2: External Functions

From myFMbutler wiki
Jump to: navigation, search

Main Page > PrinterSwitch 2 > External Functions

Contents

PrSw_Configure ( dataSelector )

Allows you to configure the plug-in using the following syntax:

PrSw_Configure ( "reset" )

This clears any filters that were installed by one or more calls with the ignore and/or only options.

PrSw_Configure ( "ignore|ignore_pattern1|ignore_pattern2" ):

Forces the PrinterSwitch plugin to ignore printer names with the selected pattern, e.g. if you don't want to see Laser printers in the list, you could have the pattern *aser*

(note that filters are case sensitive, so if you use the pattern *laser*, you will still see 'MyLaser' in the list)

Multiple patterns can be combined, separated by a piping character, e.g. *Laser*|*laser*

PrSw_Configure ( "only|only_pattern1|only_pattern2" ):

This is exactly the opposite of the 'ignore' value. It forces the PrinterSwitch plugin to only show printer names with the selected pattern. As can be seen in the 'Advanced selection' tab of our example file, it is possible to combine both 'ignore' and 'only' patterns in the same selection.

Note: if you use either the 'ignore' or 'only' selections, this may have an impact on the value that is returned by PrSw_GetPrinterNumber

PrSw_Configure ( "register|reg_name|reg_code|reg_userCount|reg_licenseType" ):

This function allows you to register PrinterSwitch with the several parts of the licensing information separated by a piping character. It will return the number of users if registration is fine, or otherwise will return ‘0’ if the registration information is invalid. The function PrSw_Configure ("save_reg" ) allows you to permanently save the current registration info to the PrinterSwitch preferences, as in the example below:

Let ([
reg_name =""; // Enter your registration name
reg_code = ""; // Enter your registration code
reg_userCount = "";// Enter the number of users for your license
reg_licenseType = "";// Enter your license type
register = PrSw_Configure ( "register|" & reg_name & "|" & reg_code & "|" & reg_userCount & "|" & reg_licenseType ); 
save = PrSw_Configure ( "save_reg" ) // Save permanently
]; register)

PrSw_GetCurrentPrinter

Returns the printer number of the currently selected printer.

If the result is "0", this means no printers have been defined.

Result "-1" implies that an error occurred.

PrSw_GetPrinterNames

Returns a list of the currently available printers.

This function returns "" (empty) if an error occurred, or if no printers are defined.


PrSw_GetPrinterNumber ( printerName )

Returns the current printer number of the requested printer.

Note: If you use filtering, this may have an impact on the value that is returned.

PrSw_GetPrinterNumber ( “HP LaserJet” )

PrSw_GetStartupPrinter

Returns the printer number of the printer that was selected at FileMaker startup

PrSw_PrintDialog( dialogModifier )

PrSw_PrintDialog ( “enable” ) PrSw_PrintDialog ( “disable” )

Windows

On Windows, used in conjunction with the PrSw_PrintSetup ( “restore” ) function, if you want to Print without showing a dialog.

The combination of three script steps below will have the same effect as the normal ‘Print [No Dialog]’ script step, but is required if you want to force FileMaker to accept changes made by the PrSw_PrintSetup ( “restore”[data]” ) function:

1° Call the function PrSw_PrintDialog ( “disable” )

2° Send the normal Print [] command (i.e. with dialog)

3° Call the function PrSw_PrintDialog ( “enable” )

Mac OS X

If you have a problem with the preview not refreshing correctly after performing a restore, we have implemented the PrSw_PrintDialog("disable") and PrSw_PrintDialog("enable") functions in the same way as they were available on Windows.

If you use the following sequence, the Preview should look fine:

Set Variable [dummy; PrSw_PrintDialog("disable")]
Print Setup[]
Set Variable [dummy; PrSw_PrintDialog("enable")]
Enter Preview Mode [Pause]

This procedure will "trick" FileMaker so that it thinks the page setup dialog has been shown, and thus it will pick up the changed setup.

This function returns a value of ‘0’.

Refer to the Print example script in our Capture-Restore example for more details on how to implement this.


PrSw_PrintDialog ( “macdialog” )

If you want to capture and restore on Mac, use this command to show the print setup dialog.

Set Field [printerswitch::MacPrintDialogResult_g[]; PrSw_PrintDialog( "macdialog" )]
Set Field [printerswitch::Capture_PrintSetup_g[]; PrSw_PrintSetup("capture")]

PrSw_PrintSetup( setupOperation )

Using the ‘Print Setup’ and ‘Print’ script steps, and specifying page setup and print options, can give unreliable results with both FileMaker Pro.

These functions allow you to save a specific printer setup, consisting of page orientation, paper size, paper source and even custom settings for a certain printer, and then later retrieve them at the time of printing.

PrSw_PrintSetup ( “capture” )

This function allows you to capture the page orientation, paper size and paper source for a certain printer. This information can then be stored as a variable or global for later retrieval. (please refer to the Define Printer Settings example script in our Capture/Restore example)

PrSw_PrintSetup ( “restore|data”)

This function will restore the page orientation, paper size and paper source that was previously captured. It will most likely be used in combination with the PrSwSelectPrinter function, in order to also select the printer for that particular setup. (please refer to the Print example script in our Capture/Restore example)

PrSw_PrintSetup ( “reset”)

This function will undo any printer selection that was made using PrinterSwitch functions.

This function will typically be used in the close script of a file.

It will also allow manual printing to be combined with scripted printing through PrinterSwitch.

PrSw_PrintSetup ( “setup_allow_user_override”)

Does allow the user to make changes in either the Page Setup or Print dialog after a PrSw_PrintSetup ("restore|…)

We chose to now make this the default setting.

Based on user feedback, we found quite a number of people wanted users to be able to make changes after a PrSw_PrintSetup ("restore|…") had been selected. You can optionally call after using the PrSw_PrintSetup ("restore|…") to determine whether a user can override the restored setup or not.

PrSw_PrintSetup("setup_block_user_override")

Will ignore any possible changes a user will make as long as the restore is active, i.e. as long as you haven't called PrSw_PrintSetup("reset").


PrSw_SelectPrinter ( selectionParameter)

Allows you to select a printer by printer name or printer number:

PrSw_SelectPrinter ( PrinterName )

Selects a printer by printer name

PrSw_SelectPrinter ( PrinterNumber )

Selects a printer by printer number

PrSw_SelectPrinter ( PrinterName/Number|filemac:[Mac path]|filewin:[Win path] )

Allows you to select a printer by printer number and add a Mac and/or Windows file path, separated by a pipe character, to create a PDF of the current FileMaker output.

  • Result "0" means selection is OK
  • Result "-1" means PrinterSwitch encountered an error.

PrSw_SetPrintCopies ( numCopies )

This sets the number of copies you want to print. The default value is 1.

Note: This function is only available on Windows. See: More about Windows Print Options

PrSw_SetPrintCollate ( collate )

Boolean. The default value is 0.

Note: This function is only available on Windows. See: More about Windows Print Options

PrSw_SetPrintRange ( from ; to)

Allows you to select the page range.

The default value is ‘All’ or PrSw_SetPrintRange ( 0 ; 0 )

Note: This function is only available on Windows. See: More about Windows Print Options

PrSw_SetPrintToFile ( printToFile )

Boolean. The default value is 0.

Note: This function is only available on Windows. See: More about Windows Print Options

PrSw_Version ( dataSelector )

Returns PrinterSwitch license Info:

dataSelector

  • "": returns the plug-in name
  • "0": returns the four digits of the version number
  • "1" to "4": return 4 separate digits of the version number
  • "5": returns the license type "Demo", "Regular", "Developer", "Site License"
  • "6": returns the user license count - "1", "5", "10", "25", "50", "Unlimited"
  • "7": returns the registrar name
  • "8": returns the activation code of the plug-in

PrSw_VersionAutoUpdate

Provides plug-in information for FileMaker Server's AutoUpdate function. Returns 8 digit number to represent an AutoUpdate version.

e.g. for version 1.7.3 the value ‘01070300’ will be returned

Personal tools