addEntitlement() preMain Functions
Provides script developers with a mechanism to quickly activate or deactivate scripts for paying customers. Using this feature, you can encrypt and distribute a single copy of a particular script and only authorized users will be able to run the script. Starting with version 11 you can also specify an expiration date in mm/dd/yyyy format for each user.
Syntax
addEntitlement( Code/URL , Description [, URL ] )
Parameters
Parameter: | Description: | Default: |
Code/URL | A string which represents entitlement code provided by eSignal or fully-qualified URL to text file containing valid user names. | n/a |
Description | A string which represents text to display to unentitled user. | n/a |
URL | [Optional] A string which represents URL to launch if user clicks on description. | n/a |
Notes
There are two ways to restrict access to the script.
The first way is create a text file with the eSignal usernames of all users who are authorized to use your script and place this text file on your web site or in a private group in the eSignal File Share. Usernames should be entered one per line. Starting with version 11 you can also specify an expiration date in mm/dd/yyyy format for each user. To do this, you must specify an expiration date next to the name of a specific user using a comma. If the current date is equal or greater than the date that was specified for the user, that user will not be able to run the EFS study. Place the addEntitlement() function in preMain() and include the fully qualified URL to the location of the authorization text file. The final step is to encrypt the script. As users purchase/lease your scripts, you can add their eSignal username to the centrally-located authorization file. Deactivating a user is as simple as removing their eSignal username from the same file.
When a user loads a script that includes the addEntitlement() function, the file specified in the required "URL" parameter will be accessed. If the current user's eSignal username is found in the list, the script will function normally. If the username is not found in the list of authorized users, the text specified in the Description parameter will be displayed to the user and the script will be halted. If the optional "URL" parameter is used, the user can double-click on the text that is displayed and their browser will be opened to the specified URL.
The second way is use an entitlement code provided by eSignal. In this case, the script will be available only to users whose accounts have this entitlement code. Place the addEntitlement() function in preMain() and put an entitlement code as the first parameter "Code". Encrypt the script. If the user's account does not have the entitlement code, the text specified in the "Description" parameter will be displayed to the user and the script will be halted. If the optional "URL" parameter is used, the user can double-click on the text that is displayed and their browser will be opened to the specified URL.
Starting with version 11.1 all mouse functions require the use of the Shift key when called from the chart. This change was done to avoid conflicts between EFS and chart mouse events (such as right clicking or double clicking) without compromising any backwards compatibility.
Code Examples
Using an authorization text file from web site
function preMain() { setPriceStudy(true); setStudyTitle("Example Script"); setCursorLabelName("EMA", 0); setDefaultBarFgColor(Color.blue, 0); setShowTitleParameters(false); //when this script is loaded, addEntitlement() will be called and the current user's eSignal //program username will be checked against a list of authorized user names. If this user is //not in that list, script operation will abort and an error message will be displayed addEntitlement("www.myWebSite.com/AuthorizedUsers.txt", "Sorry. Not authorized.", "www.MyWebSite.com"); }
AuthorizedUsers.txt (contains each entitled eSignal username with one username per line)
janedoe123, 01/01/2011 jsmith456etc... |
Using an entitlement code provided by eSignal
function preMain() { setPriceStudy(true); setStudyTitle("Example Script"); setCursorLabelName("EMA", 0); setDefaultBarFgColor(Color.blue, 0); setShowTitleParameters(false); //when this script is loaded, addEntitlement() will be called and the current user's eSignal //program username will be checked for the presence of an entitlement code. If this user's //account does not have this code, script operation will abort and an error message will be displayed addEntitlement("ENTCODE", "Sorry. Not authorized.", "www.MyWebSite.com"); }