PrinterSwitch 2: How to Integrate the Basic example in 5 easy steps

From myFMbutler wiki
Jump to: navigation, search

Main Page > PrinterSwitch 2 > How to integrate?


Step 1 - Move the table from the Basic example file into your file

In the Basic example file, go to ‘Define database’ , and have a look at the fields: you get more info on each of the fields in the comments (toggle the ‘Options / Comments’ menu).

  • In your database, go to File->Import Records (from a file)
  • Under source, select ‘PrinterSwitch’ and change the target from ‘Current Table’ to ‘New Table’ (printerswitch) and import the records (most likely only one record). Normally, you should not get any import errors.


Step 2 - Link the ID fields

  • Create a ‘_k_ID’ field in the table you want to print from and link it to the ‘_k_ID_g’ in the ‘PrinterSwitch’ table. If you don't do this your layouts won't be able to make use of the imported tables.
  • Go to ‘Define Database’ and click the Relationships tab.
  • Link the ‘_k_ID_g’ in the ‘PrinterSwitch’ table to the ‘_k_ID’ field in your table, and select ‘x’ as the operator, i.e. all records in the left table are matched to all records in the right table, regardless of the values in the match fields.


Step 3 - Create a value list

*Make a value list called ‘printers’ (or ‘printer_list’ or something similar). Click ‘Use Values from Field’ and then the Specify button. Select the ‘PrinterNames’ field from the ‘PrinterSwitch’ table.

  • Go to the ‘Printerswitch’ layout, enter layout mode and right-click the ‘PrinterNameSelect’ field. Set Field/Control Setup to be a popup menu displaying values from the printer value list you just made displaying data from the ‘PrinterNames’ field.


Step 4 - Import scripts into your solution

  • If you look at the Scripts menu of the example file, you will see which scripts are required. Also import the example script into your file. You may get some errors as some of the referenced items won't exist but that's OK.
  • Go through the imported scripts and delete any steps that have missing elements you don't need. Some of them won't be necessary as they'll refer to the splash screens in the example file, for example.
  • Make sure these scripts make sense as they'll be pointing at layout names that may be different from the example file. Most important are the ‘Start’, ‘Stop’ and ‘Rebuild Printer List’ scripts. For these to work properly, make sure they point to the ‘PrinterSwitch’ layout (or another layout that is based on the ‘PrinterSwitch’ table).
  • You'll have to modify your startup script, if you have one, to include the ‘Start’ script as a subscript. You'll also have to similarly call the ‘Stop’ script when the database file is closed.


Step 5 - Ready to go!

You are now ready to use and adapt the PrinterSwitch scripts to your own needs:

  • If you want to use the printer list popup menu on a layout, make sure you have the fields ‘PrinterNameselect’ and ‘SelectPrinter_result’ (from the ‘Printerswitch’ table) on that layout. The ‘SelectPrinter_result’ is an unstored calculation that is required to trigger the printer change.
  • If you want to integrate printer switching in your scripts, you can start adapting the example script (see below for a description of the example scripts).

Once you have everything working, you can do all sorts of things. You could store printer choices based on user account, or based on NIC address, create sessions per user, etc. If you want to add filtering or PDF creation capabilities, just copy the necessary fields from the example files, and then import the relevant scripts.

Personal tools