Function Library
The Function Library is a place where you can store groups of often-used Action commands. These groups, or functions, then can be accessed from your publications at any time using VisualNEO Win’s Call Action. Functions can make your publications smaller and easier to update. For example, suppose you created a publication with 25 buttons, each performing basically the same task. Instead of entering the same series of Action commands 25 times, you could create a function and simply “call” it from each button. Also, if your function needs to be modified, you only need to edit it once instead of 25 times.
Functions can be organized into sub folders to make finding the one you want easier. Use the New Folder button to add a sub folder. To move a function to another folder simply drag its icon to the desired location.
You can modify an existing function by clicking the function’s name in the Available Functions list, then clicking the Edit button. The Action Editor will appear allowing you to make changes to the function.
The Rename button can be used to change the name of an existing function or folder. However, any publications that use the function’s old name will need to be edited to take advantage of the change.
A function or folder that is no longer needed can be removed from the list using the Delete button. Be sure that functions you delete are not used by any of your publications. If a publication attempts to “call” a function that has been deleted, you will receive an error message.
To create a new function, click the New button. A small menu will appear allowing you to select a scripting language for your new function. You can use VisualNEO Win's native scripting language, VBScript or JScript. Both VBScript and JScript are complex scripting languages that generally require an advanced knowledge of programming. However, there are many VBScript and JScript examples on the Internet that can usually be adapted to work with VisualNEO Win. See Advanced Scripting below for more information on using VBScript and JScript in VisualNEO Win.
Once you select a scripting language, the Action Editor will appear, allowing you to define what your function will do. The Action Editor contains a large editor window and a tool bar. Action commands may be typed directly into the editor, but most authors prefer to use the Insert Action button instead. Clicking the Insert Action button will display a list of available commands. The commands are organized into groups. Locate and click the title of the command you want. For most commands, VisualNEO Win will display a simple form that can be filled in to complete the Action. See Understanding Actions and Variables and Action Command Reference for a complete discussion of the Action Editor and Action Commands.
Note: The Insert Action button is only available when editing scripts created in VisualNEO Win's scripting language.
The Save As button can be used to save a copy of your function under a different name. Use the Comments button to record a short description of your function. This description will appear in the Call action's properties screen whenever your function is selected. The Test button can be used to run the current publication allowing you to test your function without leaving the editor.
The Function Parameters panel below the Action Editor can be used to create advanced functions. An advanced function can accept up to nine parameters, allowing information to be passed from anywhere in the publication. The parameters can contain whatever data your function requires to complete its work. For example, a function that calculates compound interest might use parameters to input the loan’s present value, interest rate and length.
To create a parameter, click the Add button. A Parameter Properties screen like the one below will appear:
The Alias is a place holder for the parameter’s data. The alias is essentially a special variable that can be used in any of your function’s actions. Like a variable, an alias is simply an area of the computer’s memory that can be used to store information. Each function alias should be given a unique name and surrounded by square brackets ( [ ] ). When creating a new parameter, the default alias assigned by VisualNEO Win corresponds to the parameter’s number (for example: [%1]). However, you may wish to change this name to something that better describes what this particular parameter represents. In the case of our sample Compound Interest function above, we might change the first parameter’s alias to something like [%PV] for Present Value. The % symbol is optional, but including it can be helpful in telling the difference between aliases and regular variables.
Parameters can contain different types of data. To prevent the wrong type of data from being entered into a parameter, use the Type field to select one of the following options:
Text |
Parameter is a character string. May contain alpha characters, numbers, punctuation, etc. |
Number |
Parameter is a number. |
Mixed |
Parameter may be either numeric or alpha. May contain mathematical expression. |
File Name |
Parameter is a file name. |
Variable |
Parameter is a variable name. |
Finally, use the Description field to indicate what type of data the parameter expects. The description will appear in the Call action’s wizard as a reminder to you what the parameter is for.
Click OK to close the Parameter Properties screen and add the new parameter to the function.
When writing the script that comprises the function, simply insert the alias in the locations where you want the data they represent to appear. For example, our sample function that computes compound interest includes the following parameters:
The script to calculate the compound interest consists of only a single Math Action, but you can see how the aliases play an important role:
Math "[%PV]*((1+[%R])^[%N])" "2" "[%FV]"
Once the function is complete, click the OK button to save it. You will be prompted to give the function a Name. You should select a name that adequately describes what the function does. “Compound Interest,” for example. The name will appear in the Function Library and will be used when calling your function.
When you later use the Call Action and select the "Compound Interest" function, the Action Wizard will display fields for the Present Value, Interest Rate, Loan Period and Result parameters. The values you enter here will be used by the Compound Interest function.
Advanced Scripting: Using VBScript and JScript with VisualNEO Win
VisualNEO Win provides three special methods that VBScript and JScript programmers can use to communicate with VisualNEO Win. These methods (called nbGetVar, nbSetVar and nbExecAction) can be combined with native VBScript and JScript methods to establish two-way communication between the a function and your publication. This provides VisualNEO Win publications with direct access to many powerful JScript and VBScript features, which you can use to augment VisualNEO Win's own scripting language.
Note: Some experience with and VBScript or JScript are required to use these features.
Special VBScript/JScript methods supported by VisualNEO Win:
nbSetVar
Purpose: |
This method assigns a value to a VisualNEO Win variable. |
Syntax: |
publication.nbSetVar "variable name", "value" variable name The name of a VisualNEO Win variable. The variable name should be surrounded by square brackets. value The value to assign to the variable. |
Example: |
The following VBScript example passes a simple string to VisualNEO Win: publication.nbSetVar "[Result]", "Hello from VBScript!" Here is an example showing how function aliases can be used with nbSetVar: Function Celsius( fDegrees ) Celsius = (fDegrees - 32) * 5 / 9 End Function publication.nbSetVar "[%2]", Celsius( [%1] ) |
nbGetVar
Purpose: |
This method returns a string containing the contents of a VisualNEO Win variable. |
Syntax: |
value = publication.nbGetVar( "variable name" ) variable name The name of the VisualNEO Win variable to retrieve. The variable name should be surrounded by square brackets. value The contents of the VisualNEO Win variable in string format. |
Example: |
The following VBScript example copies the contents of VisualNEO Win's [PubTitle] variable to a VBScript variable and displays it in a message box: title = publication.nbGetVar( "[PubTitle]" ) MsgBox title |
nbExecAction
Purpose: |
Use this method to execute VisualNEO Win actions. |
Syntax: |
publication.nbExecAction( "action script" ) action script The VisualNEO Win action to execute. Multiple actions may specified by separating them with a carriage return. |
Example: |
This example executes VisualNEO Win's AlertBox action: publication.nbExecAction( "AlertBox ""Hello"" ""Hello from the Web Browser!""" ) |