|
|
Recent News
|
Hotel Software DocumentationUser Functions
IntroductionA User Function is a script that can be executed from other scripts. For example, if you use a set of actions in several scripts, you can create a User Function containing these actions and call this function when you need. User Functions can accept arguments and return the result of their work to a specified variable. For example, you can create User Function that calculates a complicated formula basing on some input data and returns the result to a variable. You can also record specified values to specified fields of a selected database record. Using User FunctionsHere is an example of simplifying the script described in the Script Designer using a User Function: First the script asks the user to enter the value of the [$quantity] variable that should exceed 0, then it increases the value of the [Order Total] field of the current folder by the entered value. Let's replace this part of the script with a User Function: Creating a New User FunctionTo create a new User Function click User Functions->Create New... or right-click the User Functions tree and select Create New...: Enter the name of the new User Function. For example, ChangeQuantity. Click Ok to open the User Functions editor: Editing User FunctionsEditing a script in User Functions is similar to editing an ordinary script. See the Script Designer Help Section for more information. As noted above, a User Function can accept arguments and return values to a variable. To set a User Function click the UF Setup... button or click User Function Properties... in the menu: User Function Properties
If you change User Function properties as shown on the illustration, predefined variables will appear in the script tree of the UF editor: You should record the result of the User Function to the [$result] variable in the end of the script. We'll create a User Function using these variables: Click Ok to save the User Function. Inserting a User Function to a scriptTo call a User Function from a script, click User Functions->Insert... or double-click the required function in the function tree. A standard Select Action dialog box will open: In the dialog box we can set values of the User Function (default, text) and specify the variable where the action result will be saved ([$new_total]). Thus, the script containing a User Function will look like this:
Changing Many Records with User FunctionThis way of modifying records is obsolete. It is much more convenient to modify record in cycles. Know more... You can apply a User Function to several records (a set of records). For example, you can change the value of record fields, e-mail a record, etc. Let's take the ChangeQuantity User Function described above. To perform an action with a recordset we should do the following:
The script for changing several records looks like this: See Also: |
Today"s Poll What software do use for your inn/b&b/hotel/etc? |
Home Page | Contacs | Terms and Conditions | Copyright (C) 2001-2010 Binary Brilliant Inc | |