Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

IsServer

Checks if plugin is running on a server.

Component Version macOS Windows Linux Server 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

Blog Entries

This function is free to use.

Created 18th August 2014, last changed 21st October 2017


IsRuntime - IsWindows