# Youseful Software - FileMaker sample script
# Script name: Youseful - Browse FTPS
# Plug-in: YsflFtp.fmx64 (Windows x64)
# Setup: Replace ftp.example.com:21, YOUR_TEST_USER, and YOUR_TEST_PASSWORD with a test account supporting explicit FTPS. This lists the account directory and disconnects, including after a listing error. Obtain credentials through your application credential flow when adapting it.
# Expected: A remote filename list or Directory is empty. Errors depend on the server/account. No remote files are changed.
# 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 [ $server ; Value: "ftp.example.com:21" ]
Set Variable [ $user ; Value: "YOUR_TEST_USER" ]
Set Variable [ $password ; Value: "YOUR_TEST_PASSWORD" ]
Set Variable [ $session ; Value: YsflFt_Connect ( $server ; $user ; $password ; "tls=explicit timeout=15" ) ]
Set Variable [ $connectError ; Value: YsflFt_LastError ]
If [ $connectError <> 0 ]
    Show Custom Dialog [ "FTPS connection failed" ; YsflFt_LastErrorText ]
    Exit Script [ Text Result: $session ]
End If
Set Variable [ $names ; Value: YsflFt_List ( $session ; "" ; "names" ) ]
Set Variable [ $listError ; Value: YsflFt_LastError ]
Set Variable [ $listMessage ; Value: YsflFt_LastErrorText ]
Set Variable [ $closed ; Value: YsflFt_Disconnect ( $session ) ]
Set Variable [ $password ; Value: "" ]
If [ $listError <> 0 ]
    Show Custom Dialog [ "Listing failed" ; $listMessage ]
Else
    Show Custom Dialog [ "Remote files" ; If ( IsEmpty ( $names ) ; "Directory is empty" ; $names ) ]
End If
If [ Left ( $closed ; 1 ) = "?" ]
    Show Custom Dialog [ "Disconnect failed" ; $closed ]
End If
