Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

IsServer

Checks if plugin is running on a server.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
Plugin 4.3 Yes Yes Yes Yes Yes

MBS( "IsServer" )

Parameters

none

Result

Returns 1 on server or 0 elsewhere.

Description

Checks if plugin is running on a server.
So if you see 0 returned, your script or calculation is not performed on a server, but on a client.
Should return 1 always for scheduled server scripts or web direct scripts.

See also IsRegistered, IsClient and IsRuntime.

Examples

Run a script on server:

If [MBS("IsServer")]
    # We run on server already
Else
    # Call this script on server
    Perform Script on Server [Wait for completion; “Your Script”; Parameter: Get(ScriptParameter)]
    If [Get(LastError)  ≠ 0]
        # Can't run on server, e.g. too many connections.
    End If
End If

Perform Script on Server:

# are we on Server?
If [MBS("IsServer") = 0]
    # perform same script on server and pass parameter
    Perform Script on Server [Wait for completion; “Do Something on Server”; Parameter: Get ( ScriptParameter )]
    # check error and result
    Set Variable [$LastError; Value:Get ( LastError )]
    # Maybe handle here error code if server is too busy and decide what to do, e.g. run script locally?
    If [$LastError ≠ 0]
        # run locally by fall through
        # alternative: Exit script here and return error to caller
    Else
        Set Variable [$ScriptResult; Value:Get ( ScriptResult )]
        #Return result back to caller
        Exit Script [Result: $ScriptResult]
    End If
End If
#This now performs on Server or on Client if Server is too busy
Go to Layout [“Test”]
New Record/Request
Set Field [perform::First; 1]
Set Field [perform::Last; 2]
Commit Records/Requests [No dialog]
# end of script

See also


IsRuntime   -   IsWindows

Feedback: Report problem or ask question.




Links
MBS Xojo Plugins