# Youseful Software - FileMaker sample script
# Script name: Youseful - Ask for a name
# Plug-in: YsflDialog.fmx64 (Windows x64)
# Setup: Run in interactive FileMaker Pro on Windows. No fields needed.
# Expected: Enter Alex and choose Save: Hello, Alex. Choose Cancel: the script exits without a welcome dialog.
# 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 [ $reply ; Value: YsflDl_Input (
    "Your name" ; "Enter a display name for this example." ;
    "Name|text|" ; "Save¶Cancel" ; "cancel=2 focus=1"
) ]
Set Variable [ $error ; Value: YsflDl_LastError ]
If [ $error <> 0 ]
    Show Custom Dialog [ "Dialog failed" ; YsflDl_LastErrorText ]
    Exit Script [ Text Result: $reply ]
End If
Set Variable [ $button ; Value: GetAsNumber ( GetValue ( $reply ; 1 ) ) ]
If [ $button <> 1 ]
    Exit Script [ Text Result: "Cancelled" ]
End If
Set Variable [ $name ; Value: Trim ( GetValue ( $reply ; 2 ) ) ]
If [ IsEmpty ( $name ) ]
    Show Custom Dialog [ "Name needed" ; "Run the example again and enter a name." ]
    Exit Script [ Text Result: "No name" ]
End If
Show Custom Dialog [ "Welcome" ; "Hello, " & $name ]
