# Youseful Software - FileMaker sample script
# Script name: Youseful - Make a QR code
# Plug-in: YsflBarcode.fmx64 (Windows x64)
# Setup: In a practice file, create a Demo table occurrence with QR (Container). Put Demo::QR on a layout and create one record. Run on that layout with an editable record; this script replaces Demo::QR.
# Expected: The QR container displays a PNG that decodes to Youseful Software demo.
# 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 [ $payload ; Value: "Youseful Software demo" ]
Set Variable [ $validation ; Value: YsflBc_Validate ( "QR" ; $payload ; "ecc=M scale=4" ) ]
If [ not IsEmpty ( $validation ) ]
    Show Custom Dialog [ "Invalid barcode data" ; $validation ]
    Exit Script [ Text Result: $validation ]
End If
Set Variable [ $image ; Value: YsflBc_Generate ( "QR" ; $payload ; "ecc=M scale=4 name=youseful-qr.png" ) ]
Set Variable [ $error ; Value: YsflBc_LastError ]
If [ $error <> 0 ]
    Show Custom Dialog [ "Generation failed" ; YsflBc_LastErrorText ]
    Exit Script [ Text Result: "Generation failed" ]
End If
Set Field [ Demo::QR ; $image ]
