uncertainty - some time worked and some time not

Duncan's Avatar


21 Jan, 2020 06:46 PM

We have experienced FileMaker(v.18) crashes related to PrinterSwitch and are trying to get to the bottom of it.

Two points the FileMaker crashed:
1. When we execute:
     PrSw_PrintSetup("restore|" & $settings...)
2. When we execute the sequence:
     Set Field [printerswitch::PrinterSwitch_Config_g; PrSw_PrintDialog("disable")
     Print [With dialog:on]
     Set Field [printerswitch::PrinterSwitch_Config_g; PrSw_PrintDialog("enable")

At this point, we are focusing on issue #1 above.
The observation is that #1 crashes because the $settings is wrong.
With same code, we noticed that we got different readings ($settings) when
configuring the printer.
** Q: Is this by design? or if this indicates something is wrong?

Attached, please find our code that read the settings - we try to keep it as
close to the PrinterSwitch sample code as possible, even though we think
some of the code are unnecessary.

Please check and verify if the attached code should work? If not, please
suggest any modification we need to made.

The #2 issue, at this point, we only know that sometimes it happens - not
very frequent and not always reproducible.

Few words about the attached code:
$CastType is just a basic description like 'duplex' - not really used here.
$Host, $HostName - we use network card NIC number($Host) to map to $HostName
We save printer settings in the settings table that is a extension of PrinterSwitch's
settings table - we use $HostName, and PrintCastId to identify unique settings.


  1. 1 Posted by Duncan on 21 Jan, 2020 06:53 PM

    Duncan's Avatar

    Q: I can't see the attachment, I re-upload it here.

  2. Support Staff 2 Posted by Support on 27 Jan, 2020 10:27 AM

    Support's Avatar

    Hi Duncan,

    Thank you for contacting us. I'll do my bes to answer your questions.

    1. The $settings variable contains the settings for a certain printer driver. If capture the settings on 1 computer and try to restore it on a different computer that a different OS or a different version of the printer driver, the printer driver will receive invalid print instructions. This can make PrinterSwitch crash.
      But it seems you're application has a print setup for each computer, right? If so you might to have to run the capture function again an update of printer driver or a Windows update.

    2. We haven't seen this behaviour yet. I certain situations we have seen that a PDF document wasn't created when using this the PrSw_PrintDialog("disable") function. I that case we were able to resolve it by removing PrSw_PrintDialog("disable/enable") function and set Print [With dialog:] to off.
      Maybe this also helps in your situation. Could you try the following code?

    Change this:
    Set Field [printerswitch::PrinterSwitch_Config_g; PrSw_PrintDialog("disable") Print [With dialog:on] Set Field [printerswitch::PrinterSwitch_Config_g; PrSw_PrintDialog("enable")

    Print [With dialog:off]

    Could you also let me know which OS version you're using?

    Kind regards,

  3. 3 Posted by Duncan on 28 Jan, 2020 04:08 PM

    Duncan's Avatar


    Thank for the reply - my email haven't been working for two weeks now.

    For #2, I will certainly try that - on my developing system, there are many times
      the FileMaker crashed on that and I notice that if I commented out
      PrSw_PrintDialog("disable/enable") but leave the Print[With dialog:on], the
      FileMaker will work fine - I haven't try with dialog:off, but I certainly will - this
      happens on both Windows 10 and Windows 7 with HP602 printer/driver.

    For #1, yes, we do have setting for each computer. The event usually reproachable
      except that it is not always end up crash the FileMaker - sometimes it is like can't
      set/read the right settings - this happens to both Windows 7 and Windows 10.

      Let me provide a bit more details about what I have done/learned:
        1. On the same computer with our program, I could have
             one setting worked just fine - configure and save the settings, then
             restore the setting and check. At the same time, the other setting
             just won't work - I configure and save the settings but when restore and
             check, it either crash or not set the printer to the right configuration.

        2. So far, I think, I can always fix the problem by running PrinterSwitch's sample
             code from the same computer and 'copy and paste' the settings into our
             settings table - the restore and check would then worked correctly. But, of
             cause, if I use our program to configure and save the settings, it won't work
             again. This is why I attached our program - I suspect I might have missed
             some steps even though I try to mimic the PrinterSwitch's sample very closely.

             Can you check the code I attached in my previous post and provide us some

    Thanks. Duncan

  4. 4 Posted by Duncan on 28 Jan, 2020 04:13 PM

    Duncan's Avatar

    Sorry. For #1, I mean The event usually 'reproducible'.

  5. 5 Posted by duncan hsu on 12 Feb, 2020 05:43 PM

    duncan hsu's Avatar

    OK. Just an update of my most recent findings - just facts, not really helping.

    Recently, I found the first case that the value captured with the sample code does not work while, at the same time, the setting captured by my program actually worked.

    The printer involved is a Lanier 4502, which is a quite sophisticate device. I don't have record on the exact setting that I try to set. But it is something like that I try to set to use color and use paper tray 1 and it keep give me black and white and tray 5 - my program has a check button that will restore the captured value and show the printer setting dialog. I copy the value captured by the sample code into my program and use the check button to see the setting.

    What is interesting is that at the same time the sample code failed on that particular one, other setting captured by the sample code actually worked well for our application. I end up using some of my value and some from the sample code.

  6. Support Staff 6 Posted by Support on 13 Feb, 2020 09:43 AM

    Support's Avatar

    Hi Duncan,

    Thank you for your feedback. I'm not sure why you get different values than the sample file and why sometimes your captured restore string works and sometimes the one from the sample app.
    What we have seen in the past is that some printers don't play very nice with PrinterSwitch, so that might be the case if it only happens with this printer and no other printers.

    Kind regards,

  7. 7 Posted by duncan hsu on 13 Feb, 2020 02:52 PM

    duncan hsu's Avatar

    Hi Jasper,

    Thanks for the reply.

    First of all, the problem of inconsistency do happen to two printer as I know of. The other is a HP602.

    All I can say at this point is that I am not sure what is really the problem. I try my best to try to get things to work. So far, one way or the other, we were able to get things going. I am continue trying to identify the cause and any help from PrinterSwitch would definitely help. By the way, I wonder if you got a chance to forward my attached code to one of your engineer to see if what we did things correctly?


Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:


Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac