Section 10.3.  Script files and forms

Prev don't be afraid of buying books Next

10.3. Script files and forms

As you may have noticed, the script file that appears in Script Editor contains other functions in addition to the one you are editing at the moment. Each form has at least one script file associated with it that contains all the necessary functions for that form.

InfoPath scripts can be written in JScript or VBScript, the default being JScript. All of the examples in this chapter are written in JScript. These two languages are similar and are often embedded in HTML to enhance Web pages. To change the scripting language for a form, click Options on the Tools menu and click the Design tab. Under Scripting, choose whether you want to write scripts in JScript or VBScript.

Script files can contain a list of functions for that form, as well as variable definitions and comments. Some functions may be associated with a particular field or button, while others are associated with the form as a whole. In addition, you can create a library of added functions in the script file in order to reuse code.

When a form is saved, the script file is stored within the .xsn file. If you use the Extract Form Files command to extract the files associated with the form, the script file will appear as a separate file whose extension is .js. By default, it will be named script.js.

It is possible to create additional script files and associate them with the form using the Resource Manager which is accessible from the Tools menu. This is useful for sharing functions across multiple forms. However, you will not be able to edit the additional script files using Script Editor; you will have to edit them in another tool such as a text editor or Visual Studio.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net