# Youseful Software - FileMaker sample script
# Script name: Youseful - Printer settings
# Plug-in: YsflPrint.fmx64 (Windows x64)
# Setup: Install a Windows printer and set it as the default. This temporarily changes its orientation and restores it. Let the script finish through Restore.
# Expected: A compatible driver reports landscape and the original settings are restored. No page is printed.
# Format: UTF-8 Script Workspace step listing. Add the steps manually; this is not an importable FileMaker file.
# Lines beginning with # are notes; optionally add them as Comment steps.
# Preserve calculation quotes, backslashes, and paragraph symbols exactly.

Set Variable [ $saved ; Value: YsflPr_Save ]
If [ Left ( $saved ; 1 ) = "?" ]
    Show Custom Dialog [ "Cannot save settings" ; $saved ]
    Exit Script [ Text Result: $saved ]
End If
Set Variable [ $prepared ; Value: YsflPr_Prepare ( "" ; "orientation=landscape" ) ]
Set Variable [ $prepareError ; Value: YsflPr_LastError ]
Set Variable [ $prepareMessage ; Value: YsflPr_LastErrorText ]
If [ $prepareError = 0 ]
    Set Variable [ $orientation ; Value: YsflPr_GetSetting ( "" ; "orientation" ) ]
    Set Variable [ $readError ; Value: YsflPr_LastError ]
End If
Set Variable [ $restored ; Value: YsflPr_Restore ( $saved ) ]
If [ Left ( $restored ; 1 ) = "?" ]
    Show Custom Dialog [ "Restore failed" ; $restored ]
Else If [ $prepareError <> 0 ]
    Show Custom Dialog [ "Prepare failed" ; $prepareMessage ]
Else If [ $readError <> 0 ]
    Show Custom Dialog [ "Could not read orientation" ; $orientation ]
Else
    Show Custom Dialog [ "Driver reported" ; $orientation & " (original settings restored)" ]
End If
