BRIO Object Model Manual
BRIO Object Model Manual
BRIO Object Model Manual
Trademarks
Brio®, Brio.Enterprise™, BrioQuery™, BrioQuery Designer™, BrioQuery Explorer™,
BrioQuery Navigator™, Brio.Quickview™, Brio.Insight™, BrioQuery.Server™, Brio
OnDemand Server™, Brio Broadcast Server™, and Brio Enterprise Server™ are
trademarks or registered trademarks of Brio Technology, Inc., in the United States and
other countries. All other marks are the trademarks or servicemarks of Brio’s suppliers
or partners and are the property of such third parties.
Contents in Brief
PART I Overview
CHAPTER 1 Executive Information Systems
CHAPTER 9 Objects
CHAPTER 10 Methods
CHAPTER 11 Properties
CHAPTER 15 Statements
Index
iv Contents in Brief
Contents
PART I Overview
CHAPTER 1 Executive Information Systems
EIS Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
Working with the EIS Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Inserting an EIS Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-3
Renaming an EIS Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Deleting an EIS Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
Switching Between Design and Run Modes . . . . . . . . . . . . . . . . . . . . . . . 1-4
Working with EIS Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
Inserting EIS Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Deleting EIS Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Setting EIS Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-7
Alignment Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-8
Border And Background Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9
Font Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-11
Object Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-12
Picture Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14
Tab Order Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-15
Values Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-16
Using Design Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Layout Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Design Guides . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Grids . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-17
Rulers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
EIS Section Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-18
Navigation Toolbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
EIS Menu Command Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-19
vi Contents
PART II Brio JavaScript Tutorials
CHAPTER 4 JavaScript Syntax
Basic JavaScript Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
JavaScript Code Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-2
JavaScript Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
Using Assignment versus Comparison Operators . . . . . . . . . . . . . . . . . . 4-5
Exercise: Adding Comparison and Assignment Buttons . . . . . . . 4-6
Exercise: Using the Comparison Operator . . . . . . . . . . . . . . . . . . 4-7
Exercise: Using the Assignment Operator . . . . . . . . . . . . . . . . . . . 4-7
Including Operators in Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-8
Exercise: Using Operators as Characters . . . . . . . . . . . . . . . . . . . . 4-8
Concatenating versus Adding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
Exercise: Concatenating Values . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Exercise: Summing Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
Declaring Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Declaring Global Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
Dynamically Declaring Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
Assigning Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-15
Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
Contents vii
CHAPTER 6 JavaScript Control Structures
Understanding Control Structure Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-2
About if...else Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
Exercise: Using an if...else Statement to Change Chart Types . . . 6-5
About switch Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-8
Exercise: Using a switch Statement to Change Chart Types . . . . 6-9
Controlling Chart Facts with if...else . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-12
Controlling Chart Facts with switch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-13
viii Contents
Loop Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
for Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
do...while Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12
while Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13
label Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-14
continue Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-15
break Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-16
Manipulating Objects with JavaScript . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
for...in Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-17
with Statement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-18
Using JavaScript to Open Web and OnDemand Server Documents . . . . . 8-18
Shell() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
OpenURL() Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-19
Bypassing the Userid and Password . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-21
Including Limit Values in the URL Submitted to the ODS . . . . . . . . . . 8-21
Passing Parameters to OnDemand Server Documents Using Browser
Cookies or URL Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-21
Accessing Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-22
Accessing URL Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-23
Microsoft Automation Interfaces and the Object Model . . . . . . . . . . . . . . . 8-24
OLE Automation Controller within JavaScript . . . . . . . . . . . . . . . . . . . . . . 8-25
Exporting Scripts to Text Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-25
Troubleshooting Scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26
Space-Saving Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-26
Case-Sensitive Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-27
Assignment Operators Versus Comparison Operators . . . . . . . . . . . . . 8-27
Conditional Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-28
Syntax Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
Recalculating Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-30
Designing Your Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-31
Code Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33
Bypass Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-33
Getting Help with a Problem Script . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-34
CHAPTER 9 Objects
CHAPTER 10 Methods
CHAPTER 11 Properties
Contents ix
CHAPTER 12 JavaScript Examples
Displaying and Entering Values in a Text Box . . . . . . . . . . . . . . . . . . . . . . . 12-2
Retrieving and Setting the Properties of an Object . . . . . . . . . . . . . . . . . . . 12-3
Enabling and Disabling Controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-3
Controlling the Visibility of Graphics and Controls . . . . . . . . . . . . . . . . . . 12-4
Creating an OCE (connection file) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
Displaying a Connection Login Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-5
Downloading Data Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
Displaying a Table Catalog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
Adding Topics to a Data Model Section . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
Setting up Topic Object Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-6
Adding Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-7
Adding Items to the Request Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-8
Adding a Computed Column to a Query Request Line . . . . . . . . . . . . . . . 12-8
Creating and Setting Variable Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9
Using the ODS User Name as a Limit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9
Using a BrioQuery 5.5 Limit Dialog Box and
Storing Selected Value in Text Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12-9
Turning off the Page Headers for the First Page in the Report . . . . . . . . . 12-10
Including Limit Values in the URL Submitted to the ODS . . . . . . . . . . . 12-10
Turning off the Prompt To Save Dialog Box . . . . . . . . . . . . . . . . . . . . . . . 12-10
Processing Queries Using “Don’t Prompt For Database Logon” . . . . . . . 12-11
Processing Queries Using “Prompt For Database Logon” . . . . . . . . . . . . 12-12
x Contents
PART IV General JavaScript Reference
CHAPTER 14 JavaScript Operators
Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-2
Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-3
Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-4
Bitwise Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-6
Bitwise Shift Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-7
Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-8
Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-9
Short-Circuit Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-10
String Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-10
Special Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14-11
CHAPTER 15 Statements
Index
Contents xi
xii Contents
About This Book
In This Book
BrioQuery Object Model and Executive Information Sytems is one of four books
that explain how to use BrioQuery (see “Related Documents” on page xv).
This book contains four main parts:
■ Part I, “Overview,” provides an overview of the EIS section and introduces
the BrioQuery object model and JavaScript, an object-oriented
programming language.
■ Part II, “Brio JavaScript Tutorials,” provides hands-on experience with
creating JavaScript scripts. The exercises focus on the relationship between
the Executive Information System, the BrioQuery object model, and the
built-in Script Editor for creating customized, interactive front-ends to
enterprise data.
■ Part III, “Brio Scripting Reference,” describes the structure of applications
scripted in BrioQuery and provides general reference and troubleshooting
information. It is also a complete reference to BrioQuery’s objects,
methods, and properties, and to the BrioQuery object model.
■ Part IV, “General JavaScript Reference,” provides information on
JavaScript operators, statements, and core objects.
Audience
This book is written for developers who create documents using BrioQuery
Explorer or Designer and who need to create front-ends using the EIS
functionality provided by the BrioQuery application.
The tutorials are written for the application designer who has BrioQuery
experience, but little or no JavaScript experience. The reference sections are
written for all levels of BrioQuery users who need detailed information on
BrioQuery elements and JavaScript.
Typographic Conventions
This book uses the following typographic conventions:
■ Options, buttons, or tabs that you need to choose and text that you need to
type are indicated in bold.
Select Typical Install. Type 1234.
■ Key names are shown in square brackets.
Press [Down Arrow]
■ Two key names joined with a plus sign (+) are consecutive keystrokes. Press
and hold down the first key while pressing the second key.
Press [Ctrl+Z]
■ Options in a menu command path are separated with an arrow. The
example indicates that you are to open the File menu and choose the Open
menu item.
Related Documents
Along with the BrioQuery Object Model and Executive Information Sytems
book, there are three additional BrioQuery books:
■ Getting Started with BrioQuery 6.5 provides an overview of BrioQuery and
explains the BrioQuery user interface and basic commands. It includes how
to retrieve data using BrioQuery, how to query new data and change
existing queries, and how to query a single database as well as multiple
databases. It also covers how to work with query results.
■ Data Analysis and Reporting with BrioQuery 6.5 describes how to use the
BrioQuery application’s powerful reporting features—pivots, charts, and
tables—and the Report Designer to create spectacular reports.
■ BrioQuery 6.5 Administration Guide explains data modeling, including how
to modify existing data models, and create new data models. It also
discusses metadata definitions, database connectivity, and document
scheduling.
IOverview
2
1 Executive Information Systems
1-1
EIS Section
The EIS section provides a streamlined, push-button approach to querying a
database. Through the EIS section, application designers can quickly combine
report sections and enhanced EIS controls to build and deploy analytic
applications that deliver prepackaged business content, including:
■ Simple forms to collect multiple input parameters for a report
■ Executive dashboard applications, complete with visual drill-down from
high-level metrics to underlying data content
■ Browser-style navigation pages to assist users in maneuvering around and
between documents
Embedded
Section Graphic
Pane
Embedded
Text
Sections
Content
Graphic
Pane
Items
Control Embedded
Items Chart
Section
Catalog
Pane
You customize an EIS section by dragging objects from the Catalog pane to the
Content pane, and then attaching scripts to them that are executed in response
to an event or action.
1 In the Section pane, select the EIS section you want to rename.
2 Choose Edit→Rename Section.
The Section Label dialog box appears.
1 In the Section pane, select the EIS section you want to delete.
2 Choose Edit→Delete Section.
The Delete Section dialog box appears.
3 Click Delete.
✏ Note In Run mode, active embedded tables and results have the Sort Ascending and Sort
Descending options available on the shortcut menu. You can also resize Table and Results
columns.
Text Label Creates a text label that you can use as a caption.
Check Box To toggle an option on/off or true/false. A check box either contains a
check mark or is empty.
List Box To list multiple values from which users can make one or more
selections.
Drop Down To list multiple values from which users can make only one selection.
2 In the Catalog pane, expand the folder that contains the object you want to insert.
3 Click the object you want to insert and drag it to the Content pane.
You can also use the following procedure to insert control and graphic objects:
1 Choose EIS→Properties
The Properties dialog box appears. The active page depends on the selection
made prior to invoking the dialog box.
2 Click through the tabs to set properties for the selected object.
3 Click OK to apply the selected settings and close the Properties dialog box.
Available properties include:
■ Alignment – Horizontal and vertical alignment, and text wrapping and
rotation.
■ Border And Background– Border color, width, style, and shadow, and
background color and pattern.
■ Font – Font family, style, size, effects (underline, overline, double overline),
and color.
■ Object – Name, title, visible, enable (control objects only), locked, scroll
bars always shown, and auto-size. For embedded sections, view-only, active,
or hyperlink.
■ Picture – File name, size, and effects for EIS background and graphic object
pictures.
■ Tab Order – Object path that end users follow when they press the [Tab] in
Run mode.
■ Values – User-defined values that populate list box, drop down, or text box
controls.
Detailed information on each of these properties is presented on page 1-8
through page 1-16.
Alignment Properties
Use the Alignment page of the Properties dialog box to specify how objects are
aligned in the EIS Content pane.
Vertical Alignment Sets the vertical text alignment to either Top, Middle, or Bottom. Text labels, pictures
Rotation Sets the rotation alignment to either Horizontal, Vertical, Vertical Rotated Up, Text labels, pictures
or Vertical Rotated Down.
Text Wrap Sets the text wrap property. Text labels, pictures
Preview Shows the results of the property settings on the selected object. Text labels, pictures
Border Color Sets the color of the border. All graphics objects except pictures
Border Width Sets the width of the border from 1pt to 6pt. All graphics objects except pictures
Border Style Sets style of the border to solid, dashed, or dotted. All graphics objects except pictures
Border Shadow Sets the shadow of a graphic object. All graphics objects except lines
and pictures
Background Color Sets fill color of the graphic object. Default (white), None All graphics objects except lines
(transparent), Custom (combination of a color mixed with and pictures
pattern)
Background Pattern Sets the background color by blending the Background color All graphics objects except lines
and white to produce a percentage fill of the pattern. Solid and pictures
sets 100% of the background color, 75% blends in 25%
white, 50% blends in 50% white, and 25% blends in 75%
white.
Preview Shows the results of the property settings on the selected All graphics objects except pictures
object.
Table 1-5 describes the properties available on the Font page and specifies
which properties apply to which objects.
Font Sets the type of font. Text label graphics objects, all control objects
Font Style Sets the style to one of the following: Regular, Italic, Bold, or Text label graphics objects, all control objects
Bold Italic.
Font Size Sets the font size. Text label graphics objects, all control objects
Font Color Sets the font color. Text label graphics objects, all control objects
Font Effects Sets the font effect to one of the following: Underline, Text label graphics objects, all control objects
Overline, or Double Overline.
Table 1-6 describes the properties available on the Object page and specifies
which properties apply to which objects.
Name Sets the object’s name. The object model uses this name to reference All objects (embedded sections,
this object. graphics, and controls)
Title Specifies an optional name title for the object. Command button, radio button,
check box, and text box controls
Visible Allows the object to be visible during Run mode. All sections
Locked Locks an object’s position in the Content pane. All objects (embedded sections,
graphics, and controls)
Scrollbars Always Turns on scroll bars in Run mode if the size of the original object Pivot, Results, and Table sections
Shown exceeds the allotted region in the EIS Content pane. This option is
not available if Auto-Size is selected.
Auto-Size Sizes the object to fit in the allotted region in the EIS Content pane. Pivot and Table sections
If not selected, the embedded object retains the size of the original
section. Vertical and horizontal scroll bars are enabled so that users
can easily navigate through the data.
Group Name Enables you to provide a distinct name for a group of radio buttons. Radio button controls
The default Radio Group name is RadioGroup.
Allow Multiple Allows users to select multiple values in a list box. By default, a List box controls
Selections single value is returned from a list box selection.
Password Displays asterisks (*) in place of characters typed in a text box. Text box controls
Scrollable Turns on scroll bars for viewing data not visible in the immediate Text box controls
display area.
View Only Provides read-only interaction with the embedded section, which All embedded sections
appears as a thumbnail in the EIS section. View Only is the default
setting for all embedded sections.
Active Provides limited analytical interaction with the embedded section, All embedded sections
which appears clipped in the EIS section. Only a subset of the
analytical functions available in the original sections are available for
use in embedded sections.
Hyperlink Allows users to easily navigate to the original section from the All embedded sections
embedded section, by clicking the thumbnail in the EIS section.
Property Description
Picture Sets the bitmap (.bmp) file that is used for the picture graphic object.
Picture Scale Sets the height and width for the picture as a percentage of the original size.
Picture Effect Sets the picture effect to one of the following: None, Stretch, Clip or Title.
✏ Note The EIS background is not considered an object in the tab-order definition.
■ Double-click an object name in the list to add or remove it from the tab
order. Objects preceded by an asterisk (*) are included in the tab order.
■ Click Up or Down to change the tab order sequence of one or more selected
objects.
Tab order is defined from top to bottom. Initial focus is placed on the
asterisked object listed first in the tab-order definition. Each toggle between
Run and Design modes re-initializes the tab order back to the first asterisked
object in the list.
The tab order also includes disabled and invisible EIS objects and overrides any
Enable and Visible properties settings. You need to determine whether you
want to include disabled or invisible objects in your tab-order definition.
Values Properties
Use the Values page of the Properties dialog box to define one or more values
for the List Box and Drop Down control objects.
■ To define values for a list box or drop down control object, type a value in
the List Value field and click Add.
✏ Note To add multiple values for list boxes or drop downs, make sure the Allow Multiple Selection
check box on the Object page is selected.
■ To remove values from the list, select one or more values and click Remove.
■ To change the order of the listed values, select a value and click Move Up or
Move Down.
Layout Tools
A rich set of layout aids is available to help you easily create professional
looking EIS sections. All the layout tools are available from the EIS Menu or
the EIS Section Toolbar.
Design Guides
Design guides are horizontal and vertical lines that you place in your report to
help you line up objects. Design guides are similar to grids in that objects
automatically snap to align to the design guides.
If rulers are visible, click the ruler and drag one or more design guides from
both the horizontal and vertical rulers.
Grids
BrioQuery provides a layout grid that automatically snaps all objects to the
closest grid spot.
Choose EIS→Grid.
A check mark appears next to Grid to indicate the grid is visible. Choose this
option again to clear the check mark and remove the grid from view.
Choose EIS→Ruler.
A check mark appears next to Ruler to indicate the ruler is visible. Choose this
option again to clear the check mark and remove the ruler from view.
Design/Run Mode
Align
Make Same Size
Layer
Example 2: //Syntax for turning on all toolbars except the Navigation toolbar
j=Toolbars.Count
Keyboard Shortcut
Command Description Shortcut Menu
Design Mode Toggles between the design and run mode. [Ctrl+D]
Summary
This chapter provided an overview of the EIS section, and familiarized you with the
concepts, procedures, and tools involved with custom application design. As you
continue, remember these points:
■ The EIS section is what you use to develop custom applications referred to as
Executive Information Systems. It acts as the front-end to a BrioQuery document
and simplifies your users’ interactions with databases and other document
sections.
■ You can embed a variety of objects to help you construct a custom EIS, including
Results, Table, Chart, Pivot and OLAP sections, graphics, bitmap pictures, and
graphical interface controls.
■ Customized EIS sections are event driven and execute scripts in response to an
action, such as clicking a button or opening a document.
■ You can control the order in which users navigate a customized EIS section by
specifying a tab-order definition in the Properties dialog box.
2-1
Understanding the BrioQuery Object Model
The BrioQuery object model is a hierarchical representation of BrioQuery
objects and the actions and attributes used to manipulate those objects. It
consists of a collection of objects, each of which has its associated methods
(actions) and properties (attributes).
Objects
Method What it can do; action that is executed Grow, bear fruit, Activate, Copy, Add
when an object receives a message. drop leaves
✏ Note BrioQuery uses JavaScript as its scripting language since the release of BrioQuery version 6.0.
Documents scripts created using the older Brio scripting language are automatically converted
to JavaScript when the document is first opened.
BrioQuery has a set of predefined events. You determine how these events
respond by attaching a script to the event. For example, if you want a button to
perform an action when clicked, you attach a script that defines your action to
the OnClick event associated with the button.
BrioQuery’s predefines events as follows:
■ Object Level Events – Events associated with EIS objects.
■ Section Level Events – Events associated with EIS sections.
■ Document Level Events – Events associated with BrioQuery documents.
In addition to the overall object level events, graphic objects and control
objects have specific predefined events with which they are associated, as
shown in Table 2-3 and Table 2-4.
Line OnClick
Rectangle OnClick
Picture OnClick
Caution ! OnShutDown events execute before any prompts in the Save dialog box
Choose File→Document Scripts to open the Script Editor from any section other than
the EIS section.
Object
Browser
Description
Pane
The Script Editor contains the Object browser, the Description pane, the
Events drop-down menu, and the Scripting pane.
Methods and
Properties for
the Active
Document
Sample1.bqy
A script that accesses multiple open documents should use the Documents
path to the methods and properties of a specific document. A script that affects
only the currently active document can use the ActiveDocument path.
4 Double-click Activate.
BrioQuery automatically enters a script in the Scripting pane and attaches it to
the OnStartup event listed in the Event drop-down box.
✰ Tip Expand the view of the object model by clicking and dragging the striped
arrow at the bottom of the Object browser’s scroll bar.
✏ Note The following procedure assumes that Sample1.bqy, opened in the “Sample JavaScript Script”
is still open.
1 Activate the EIS section of Sample1.bqy, by clicking the title in the section pane.
2 Choose View→Execution Window.
An Execution window opens:
4 Open the document script created earlier (choose File→Document Scripts), copy the
script, and then paste it in the Execution Window.
✏ Note The following exercise uses the script previously entered in the Execution window in
Sample1.bqy.
Line 1 contains the error. The error message is referring to the method (or
function) activate. Because JavaScript is case sensitive, it does not recognize
activate as Activate.
Summary
When creating customized interfaces, remember these points:
■ Choose EIS→Design Mode to toggle between Design and Run modes. [Ctrl+D].
■ Add scripts to documents and EIS sections by opening the Script Editor on the
document (File→Document Scripts) or the section (EIS→Scripts). [F8]
■ The Object browser in the Script Editor displays the entire BrioQuery application,
the Brio Constants, and the EIS section objects in a hierarchical structure.
■ Object and their methods and properties can be accessed from more than one
place in the application hierarchy.
■ Create error-free scripts by navigating the object model and double-clicking the
applicable methods and properties.
The previous chapter introduced the BrioQuery object model and explained
how to use the built-in scripting tools to quickly add JavaScript to a document.
This chapter shows how to associate simple scripts to various EIS control
objects using the Script Editor and the Object browser. It contains:
■ Scripting Control Objects
■ Associating Scripts with Command Buttons
■ Associating Scripts with Radio Buttons
■ Associating Scripts with Check Boxes
■ Associating Scripts with List Boxes
3-1
Scripting Control Objects
This chapter explains how to associate JavaScript scripts with four of the EIS
control objects: command buttons, radio buttons, check boxes, and list boxes.
The exercises in this chapter guide you through inserting a new EIS section in
Sample3.bqy, adding control objects to the new section, and associating
scripts with the controls.
Section
Pane
Content
Pane
Catalog
Pane
3 In the Section pane, double-click EIS to open the Section Label dialog box.
4 Type Controls in the Label field and then click OK to close the Section Label dialog box.
✏ Note The exercise in this section assumes that you have previously inserted a new EIS section in
Sample3.bqy and renamed the new section Controls.
The entry in the Title field appears as a label on the control object. The entry in
the Name field appears on the Title bar in the Script Editor and in the object
model.
✏ Note The exercise in this section assumes that you have previously inserted a new EIS section in
Sample3.bqy and renamed the new section Controls.
1 Drag a command button control from the Catalog pane to the Content pane and use the
Properties dialog box to specify its title as RevSummary.
(See “Changing a Control Object’s Title” on page 3-3 for detailed
instructions.)
2 With the RevSummary object’s selection handles visible, choose EIS→Scripts. [F8]
You have just learned to associate a script with a command button. You can
review your script by activating the Controls EIS section, toggling to Design
mode, and opening the Script Editor for the command button.
Exercise Create another button. Associate the button with a script that duplicates the
RevSummary section. You can also try this on other BQY documents
ActiveDocument.Sections[“RevSummary”].Duplicate()
✏ Note The exercises in this section assume that you have previously inserted an EIS section in
Sample3.bqy and renamed it Controls. These exercises show you how to embed a chart and
add radio buttons for user-control of the chart type.
2 Drag the chart named RevbyTime from the Catalog pane to the Content pane.
The script in this exercise changes the chart type to a line chart. Before
changing the chart with the script, verify that RevbyTime is a vertical bar chart.
To verify and change the chart type, activate the RevByTime section and
choose Format→Chart Type→Vertical Bar, then return to the Controls
section.
1 Drag a radio button control from the Catalog pane to the Content pane and use the
Properties dialog box to specify its title as Line.
(See “Changing a Control Object’s Title” on page 3-3 for detailed
instructions.)
3 Use the Object browser to locate and expand the RevByTime section of ActiveDocument.
4 Expand the RevbyTime Properties folder, then double-click ChartType.
BrioQuery automatically enters the first part of the script in the Scripting
pane. Property ChartType as BqChartType appears in the Description pane.
BqChartType is a constant whose values appear in the Constants collection
of the Object browser.
6 In the Scripting pane, type and equals sign (=) immediately after ChartType.
7 Double-click bqChartTypeLine.
BrioQuery adds the rest of the script to the Scripting pane.
Exercise Create a second radio button with the title Vertical Bar by toggling to Design
mode and working through the preceding exercise.
Add a script to this radio button to change the chart type to vertical bar
(bqChartTypeVerticalBar).
✰ Tip Radio buttons work in groups: when one button in the group is selected, the
others in the same group are cleared. Set the group name in the Properties
dialog box for each button. The default group name is RadioGroup.
1 Drag a check box control from the Catalog pane to the Content pane and use the
Properties dialog box to change the Name and Title properties as follows:
■ Name – chk_IntervalValues
■ Title – Show/Hide Dollars
(See “Changing a Control Object’s Title” on page 3-3 for detailed
instructions.)
The Name chk_IntervalValues is used in the script for the Show/Hide Dollars
check box.
Consider that a check box has two conditions: checked and unchecked (or
cleared). Hence, the JavaScript needs to perform an action when a given
condition is true and negate that action if it is false. “If ” a condition exists, then
a given action occurs; “else” the reverse happens.
1 With the Show/Hide Dollars check box object’s selection handles visible, choose
EIS→Scripts. [F8]
}
else
{
■ The parentheses enclose a statement that tests the checked property of the
check box (chk_IntervalValues).
■ The first set of curly brackets, after the if, encloses the statement to execute
if the test is true.
■ The second set of curly brackets, after the else, encloses the statement to
execute if the test is not true.
5 Click on the line between the curly brackets and add the statement to execute if the test
is true.
6 Click on the line between the curly brackets (after else) and add the statement to
execute if the test is false.
a. Use the Object browser to navigate to
Application→ActiveDocument→Sections→RevByTime→ValuesAxis→Pr
operties, and then double-click ShowIntervalValues.
b. Type =false and a semicolon (;) at the end of line in the Scripting pane.
else
{
ActiveDocument.Sections["RevByTime"].ValuesAxis.ShowIntervalValues=false;
}
Exercise Create another check box. Associate the check box with a script that shows/hides
another property of the chart.
Any property in the chart’s Property dialog (in the chart section) can be accessed
through the object model and JavaScript. To view RevByTime chart properties,
activate this section by clicking the title in the Sections pane, click in white space
close to the chart, right-click, and then select Properties from the menu that
appears.
You can also try the exercise on some other BQY document.
✏ Note The exercise in this section assumes that you have previously inserted a new EIS section in
Sample3.bqy and renamed the new section Controls.
1 Drag the list box icon from the Catalog pane to the Content pane of the Controls section.
2 With the list box control selection handles visible, choose EIS→Properties.
The Properties dialog box appears.
Turns Multiple
Selections On and Off
3 Enter Time in the Name field and then clear the Allow Multiple Selections check box.
When Allow Multiple Values is not selected, only one selection is allowed.
4 Click the Values tab, add the values Today, Tomorrow, and Yesterday, and then click OK.
This method displays an alert box. The content of the alert is controlled with
arguments added between the parentheses.
7 Click in the parentheses after Alert and use the Object browser to navigate to
Controls Objects→ Time→SelectedList→Methods, and then double-click Item.
Application.Alert(Time.SelectedList.Item())
Exercise Edit the Alert to say What a wonderful day! after the selected item. Type a plus
sign (+) in the parentheses after Item(1), and enclose the new phrase (a string) in
quotes.
Application.Alert(Time.SelectedList.Item(1)+" What a
wonderful day!")
Summary
When adding scripts to EIS controls, remember these points:
■ Select the control and choose EIS→Scripts to open the Script Editor. [F8]
■ The object label (or title), displayed in Run mode, is set in the object’s Properties
dialog. One way to access the Properties dialog is by double-clicking the object.
■ The object name, displayed in the Object browser, is set in the Properties dialog.
■ BrioQuery constants (for example BqChartType) are accessible through the Object
browser in the Constants collection.
The previous chapters introduced the BrioQuery object model, EIS sections
and controls, and adding JavaScript scripts to enhance the functionality of a
BrioQuery document.
This chapter reviews JavaScript syntax. It contains:
■ Basic JavaScript Syntax
■ JavaScript Code Structure
■ JavaScript Operators
■ Variables
■ Reserved Words
4-1
Basic JavaScript Syntax
JavaScript is a powerful programming language with three basic syntax rules,
shown in Table 4-1.
Rule Example
JavaScript is case sensitive. Alert is not the same as alert.
Strings must be in quotes. The following two statements define a variable n as the string Brio, and then insert the
string value as an argument for the Alert method. The alert says Brio.
var n="Brio";
Application.Alert(n);
The following two statements define n without quotes. The alert generates the error
Brio is not defined because Brio is not a recognized JavaScript term.
var n=Brio;
Application.Alert("The company name is "+n);
Legal names (for variables, func- The first character must be a letter or an underscore(_),
tions, and objects): not a number. Subsequent characters may be any letter or
digit or an underscore, but not a hyphen, period, or
■ Start with a letter and space.
continue with only letters,
numbers, or an underscore sample legal name: _letters123
■ Do not use reserved words Names need to be unique in context. An EIS section cannot have two drop-down boxes
■ Are unique in context with the same name, a function cannot have two variables with the same name, a
document cannot have two sections with the same name
See “Reserved Words” on page 4-17 for a complete list of reserved words.
generates the following error because the separator between ActiveDocument and
Sections is missing:
ActiveDocumentSections is not defined
Methods (and Functions): Activate() does not take arguments, but the parentheses are still required.
■ Separate from the object path with ActiveDocument.Sections["RevSummary"].Activate()
a period (.) The Add() method requires a single argument, included in the parentheses.
■ Include parentheses for arguments Time.Add(TextBox1.Text)
The Alert() method requires at least one argument and allows for multiple optional
arguments. Multiple arguments are separated by commas.
Application.Alert(TextBox1.Text,"Text Box")
- Subtraction
-= Subtraction and assign resulting value
* Multiplication
*= Multiplication and assign resulting value
/ Division
/= Division and assign resulting value
✏ Note The following exercise uses the BrioQuery file Sample3.bqy and the RevByTime chart used in
“Associating Scripts with Radio Buttons” on page 3-7. You can use any BrioQuery document
that includes a chart.
Example Insert a new EIS section in Sample3.bqy. Add a line chart and two buttons
titled Comparison and Assignment.
Add a JavaScript script to the Comparison button to compare the type of chart to
bqChartTypeVerticalBar and open an alert that displays the result of the
comparison. Test the comparison button. What does the alert say?
Script the Assignment button to change the chart type to bqChartTypePie. Try
the comparison button again. What does the alert say now?
✰ Tip Both JavaScript scripts act on the actual chart, not the view of the chart in the
EIS section.
The script for the Comparison button uses == to test if ChartType matches
bqChartTypeVerticalBar. The alert displays true if they match, false if they
don’t match.
The Assignment button’s script uses = to set RevByTime’s ChartType property
equal to bqChartTypePie. The chart changes to a pie chart.
1 Open Sample3.bqy and insert a new EIS section. Rename it Equal EIS.
Refer to“Creating a New EIS Section” on page 3-2 for information on
renaming a section.
2 Add two command buttons by dragging them from the Catalog pane to the Content pane.
3 Double-click one button and change the Title to Comparison.
4 Double-click the other button and change the Title to Assignment.
5 Drag the RevByTime chart from the Catalog pane to the Content pane.
Verify that the chart is a vertical bar chart. (To verify and/or change the chart
type, choose Format → Chart Type → Vertical Bar in the RevByTime section.)
In Run mode, click the Comparison button. The alert displays true if the chart
is a vertical bar chart, false if the chart is any other chart type. [Ctrl+D]
1 In Design mode, select the Assignment button and choose EIS→Scripts. [F8]
✏ Note The following exercise adds a script to the file Sample3.bqy to open the Brio
Enterprise 6 - What’s New.bqy file. You can use any two BrioQuery documents for
this exercise.
Example Add a command button and a script to open a specific BQY document.
Verify where the file is on your system, and copy the path to this file from your
desktop. Escape the backslash in the directory path.
1 Open Sample3.bqy and insert a new EIS section. Rename it Strings EIS.
Refer to“Creating a New EIS Section” on page 3-2 for instructions on
renaming a section.
2 Drag a command button from the Catalog pane to the Content pane.
3 Select the command button and choose EIS→Scripts.
5 Switch to the desktop and find and copy the path (not the file name) to the file you wish
to open.
For the Brio Enterprise 6 - What’s New.bqy document, the default
path is C:\Program Files\Brio\BrioQuery\Samples.
7 Copy the file name and paste it at the end of the path in the current script.
a. Switch back to the desktop and copy the exact file name.
b. Return to BrioQuery and open the Script Editor on the command button.
c. Click after the last slash in the path, before the ending quote mark, and
paste the file name.
The script should look similar to:
Documents.Open("C:\\Program Files\\Brio\\BrioQuery\\Samples\\Brio Enterprise 6 -
What's New.bqy")
Text boxes, list boxes, and drop-down boxes return string values, not numbers.
If these strings are to be treated as numbers, JavaScript needs to be told to
“parse” (change the value of) the string into a number.
JavaScript has two methods for parsing strings into numbers:
■ parseInt() converts a string into an integer
■ parseFloat() converts a string into a floating point number
✏ Note Any BrioQuery document can be used for the following exercise.
Example In Design mode, add three text boxes and a command button to a new or existing
EIS section in Sample3.bqy, similar to Addition of Strings in Figure 4-2. Script
the command button to add the values of the first and second text boxes, return-
ing the result in the third text box.
Enter numbers in both the first and second text box and click the button. What is
the result?
1 In Design mode, drag a text box from the Catalog pane to the Content pane of a new or
existing EIS section.
✰ Tip BrioQuery allows copying and pasting of control objects only when the
Console window is closed, and only within the same document section.
6 Copy and paste the operand1 text box again and move it to the right of operand2.
BrioQuery automatically renames the new text box operand3.
To avoid typing errors, use the Object browser to navigate to EIS Objects, and
then select the Text property for each text box. Type only the = and +
operators.
✏ Note The following exercise continues from the previous one, but changes the script to add instead
of concatenate strings.
✏ Note ■ There is no method to distinguish explicitly between integer values (for example, 2) and
real (floating point) numbers (for example, 3.14.). In addition, there is no date data type.
However, you can use the Date object to handle date manipulations.
Variables 4-13
Declaring Local Variables
Use the term var to declare a new local variable.
var variable
A local variable is available only to the function or event handler script that
defines it, and cannot be accessed by another function or event. Once a name
is declared, it is assigned a value of null or undefined unless you assign a
specific value when declaring the variable name.
In the BrioQuery object model, it is helpful to adopt a naming convention that
starts with the type of object and includes the action or value. For example, a
list box containing StoreType data values could be named Lbx_storeType.
Caution ! JavaScript is case sensitive. A variable named Lbx_StoreType is not the same
as lbx_StoreType.
✏ Note Global variables are not available between BQY documents when using the Web client (that is,
the Insight plug-in) because Web browsers do not support them. Cookies should be used to
write variables shared between documents.
To prevent this error, assign a specific value to the global variable when
declaring it:
gvariable=25
You should consider some naming convention to distinguish global variables
from local variables, such as an extra “g” at the beginning of the global variable
name.
Assigning Values
The JavaScript assignment operator (=) assigns a value to a variable. The type
of data can be a number (the number of items or the result of a calculation), an
object (a string or an object path), or a boolean (true or false).
var Result = 15 // The value 15 is assigned to
the variable named Result
var Result = Result + 2 // The variable Result is incremented by 2
The data type can be changed at any time. For local variables, the data type is
null or undefined until a value is assigned. Once a value is assigned, the
variable’s data type defines whether the + operator concatenates or adds; to
add, all values must be numeric. See “Concatenating versus Adding” on
page 4-10 for converting a string to a number.
Variables 4-15
JavaScript is a dynamically typed language. This means that you do not need to
specify the data type of a variable when you declare it. Data types are converted
automatically as needed during script execution. This allows you to reuse
variables with different data types. For example, if you define a variable, such
as:
var version = 6.5
Later, you can assign a string value to the same variable:
version = "BrioQuery 6.5"
Since JavaScript is dynamically typed, this assignment does not cause an error
message.
In expressions involving numeric and string values with the + operator,
JavaScript converts numeric values to strings. For example, consider the
following statements:
// returns The version is 6.5
x = "The version is " + 6.5
In statements that involve other operators, JavaScript does not convert
numeric values to strings, for example:
"50" - 5 // returns 45
"60" + 5 // returns 65
(C on tinu ed)
✏ Note The exercises in this chapter use the file Sample1mod.bqy and the Limits EIS, Limits Query,
Limits Results, and Limits Chart sections.
5-1
Using Drop-Down Boxes
Drop-down boxes are typically used to list multiple values from which users
can make one selection.
You can use limits that were set in other sections to limit the values available in
drop-down boxes.
For example, Activate the Limits Results section of Sample1mod.bqy and
double-click Territory on the Limit line. There are seven available Territory
values in the database, but only three are selected in the Show Values list (Asia,
North America, and South America). This means the Results section displays
only products sold in Asia, North America, and South America.
In the Limits EIS section, the territories shown in the drop-down box also are
limited to these three selected values.
This chapter shows you how to create a script that allows the user to view the
pie chart according by territory as selected from the drop-down box .
✏ Note Use the file Sample1mod.bqy to add a script to DropDown1 in the Limits EIS section.
1 Open Sample1mod.bqy, activate the Limits EIS section, and change to Design mode.
2 Double-click DropDown1 to display the Properties dialog box, change the Name field to
drp_Territory, and then click OK.
✏ Note This rest of this exercise shows how to click through the object model to associate a script to
drp_Territory, a Limits EIS object. The script will apply the Item method, using a pointer to the
selected item (SelectedIndex) as the method argument.
6 Place the cursor inside the parentheses of the Item method, and then double-click
SelectedIndex from the Properties folder.
7 Type a semicolon (;) and a return [Enter] at the end of the line.
The line now reads:
drp_Territory.Item(drp_Territory.SelectedIndex);
8 Add a new statement using the Alert method with the drop-down selection as its
argument.
a. Type Alert() or double-click Alert from within Application→Methods.
b. Copy the first JavaScript statement and paste it inside the Alert method’s
argument parentheses.
c. Delete the semicolon from within the argument.
d. Type a semicolon (;) and return [Enter] at the end of the statement.
The Alert method displays a popup message that contains the name of the item
selected from the drop-down box.
Characteristic Explanation
Name Names must start with a letter or underscore. Subsequent characters may include letters,
numbers, or the underscore (drp_Territory is a legal name). A variable name cannot be a
reserved word (new is a reserved word, but newVariable is not).
Use a JavaScript var statement to declare a variable name before it is used. For example:
var newVariable;
In the above statement, JavaScript reserves the name newVariable, with a value of null or
undefined.
Value Values are assigned to variables with the JavaScript assignment operator (=). Any type of data
can be assigned to a variable: an object (a string, a user selection, an object path), a boolean
(true or false), or a number. For example:
var newVariable;
newVariable=true;
The value can be assigned in a separate statement like above, or in the same statement that
declares the variable name. For example:
var newVariable=true;
newVariable (and its value) is available only within the script or function that declares it,
preventing accidental changes from other scripts using the same variable name.
This exercise uses a variable to hold the user’s selection (the first line of the
script from the preceding exercise). A variable can be declared in one statement
and the value assigned in another:
var Selection;
Selection=Territory.Item(Territory.SelectedIndex);
✏ Note The following exercise continues from the previous section. This exercise alters the script in the
drop-down box (renamed drp_Territory) in the Limits EIS section of Sample1mod.bqy.
This declares a new variable Selection, and assigns the user’s selection to it.
If the alert displays “undefined”, the alert argument has not been assigned a
value. This is most likely a typo: If the variable is defined with a capital “S” for
Selection, the variable in the alert argument must also have a capital “S”.
The exercises in this section used JavaScript and the Brio object model to
access a user’s selection in a drop-down box. The Item method, with
SelectedIndex as the argument can be acted on directly, or a variable can
hold the selection, clarifying the JavaScript logic: get the selection, act on it.
Statements to modify
an existing limit. Each
statement ends with a
semicolon.
Commented statements
ignored by JavaScript.
Multi-line comments
start with /* and end
with */
Caution ! There must be a limit on the Limit Line for the script to execute. If there is no
existing limit, an “uncaught exception” error will be recorded in the Console
window and the rest of the script will not execute.
✏ Note This exercise assumes that the Script Editor for the drop-down box drp_Territory is open. If it is
not, open the file Sample1mod.bqy and activate the Limits EIS section. In Design mode,
select the drop-down box drp_Territory, and then right-click to select Scripts.
3 Type a semicolon (;) at the end of the statement, and then press [Enter].
ActiveDocument.Sections["Limits Results"].Limits[1].SelectedValues.RemoveAll();
This step adds the selection the user chose as the value for the limit.
ActiveDocument.Sections["Limits Results"].Recalculate()
ActiveDocument.Sections["Limits Results"].Limits[1].SelectedValues.RemoveAll();
ActiveDocument.Sections["Limits Results"].Limits[1].SelectedValues.Add(Selection);
ActiveDocument.Sections["Limits Results"].Limits[1].Operator=bqLimitOperatorEqual;
ActiveDocument.Sections["Limits Results"].Recalculate()
Several words in the last four statements are repeated in each line—the path to
Limits[1] and the path to Limits Results section. A variable can hold these
objects (the repeated words), which makes the JavaScript logic easier to read.
✏ Note This following exercise edits the JavaScript associated with drp_Territory from the previous
exercise (in the Limits EIS section of Sample1mod.bqy) to use a variable for the object path.
Exercise Refer to Figure 5-1 on page 5-9 and study the last two sets of statements—using a
variable for the object (path). Select one of the sets to enter in Design mode.
Start by commenting out the last four statements in your current script by typing
/* before the first ActiveDocument.Sections statement and */ after the
fourth one. This will make the four lines comment lines that JavaScript does not
execute.
Enter one set of statements with a variable newChoice holding the object path. Do
not enclose these statements in comments.
Test the new statements in Run mode. Selecting an item in the drop-down box
should still change the pie chart results.
Caution ! Don’t end an object path value with a period. The syntax error “missing name
after . operator” refers to an incomplete object model path.
The first set of commented statements in Figure 5-1 creates a variable equal to
navigating from ActiveDocument to Limits[1].
Exercise Change the existing limit in the Limits Query section based on the drop-down
selection. Use the Process method instead of the Recalculate method to
update the query results.
ActiveDocument.Sections["Limits Query"].Process()
To test the script, a database connection is needed. Use Brio 6.0 Sample
1.oce. Leave the Host Name and Host Password blank.
1 Activate the Limits EIS section by clicking the title in the Section pane.
2 Toggle to Design mode and choose EIS→Scripts to open the Script Editor on the active
section.
The variable topDrill now holds the chart fact Product Line.
The same JavaScript can be added to a command button, so the user can
choose to return the chart to Product Line at any time.
✏ Note The following exercise hides the application Status bar, the Format toolbar, and the document
Section/Catalog pane. There are other toolbars accessible in each of these areas of the
BrioQuery object model. Use this exercise as a starting point to accessing the various toolbars.
To hide toolbars:
The menu bar can be accessed at this level of the object model, with
ShowMenuBar property.
b. In Application→Toolbars→Formatting→Properties, double-click Visible,
and then type =false. End the statement with a semicolon and a return.
Toolbars["Formatting"].Visible=false;
The Section title bar can be accessed at this level of the object model with
the ShowSectionTitleBar property.
6-1
Understanding Control Structure Syntax
The basic syntax of a control structure is:
type of control ( control statement )
{ block of statements to execute, based on the value of the control statement ; }
■ Parentheses hold the control statement and are a required part of the
control structure syntax.
■ Curly brackets delineate the control statement block or control body.
■ Each statement in the body of the control structure ends with a semicolon.
The result of the control statement defines whether or not the statements in
the control block are executed. Statements outside the control block are always
executed. Table 6-1 describes three JavaScript control structures and their
syntax.
If…else An if...else tests the condition of a control if (condition returning true or false)
statement, using the comparison or logical {
operators in Table 4-3 on page 4-4. statements;
}
The body of the if executes only when the condition else
tests true. The body of the else executes if the {
condition tests false. statements;
}
statements executed after control;
F i g u re 6 - 1 Check Boxes Used to Change Between Two States: Pie Chart and Line Chart
JavaScript tests whether the Checked property of the check box matches true.
When the condition test returns true (yes, the Checked property matches
true), it executes the body of the if statement block. When the condition test
returns false (no, the Checked property does not match true), it skips the if
statement block.
With this JavaScript logic, when the check box is selected, the pie chart changes
to a line chart. When the check box is cleared, the chart does not change
because the condition test (chk_ChartType.Checked==true) is false.
Use an if...else statement to expand the if to change the chart back to a pie chart
when the condition test is false. JavaScript tests the Checked property of the
check box. When the check box is checked, the body of the if executes. When
the check box is not checked, the body of the else executes.
✏ Note The following exercise adds scripts to new control objects in the Limits EIS section of
Sample1mod.bqy.
1 Add a new check box to Limits EIS, change the Name to chk_ChartType, and change the
Title to Show Chart As A Line Chart (use the Properties dialog box).
2 Open the Script Editor on the new Show Chart As A Line Chart check box. [F8]
3 Type if (), a return [Enter], an open curly bracket ({), two returns [Enter], and a close
curly bracket (}).
if ()
{
The parentheses hold the controlling condition test. The curly brackets are for
the body of the if, executed only when the condition tests to true.
4 Click inside the control part of the if, then use the Object browser to navigate to Limits
EIS Objects→chk_ChartType→Properties and double-click Checked.
if (chk_ChartType.Checked)
{
The Description pane shows Property Checked as Boolean. There are two
Boolean values: true and false.
Verify that there are two equal signs, meaning match true, not assign the value
true. Condition statements use the comparison or logical operators in
Table 4-3 on page 4-4.
6 Add a statement in the body of the if statement to change the Limits Chart to type Line.
a. Click inside the body of the if (on the blank line between the curly
brackets), then use the Object browser to navigate to
Application→ActiveDocument→Sections→Limits Chart→Properties
and double-click ChartType.
7 On a new line, after the close curly bracket for the if, type else, a return [Enter], an open
curly bracket ({), two returns [Enter], and a close curly bracket (}).
}
else
{
The curly brackets are for the body of the else, executed only when the
condition tests false.
8 Click in the body of the else and use the Object browser to add a statement to change
the Limits Chart to a pie chart.
else
{
ActiveDocument.Sections["Limits Chart"].ChartType=bqChartTypePie;
}
Caution ! Use one equal sign when assigning a value, use two equal signs when testing if
the value matches true.
✰ Tip The check box and its script show the chart legend when the check box is
selected and its state becomes “checked.” Since the chart legend is already
showing, the check box must be cleared to hide the legend the first time the EIS
section is used.
The initial state of the chart and the check box can be set with JavaScript
statements associated with the OnActivate event of the EIS section:
ActiveDocument.Sections["Limits Chart"].ShowLegend=true;
chk_ShowLegend.Checked=true;
These two statements set both ShowLegend and the check box Checked
properties to true when the section is activated.
switch if...else
switch (CheckBox.Checked) if (CheckBox.Checked==true)
{ {
case true : set the chart type to a line chart
set the chart type to a line chart }
case false : else
set the chart type to a pie chart {
} set the chart type to a pie chart
}
1 Add a new check box to Limits EIS, and use the Properties dialog box to change the Title
to Switch Chart To Line Chart and the Name to chk_ChartType2.
2 Open the Script Editor on the new Switch Chart To Line Chart check box. [F8]
3 Type switch (), a return [Enter], an open curly bracket ({), two returns [Enter], and a
close curly bracket (}).
switch ()
{
The parentheses are for the expression. The curly brackets are for the body of
the switch.
4 Click inside the expression parentheses, and then use the Object browser to navigate to
Limits EIS Objects→chk_ChartType2 Properties) and double-click Checked.
switch (chk_ChartType2.Checked)
{
The Description pane shows Property Checked as Boolean. Since there are two
Boolean values (true and false), we will provide two case values.
5 In the body of the switch, add the case for a value of true, and the statement to change
the Limits Chart to a Line chart.
a. Click inside the body of the switch (on the blank line between the curly
brackets), type case true : and a return [Enter].
b. Navigate to Application→ActiveDocument→Sections→Limits Chart→
Properties and double-click ChartType.
The Description pane shows Property ChartType as BqChartType. Find the
collection for BqChartType in the object model under Constants.
The case for true changes the chart to a line chart and ends with a break
statement so other cases are ignored. The extra return is for readability.
6 Add the case for a value of false, and the statement to change the Limits Chart to a pie
chart.
a. Click inside the body of the switch (on the blank line above the closing
curly bracket), type case false : and a return [Enter].
b. Use the Object browser to navigate to Application→ActiveDocument→
Sections→Limits Chart→ Properties and double-click ChartType.
c. After ChartType, type an equal sign (=), and then navigate to
Constants→BqChartType and double-click bqChartTypePie.
d. Type a semicolon (;) at the end of the statement, and a return [Enter].
e. Type break; and a return [Enter].
switch (chk_ChartType2.Checked)
{
case true :
ActiveDocument.Sections["Limits Chart"].ChartType=bqChartTypeLine;
break;
case false :
ActiveDocument.Sections["Limits Chart"].ChartType=bqChartTypePie;
break;
}
Verify that there is a close curly bracket after the last case.
Example DropDown1 (under Select View) of The Plan and Actual section of
Sample2mod.bqy allows the user to change the Costs, Sold, and Revenue charts
to display results in terms of Planned vs. Actual, Planned, or Actual.
DropDown1
selection options
The OnClick event for DropDown1 creates a variable for the user choice. Then,
depending on the value of choice, the JavaScript goes through each chart and
removes all facts, and adds the appropriate facts. This is done with an if...else
control structure.
In Design mode, with the Console window closed, copy and paste DropDown1
and rename the new one DropDown1_switch. Change the if...else control struc-
ture to a switch. (See “Controlling Chart Facts with if...else” on page 6-12 and
“Controlling Chart Facts with switch” on page 6-13 for the finished JavaScript
scripts.)
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Plan');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Actual');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Plan');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Actual');
}
else
if (choice=='Planned')
{
ActiveDocument.Sections["PlanActualCostsChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Plan');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Plan');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Plan');
}
else
if (choice=='Actual')
{
ActiveDocument.Sections["PlanActualCostsChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Actual');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Actual');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Actual');
}
switch (choice)
{
case 'Planned vs. Actual':
ActiveDocument.Sections["PlanActualCostsChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Plan');
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Actual');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Plan');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Actual');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Plan');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Actual');
break;
case 'Planned':
ActiveDocument.Sections["PlanActualCostsChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Plan');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Plan');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Plan');
break;
case 'Actual' :
ActiveDocument.Sections["PlanActualCostsChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualCostsChart"].Facts.Add('Costs Actual');
ActiveDocument.Sections["PlanActualSoldChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualSoldChart"].Facts.Add('Units Sold Actual');
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.RemoveAll();
ActiveDocument.Sections["PlanActualRevenueChart"].Facts.Add('Revenue Actual');
break;
}
This chapter introduces the JavaScript for loop to manipulate multiple objects
with minimal scripting statements. It contains:
■ Using for Loops
■ Filling Boxes with Multiple Values
■ Accessing Selected Values
■ Creating Results Limits
■ What’s Next
7-1
Using for Loops
List boxes and drop-down boxes contain multiple values. These values can be
added at design time or with a JavaScript script and the Add method. For
example, to add the number 1 to a DropDown1, the JavaScript statement is:
DropDown1.Add(1);
This script repeats the same object model method until all the values are
added—with a different value each time. This could also be accomplished with
a for loop:
for (var i=1; i<=4; i=i+1)
{
DropDown1.Add(i);
}
The variable i holds the first value (or a pointer to the first value). It is then
tested against the total number of values. The test, is i less than or equal to the
total number of values (with a true or false result), controls whether the
statements inside the curly brackets execute. The Add method uses i as the
argument: the first time use the first value, the second time use the second
value, and so on. Once the statements in the body execute the first time, i is
then incremented by 1 with i=i+1 and retested. The Add statement executes
only while i<=4.
A JavaScript for loop (spelled with a lower-case “f ”), and its three control
statements, uses this syntax:
for ([counter]; [condition-test]; [counter-increment])
{
object_model_path.method(counter);
}
■ Parentheses hold three control statements and are a required part of the
syntax. Control statements are separated with a semicolon.
■ Curly brackets delineate the control statement block (the body of the loop).
■ Each statement in the body of the for ends with a semicolon. There can be
multiple statements.
✰ Tip Typing a comma instead of a semicolon, or testing a condition that will never
be false causes an infinite loop. To stop an infinite loop, type [Alt+End]
simultaneously.
This script uses Console.Writeln to verify the value of the variable. The list
box should be filled with the same number of values.
Writeln is pronounced Write Line and spelled with a lower-case “L”. In
previous exercises, Alert was used for testing the state of objects and variables.
Writing messages to the Console window does not require user interaction and
keeps a record of each line as it is written.
The Console window can also be used to track the execution of the script.
Adding console messages before and/or after each step can be helpful in
troubleshooting a script that is not working.
✰ Tip There are two methods to send messages to the Console window: Write and
Writeln. Writeln ends each message with a line return. The Write method does
not end with a new line; each message starts immediately after the preceding
one.
✏ Note The following exercise uses the MyEIS section in Sample2mod.bqy. The exercise adds a
JavaScript to the Fill List Box button to “fill” the list box List_StoreType with available values
from the first limit (Limits[1]) of the PlanActualQuery section.
Exercise: Using a for Loop to Fill a List Box with Limit Values
To fill a list box with available limit values:
1 In Design mode, open the Script Editor on the Fill List Box command button. [F8]
2 Declare a variable count and assign the Count property of AvailableValues from the first
limit in the PlanActualQuery section.
a. Type var count to declare the variable name.
b. End the statement with a semicolon (;) and a return [Enter].
c. Type count= to assign the property in the next step.
d. Use the Object browser to navigate to Applications→ActiveDocuments→
Sections→PlanActualQuery→Limits→1→ AvailableValues→Properties)
and double-click Count.
e. End the statement with a semicolon (;) and a return [Enter].
var count;
count=ActiveDocument.Sections["PlanActualQuery"].Limits[1].AvailableValues.Count;
The message in the Console window displays the number of items that should
be added to the box.
Before adding a new set of values to the list box, old values are deleted.
The value of i is set to correspond to the first item in the AvailableValues array.
The condition test verifies that i is <= to the total number of items.
6 Click in the body of the for loop (between the curly brackets), and enter the statement to
add (to the list box) the available values from the first limit.
a. Navigate to MyEIS Objects→List_StoreType→Methods and double-click
Add.
b. As the argument for the Add method, navigate to
Applications→ActiveDocuments→ Section →PlanActualQuery→Limits
→1→AvailableValues and double-click 1.
List_StoreType.Add(ActiveDocument.Sections["PlanActualQuery"].Limits[1].Available
Values[1]);
Exercise Fill the drop-down box in MyEIS section of Sample2mod.bqy with the available
values from the second existing limit (Limits[2]) of the PlanActualQuery section.
The script to fill a drop-down box is associated with the Fill Drop-Down Box
button and shown below.
/* Create a local variable for the count of values */
var count;
count=ActiveDocument.Sections["PlanActualQuery"].Limits[2].AvailableValues.Count;
/* Test the variable to compare with the number of values added to box */
Console.Writeln("total available values "+count);
where :
listboxobject is the name of the list box
1 is the first item in the SelectedList array.
✰ Tip It does not matter what order the list box values are selected in, SelectedList
stores them in the same order they appear in the list box, not in selection
order.
Use a JavaScript for loop to access each value in SelectedList. Initialize the
control variable to i (to match the first position in the array). Set the condition
to test if the variable is less than or equal to the count of values.
The JavaScript script to write the selected values from List_StoreType to an
alert is:
/* Define a local variable for the count of selections */
var countSelections;
countSelections=List_StoreType.SelectedList.Count;
✏ Note The following exercise assumes the list box List_StoreType (in the MyEIS section of
Sample2mod.bqy) contains three values. See “Filling a List Box with Available Values” on
page 7-4 for the JavaScript to add the values.
If you have not already done so, it is best to save the document before starting this exercise.
1 In Design mode, open the Script Editor on the Display Selections button. [F8]
2 Define a local variable (countSelections) for the total count of selected items.
Use the Count property of SelectedList under List_StoreType.
var countSelections=List_StoreType.SelectedList.Count;
The value of countSelections serves as the condition test in the if and the for
statements.
✏ Note The following step is an additional statement providing feedback on the number of selected
items—even if the Alert does not display.
5 In the body of the if, add a for loop with a control variable (i) set to 1, a condition test
i<= countSelections, and an increment for i (i++).
var countSelections=List_StoreType.SelectedList.Count;
if (countSelections>0)
{
for (i=1; i<=countSelections; i++)
{
}
}
7 Click OK to save the script and close the Script Editor, then toggle to Run mode.
8 Display the Console window (View →Console Window) and test the script by clicking on
the Display Selections button.
If nothing is selected in the list box when the button is clicked, the Console
window displays the message “number of selected items: 0”.
If multiple items are selected in the list box (hold [Shift] or [Ctrl] to select
multiple items), the Console window displays the number of selections and an
alert displays the first value in the SelectedList array. Click OK in the alert to
display the next item in the array, until all selections have been displayed.
✰ Tip When using list boxes for user selections, offer the capability of clearing the
selections. Use one of the following scripts with the OnClick event of a new
command button or a text label (set the Font property of a text label to
Underline):
To clear selections in a list box:
var clear=List_StoreType.SelectedList.Count;
for(i=1; i<=clear; i++)
{
List_StoreType.Unselect(List_StoreType.SelectedList.
ItemIndex(1));
}
OR
List_StoreType.Enabled=false; List_StoreType.Enabled=true;
The statements above disable the list box which clears all selections, then
enable it.
/* create a variable to hold the column name, create a new limit with the name */
var nameLimit; var newLimit;
nameLimit=ActiveDocument.Sections["PlanActualResults"].Columns["Territory"].Name;
/* update results */
ActiveDocument.Sections["PlanActualResults"].Recalculate()
✏ Note The following exercise uses the MyEIS section in Sample2mod.bqy to create a single limit on
the Limit line of PlanActualResults section. This exercise assumes the drop-down box
drp_Territory contains seven Territory values. See “Filling a Drop-Down Box with Available
Values” on page 7-7 for the JavaScript to add the values.
1 In Design mode, open the Script Editor on the drp_Territory drop-down box. [F8]
2 Remove all existing limits from the Limit line of the PlanActualResults section.
a. Use the Object browser to navigate to ActiveDocument→Sections→
PlanActualResults→Limits→Methods and double-click RemoveAll.
b. Type a semicolon (;) and a return [Enter] at the end of the statement.
This statement removes all limits from the Limit line.
ActiveDocument.Sections["PlanActualResults"].Limits.RemoveAll();
3 Declare two new variables, nameLimit and newLimit, ending each declaration with a
semicolon (;).
var nameLimit; var newLimit;
4 Using the Object browser, assign the Name property of the PlanActualResults Territory
column to nameLimit.
a. Type nameLimit= , then navigate to PlanActualResults→Columns→
Territory→Properties and double-click Name.
b. Type a semicolon (;) and a return [Enter] at the end of the statement.
nameLimit=ActiveDocument.Sections["PlanActualResults"].Columns["Territory"].Name;
The CreateLimit method creates a new limit object with the same methods and
properties that all limit objects have.
The new limit is not visible in the Object browser (until the script executes).
Step 6 and Step 7 use the SelectedValues.Add method and Operator property
common to all limit objects.
c. Type a semicolon (;) and a return [Enter] at the end of the statement.
8 Add the new limit object (newLimit) to the limit line of the PlanActualResults section.
a. Navigate to ActiveDocument→Sections →PlanActualResults→ Limits→
Methods and double-click Add.
ActiveDocument.Sections["PlanActualResults"].Limits.Add();
b. Type the new limit object (newLimit) as the argument to the method.
ActiveDocument.Sections["PlanActualResults"].Limits.Add(newLimit);
c. Type a semicolon (;) and a return [Enter] at the end of the statement.
The PlanActualResults section now has one limit with an operator and a user-
selected value.
10 Click OK to save the script and close the Script Editor, then toggle to Run mode and test.
Making a selection from the drop-down box creates a new limit, and
recalculates the results. The limited results data is reflected in the chart.
Recalculating results (or tables) updates the displayed results according to the
local Limit line parameters. A local limit does not delete data from the local
data set (resulting from the original query), it just limits the display of the data.
The same basic steps are used to create a new local limit from list box
selections. Since a list box allows multiple selections, the script uses a for loop
to add all the selections to the limit.
✏ Note The following exercise uses the MyEIS section in Sample2mod.bqy to create a single limit on
the Limit line of PlanActualResults section. This exercise assumes the list box List_StoreType,
contains three Store Type values. See “Filling a List Box with Available Values” on page 7-4 for
the JavaScript to add the values.
Summary
When manipulating multiple objects, remember these points:
■ Use JavaScript for loops to execute the same statements with multiple values.
■ Use if statements to skip value manipulation statements when there are no values,
thus avoiding JavaScript errors.
■ Send messages to the Console window to pinpoint exactly what the script is doing:
and which statements are executing with what values.
8-1
Scripting Applications in BrioQuery
When you use BrioQuery to create an application, the application can
comprise one or more BrioQuery documents and may contain one or more of
the components listed in Table 8-1.
Component Description
EIS Shapes and Controls User Interface components that enable users to interact with the
application.
Computed Columns Scripts that run within the context of a Results or Table section
column.
Custom Menu Items Special menu items that allow scripts to run from any section.
On Windows platforms, you can launch script commands from the command
line. Script commands launched from the command line require the
-jscriptcmd flag. For example, to launch the BrioQuery application, you
would type:
brioqry.exe –jscriptcmd "Application.Documents.Open ("c:\\temp\\briodoc.bqy")"
Defining Functions
A function definition consists of the function keyword, followed by:
■ The name of the function
■ A list of arguments to the function, enclosed in parentheses and separated
by commas
■ The JavaScript statements that define the function, enclosed in curly
braces { }
The function square takes an argument called number. The function consists
of one statement that indicates to return the argument of the function
multiplied by itself. The return statement specifies the value returned by the
function, for example:
return number * number
All parameters are passed to functions by a value. The value is passed to the
function, but if the function changes the value of the parameter, the change is
not reflected globally or in the calling function. If you pass an object as a
parameter to a function and the function changes the object’s properties, that
change is visible outside the function. For example:
function myFunc(theObject) {
theObject.make="Toyota"
}
mycar = {make:"Honda", model:"Accord", year:1998}
x=mycar.make // returns Honda
myFunc (mycar) // pass object mycar to the function
y=mycar.make // returns Toyota (property was changed by the function)
Example 1 // MyButton
function square(value)
{
return value*value;
}
Alert (‘’The square of 3 equals ‘’+ square(3))
// YourButton
var retVal = square(3)
// generates a runtime error
Alert (‘’The square of 3 equals ‘’+ retVal)
By explicitly defining the square function within the context of the YourButton
object, you make the function visible to the scripts that are running behind
that button. Using this syntax is not restricted to objects within EIS. Any object
from the object model can be used in conjunction with the with statement.
Example 3 shows another way to accomplish the same behavior as Example 2.
Example 3 // MyButton
Function square(value)
{
return value*value;
}
Alert (“The square of 3 equals “+ square(3))YourButton.square
= square;
// YourButton
var retVal = square(3)
Alert (“The square of 3 equals “+ retVal)
Example 4 // MyButton
Function square(value)
{
return value*value;
✏ Note Use caution when working with global variables. These are visible throughout BrioQuery,
including to computed column calculations and Report section expressions.
Conditional Statements
A conditional statement is a set of commands that executes if a specified
condition is true. The conditional statements supported by JavaScript are:
■ if...else Statements
■ Inline if Statements
■ switch Statements
Example 5 if (condition) {
statements1
}
else {
statements2
}
The condition can be any JavaScript expression that evaluates to true or false.
The statements to be executed can be any JavaScript statements, including
deeper nested if statements. If you want to use more than one statement after
an if or else statement, you must enclose the statements in curly braces {}.
Do not confuse the primitive Boolean true and false values with the Boolean
object true and false values. Any object whose value is not undefined or null,
including a Boolean object whose value is false, evaluates to true when passed
to a conditional statement, for example:
var b = new Boolean(false);
if (b) // this condition evaluates to true
✏ Note The words if and else must be in lowercase. If you type an uppercase “i” or “e”, you get a
“missing syntax” error. A then statement is implied for values enclosed in the curly braces “{ }”.
If you type the word “then” in a statement, an error message is returned.
where:
■ condition – An expression that evaluates to true or false
■ expr1, expr2d – Expressions with values of any type.
✏ Note You can eliminate the condition parentheses as shown below, but omitting the quotes for
strings may lead to problems:
(condition?'expr1':'expr2')
In this case, if the isMember variable evaluates to true, then the operator
returns the string Member. If isMember does not evaluate to true, then the
operator returns the string Not a Member.
You can also use the comparison operator:
((isMember == 'Yes' ) ? 'Member' : 'Not a member')
✏ Note When you open a version 5.5 document in the 6.2 version of BrioQuery and the document
contains computed columns with nested if...else statements, the Brio JavaScript engine will
convert the if...else syntax to the inline if statement syntax. The conversion process will not
alter the meaning or value of the original if...else statement.
switch Statements
A switch statement allows a program to evaluate an expression and attempts to
match the expression’s value to a case label. If a match is found, the program
executes the associated statement. Example 6 shows an example of a switch
statement.
Loop Statements
A loop is a set of commands that repeatedly executes until a specified
condition is met. JavaScript supports the following Loop statements:
■ for Statements
■ do...while Statements
✏ Note label is not itself a looping statement, but is frequently used with these statements. In
addition, you can use the break and continue statements within loop statements.
The for...in statement executes statements repeatedly but is used for object manipulation. For
more information, see “Manipulating Objects with JavaScript” on page 8-17.
for Statements
The for loop repeats until a specified condition evaluates to false. The
JavaScript for loop is similar to the Java and C for loop.
for ([initialExpression]; [condition];
[incrementExpression]) {
statements
}
do...while Statements
The do...while statement repeats until a specified condition evaluates to
false. A do...while statement looks as follows:
do {
statement
} while (condition)
while Statements
A while statement executes as long as a specified condition evaluates to true, for
example:
while (condition) {
statements
}
If the condition becomes false, the statements within the loop stop executing
and control passes to the statement following the loop.
The condition test occurs before the statements in the loop are executed. If the
condition returns true, the statements are executed and the condition is tested
again. If the condition returns false, execution stops and control is passed to
the statement following while.
In Example 8, the while loop repeats as long as n < 3:
Example 8 n = 0
x = 0
while( n < 3 ) {
n ++
x += n
}
After completing the third pass, the condition n < 3 is no longer true, so the
loop terminates.
In Example 9, the while loop is an infinite loop that never terminates; that is, it
executes forever because the condition never becomes false.
label Statements
A label provides a statement with an identifier that lets you refer to it elsewhere
in your program. For example, you can use a label to identify a loop, and then
use the break or continue statements to indicate whether a program should
interrupt the loop or continue its execution.
The syntax of the label statement looks like this:
label :
statement
The value of label may be any JavaScript identifier that is not a reserved word.
The statement that you identify with a label may be any type.
In Example 10, the label markLoop identifies a while loop.
Example 10 markLoop:
while (theMark == true)
doSomething();
}
Example 11 i = 0
n = 0
while (i < 5) {
i++
if (i == 3)
continue
n += I
}
Example 12 checkiandj :
while (i<4) {
Console.Writeln(i + "");
i+=1;
checkj :
while (j>4) {
Console.Writeln(j + "");
j-=1;
if ((j%2)==0);
continue checkj;
Console.Writeln(j + " is odd.");
}
Console.Writeln("i = " + i + "");
Console.Writeln("j = " + j + "");
}
break Statements
Use the break statement to terminate a loop, switch, or label statement.
When you use break with a while, do...while, for, or switch statement, break
terminates the innermost enclosing loop or switch immediately and transfers
control to the following statement.
When you use break within an enclosing label statement, it terminates the
statement and transfers control to the following statement. If you specify a
label when you issue the break, the break statement terminates the specified
statement.
The syntax of the break statement looks like this:
1. break
2. break [label]
The first form of the syntax terminates the innermost enclosing loop,
switch, or label; the second form of the syntax terminates the specified
enclosing label statement.
Example 13 iterates through the elements in an array until it finds the index of
an element whose value is theValue.
for...in Statement
The for...in statement iterates a specified variable over all of the properties of an
object. For each distinct property, JavaScript executes the specified statements.
A for...in statement looks like this:
for (variable in object) {
statements }
The function in Example 14 takes as its argument an object and the object’s
name. It then iterates over all the object’s properties and returns a string that
lists the property names and their values.
For an object car with properties make and model, the result would be:
car.make = Ford
car.model = Mustang
Example 15 var a, x, y
var r=10
with (Math) {
a = PI * r * r
x = r * cos(PI)
y = r * sin(PI/2)
}
✏ Note If you do not have the path fir the application specified in the Win 95/98 autoexec.bat
file, or Windows NT environment variables, then you must specify the full path to the
application, which limits the portability of the code. If the application path is specified in the
your autoexec.bat file or environment variables, you can just use the name of the
application’s executable file. It is recommended that you specify the browser executable path
in your autoexec.bat or environment variables.
OpenURL() Method
To avoid specifying a browser path or to use the same browser window, you can
use the OpenURL method.
The syntax for OpenURL is OpenURL(url, type of window) where url is
your ODS document, and type of window is either the current browser window
or a new browser window.
The code in Example 16 opens a new browser window.
The code in Example 17 uses the browser window that is currently open.
Normally, when the OnDemand Server returns the document list, the
Docname= parameter is a long string of what appears to be arbitrary
characters. This string is an encoded representation of the document name on
the server. The encoding is performed to support double-byte document
names for Asian languages. The OnDemand Server also supports an English
readable format in which to specify the document to load. The generic format
is:
http://webserverusername/ods-isapi/ods.ods?Method=getDocument&Docname=My+document
.bqyMy+document+display+name&JScript=enable
The format consists of the physical name of the document as stored in the
OnDemand Server documents directory, followed immediately by the display
name the document uses (with no space between these two names). Any spaces
in either name are replaced with plus (+) signs. In the example above, the
physical document name is My document.bqy and the name displayed in the
document list is My document display name. The names are case sensitive
and must exactly match exactly the name the OnDemand Server uses for the
documents to load. These names correspond to the File Name and Unique
Name fields given when registering the document for OnDemand Server
access.
To get the encoded document name, simply go into the ODS document list,
right-click a document, and select Copy Link Location. When you paste the
link, you see the actual name on the server. You can paste this name into the
Docname= part of your URL.
If you use the Shell method to move up an ODS document in the client
version of BrioQuery, Brio.Insight opens unless you have Brio.Quickview
specified in the plugins directory.
Accessing Cookies
Cookies are a common way to store bits of information to be used across
browser sessions and across different browser pages. A cookie is set by defining
a name and value for that cookie. (For a complete discussion of cookies, and
how to set them, refer to the Netscape Web site or any of the numerous general
JavaScript books available at most bookstores.) The following sample HTML
code displays a text entry box on an HTML page, and when pressing the link it
sets a cookie named ‘Region’ to hold the value entered into the text box. The
href in the link sends a message to the OnDemand Server to load the named
Brio document.
<html>
<script>
function setCookie(cookieName, cookieValue) {
document.cookie = cookieName + "=" + cookieValue + "; path=/"
}
</script>
<body>
<form name=cookieForm>
Region = <input name=Region> (clicking the link will set the cookie to whatever
you type in)<br>
<A href='http://djewett/ods-
isapi/ods.ods?Method=getDocument&Docname=Cookie+passing+sample.bqyCookie+passing+
sample&JScript=enable'
onClick="setCookie('Region', document.cookieForm.Region.value)">click here to
load the document</a>
</form>
</body>
</html>
✰ Tip You cannot embed OLE objects inside a BrioQuery document. Likewise,
BrioQuery is not an OLE Server that produces OLE objects you can embed in
OLE Containers.
Example 18 shows you how to invoke a new Excel Worksheet from a command
button created in an EIS section and write “Hello World” to rows 2 and 3 in
column B.
2 Specify the file name and location, and then click Save.
Space-Saving Variables
One exception to the Code Entry rule is: If you plan to repeatedly use an object
model path, define it as a variable to save space and keep your script compact.
For example, instead of typing:
ActiveDocument.Sections["Query"].DataModel.Connection.Username = "brio"
ActiveDocument.Sections["Query"].DataModel.Connection.SetPassword("brio")ActiveDo
cument.Sections["Query"].DataModel.Connection.Connect
try this:
DMPath = ActiveDocument.Sections["Query"].DataModel.Connection
DMPath.Username = "brio"
DMPath.SetPassword("brio")
DMPath.Connect
You must remember to treat space-saving variables like the actual object model
paths. That is, insert periods between object model segments and do not add
unnecessary spaces.
Also, it is generally a good idea to only include objects as part of the path. That
is, make sure that your variable does not have any methods or properties
segments for the object with which you want to work. For example:
LPath = ActiveDocument.Sections["Query"].Limits
LPath.Activate()
Conditional Tests
When using if statements, avoid impossible conditional tests. For example, the
following script will always return “myvar is not 5!” even though myvar is 5.
This is because the condition will always evaluate to false. In this case, 5 is not
the same as “five.”
var myvar = 5
if ( myvar == "five")
{
Alert("myvar = 5!")
}
else
{
Alert("myvar is not 5!")
}
It is especially important to know exactly how a variable reports in your
condition. The Console.Writeln() and Alert() methods are especially
useful in diagnosing problems like this. Note that the JavaScript core operator
String is used only to format myvar for the Console window:
var myvar = 5
Console.Writeln(String(myvar))
if ( myvar == "five")
{
Alert("myvar = 5!")
}
else
{
Alert("myvar is not 5!")
}
Syntax Reference
On the bottom left of the Script Editor, directly above the Help button, is the
Description pane. The Description pane shows you the necessary syntax for
any item you select in the Object browser.
For example, in the Object browser, navigate to
Application→ActiveDocument→Sections→Query→Methods, then select the
Activate(). The Description pane reads:
void Activate()
This indicates that the Activate() method does not take any arguments.
Now click on the Export() method. The Description pane reads:
void Export(String Filename, BqExportFileFormat FileFormat, [optional] Boolean
IncludeHeaders)
This indicates that the Export() takes three arguments, two required
arguments and an one optional.
For more detailed information, click Help to open the online help for the
Export() Method topic.
Recalculating Results
A script that includes limits may execute slowly because it has to recalculate a
complete data set each time there is a modification. You can use the
SuspendRecalculate property to prevent a Results limit from recalculating
after each modification.
✏ Note Console.Writeln() is spelled with a lowercase L and N, which is an abbreviation for Write Line.
Bypass Errors
The try-catch block is borrowed from Java and is used to bypass errors. general
syntax for a try-catch block is:
try
{do something}
catch(errorname)
{do something with the error}
finally
{do something else}
For example:
QPath = ActiveDocument.Sections["Query"].Limits
try
{QPath.Activate()}
catch(e)
{Alert(e.toString())}
finally
{Alert("We're Done!")}
The try-catch block generally does not catch definition errors, but shows an
error in the Console window at the lowercase “d” in “date()”:
try
{Alert(new date())}
catch(e)
{Alert(e.toString())}
finally
{Alert("We're Done!")}
All elements in BrioQuery documents are seen as objects, each of which can
have certain properties and methods. Objects also can be organized into
collections.This chapter provides an alphabetical reference to the
objects and collections available in BrioQuery documents.
9-1
AggregateLimits (Collection)
Description: The AggregateLimits collection represents those items that allow you to set a
limit on a Request item that was computed using a data function in the Query
section. The AggregateLimits collection is identical to the Limits collection
except it is used only for aggregate limits and the AvailableValues Collection is
not available for use. For more information on regular limits and computed
item limits, see the Limits Collection.
Example: The following example shows you how to create a query aggregate item limit,
add values to the aggregate limit through custom values and selected values,
and then add the limit to the limit line.
//Note that the string argument for the CreateLimit method is a reference to the
//item’s DisplayName on the request line in the form of Request.DisplayName
myLimit=ActiveDocument.Sections["SalesQuery"].AggregateLimits.CreateLimit
("Request.Amount Sales")
myLimit.Operator=bqLimitOperatorEqual
myLimit.CustomValues.Add("50")
myLimit.SelectedValues.Add("50")
ActiveDocument.Sections["SalesQuery"].AggregateLimits.Add(myLimit)
9-2 Objects
AppendQueries (Collection)
Description: The AppendQueries (Collection) represents those items that allow you to
merge multiple queries in a combined Results set.
Example 1: The following example shows you to how to append a query using the Union
operator.
ActiveDocument.Sections["Query"].AppendQueries.Add()
ActiveDocument.Sections ["Query"].AppendQueries[1].UnionController=bqUnion
Example 2: The following example shows you how to add "Periods" and "Quarters" to the
Request line, and how to remove the second request line item.
ActiveDocument.Sections["Query"].AppendQueries.Requests.Add("Periods","Quarters")
ActiveDocument.Sections["Query"].AppendQueries.Requests[2].Remove()
Example 3: The following example shows you how to place a limit on the "Periods" request
line item and how to add the value "Quarter 1" to the limit value.
MyLimit=ActiveDocument.Sections["Query"].AppendQueries.Limits.CreateLimit
("Periods")
ActiveDocument.Sections["Query"].AppendQueries.Limits[1].SelectedValues.Add("Q1")
ActiveDocument.Sections["Query"].AppendQueries.Limits.Add(MyLimit)
Description: This object represents the entire BrioQuery application. The Application
object contains:
■ Application-wide settings and options
■ Methods that return top level objects, such as ActiveDocument
■ Properties that return top level objects, such as ActiveDocument
Example: In this example, the quit method is called from the Application object.
Application.Quit()
✏ Note The Application.Quit() method applies only to BrioQuery and not the Brio plug-ins.
9-4 Objects
AreaChart (Object)
Description: The AreaChart object represents all of the properties of an area chart.
Example: The following script shows you how to set an Area chart to fill the area under
the Ribbon. The example assumes that “Chart” is the name of Chart report in
the active document.
ActiveDocument.Sections["Chart"].AreaChart.FillUnderRibbon = true
9-6 Objects
AxisLabels (Collection)
Description: The AxisLabels collection is a collection of labels for a specific chart axis. It
maps directly to the Chart outliner.
The AxisLabels collection is instantiated three times for each Chart Section
Object in the form: XLabels, YLabels, and ZLabels.
Example: The following example shows you how to determine the number of labels on
the X-axis.
ActiveDocument.Sections["AllChart"].XLabels.Count
Description: The BarChart object represents all of the properties of a bar chart.
Example: This example shows you how to enable the bar values of a bar chart.
ActiveDocument.Sections["Chart"].BarChart.ShowBarValues = true
9-8 Objects
BarLineChart (Object)
Example: The following example shows you how to change the properties of a barline
chart.
ActiveDocument.Sections["Chart"].BarLineChart.ShowBarValues = true
ActiveDocument.Sections["Chart"].BarLineChart.StackClusterType=bqBarLineCluster
ActiveDocument.Sections["Chart"].BarLineChart.ClusterBy = bqClusterByY
ActiveDocument.Sections["Chart"].BarLineChart.IgnoreNulls = false
ActiveDocument.Sections["Chart"].BarLineChart.ShiftPoints = bqShiftCenter
Description: The CategoryItems collection is a collection of items for a specific Chart axis. It
maps directly to the Chart outliner.
The CategoryItems collection is instantiated three times in a Chart Section in
the form: XCategories, Facts, and ZCategories.
Example: In this example, a chart is built from scratch using the request items specified
in the query. First, all the items in the outliner are removed, and then each
specific item is added to the outliner.
ActiveDocument.Sections["Chart"].XCategories.RemoveAll()
ActiveDocument.Sections["Chart"].Facts.RemoveAll()
ActiveDocument.Sections["Chart"].XCategories.Add("Year")
ActiveDocument.Sections["Chart"].Facts.Add("Unit Sales")
or
for (I=1;I< ActiveDocument.Sections["Chart"].XCategories.Count; I++)
ActiveDocument.Sections["Chart"].XCategories.Remove(I)
for (I=1;I< ActiveDocument.Sections["Chart"].Facts.Count; I++)
ActiveDocument.Sections["Chart"].Facts.Remove(I)
ActiveDocument.Sections["Chart"].XCategories.Add("Year")
ActiveDocument.Sections["Chart"].Facts.Add("Unit Sales")
9-10 Objects
Properties: Read-Only Properties: Property Count As Number, Property AxisType As
BqChartAxisType
Example: The following example activates the “Sales Chart” section, turns on the legend,
changes the title to “International Sales Report”, changes the chart type to a
horizontal bar chart, and then exports the chart to an HTML file named
“intlchrt.htm.”
myChart = ActiveDocument.Sections["Sales Chart"]
myChart.Activate()
myChart.ShowLegend = true
myChart.Title = "International Sales Report"
myChart.ChartType = bqChartTypeHorizontalBar
myChart.Export("c:\\html\\intlchrt.htm",bqExportFormatHTML,true)
9-12 Objects
Objects: AreaChart As AreaChart, BarChart As BarChart, BarLineChart As
BarLineChart, LabelsAxis As LabelsAxis, LineChart As LineChart, PieChart As
PieChart , ValuesAxis As ValuesAxis, Legend As Legend
Description: The Column object represents an individual column within a Table or Results
section.
Example 1: The following example shows how to populate a Dropdown list control in an
EIS section with data from a Results column. This example assumes that you
have two controls in your EIS section, a button named “CommandButton”
and a dropdown list named “Dropdown.”
//Code behind the "CommandButton"
var NumRows = ActiveDocument.Sections["Results"].RowCount
for (I =1 ; I <= NumRows;I++)
DropDown.Add(ActiveDocument.Sections["Results"].Columns[1].GetCell(I))
Example 2: The following example shows how to change the number format of all numeric
columns in a Results section.
var NumColumns=ActiveDocument.Sections["SalesResults"].Columns.Count
for (I=1; I<=NumColumns;I++)
{
var MyCol=ActiveDocument.Sections["SalesResults"].Columns.Item(I)
MyCol.ResizeToBestFit()
if (MyCol.DataType = bqDataTypeNumber)
MyCol.NumberFormat = "0.00"
}
9-14 Objects
Columns (Collection)
Example: The following example shows how to add a computed column, named
“MyComputed,” in the Results section. This example includes both strings and
numeric calculations in the same computed columns.
var MyResults = ActiveDocument.Sections["Results"]
var NumColumns = MyResults.Columns.Count
var Expression = ("Number of Columns="+Number(NumColumns+1))
MyResults.Columns.AddComputed("MyComputed", Expression)
Description: The Connection object represents either a Connection File (OCE) or the
connection to a database. Each Data Model object has an associated
connection object that describes the Data Model’s connection to the database.
The connection object can also represent a Data Model’s MetaData connection
information. Lastly, a connection object can be a stand-alone object, which
represents an OCE. This object can be created by calling the CreateConnection
method.
Example 1 The following example shows you how to connect a Data Model to its
associated database and then process a query. This example assumes that a
connection file is already associated with the Data Model.
//Check to make sure the connection has an associated OCE
if(ActiveDocument.Sections["Query"].DataModel.Connection.Filename != "")
{
with(ActiveDocument.Sections["Query"].DataModel.Connection)
{
Username = "brio"
SetPassword("BrioBrio")
Connect()
}
ActiveDocument.Sections["Query"].Process()
}
else
{
Alert("Your DataModel does not have an OCE","Information")
}
Example 2 This example shows you how to create an OCE from scratch and save it to a
local file.
var myCon
myCon = Application.CreateConnection()
myCon.Api =bqApiSQLNet
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("C:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\PlutoSQL.oce")
//Now use this connection in a datamodel
ActiveDocument.Sections["SalesQuery"].DataModel.Connection.Open("C:\\Program
Files\\Brio\\BrioQuery\\Program\\Open Catalog Extensions\\PlutoSQL.oce")
9-16 Objects
Method Connect(), Disconnect(), Open(Filename As String), Save(), SaveAs(Filename
As String), SetPassword(Password As String),
UseAlternateMetadataLocation(Value As Boolean, [MetadataOce As String])
Example 1 The following example shows you how to display the names of all the sections
in a document to the console window. Each section name can print on a new
line by using the Carriage Return “\r” and New Line “\n” characters. The
method used is Write.
for(I=1 ; I <= ActiveDocument.Sections.Count; I ++)
Console.Write (ActiveDocument.Sections[I].Name+"\r\n")
Example 2 The following example shows you how to print the names of document
sections on individual lines. Each name is printed on a new line by using the
Writeln method.
Console.Writeln(ActiveDocument.Name +"'s sections are: ")
for (j=1 ; j < ActiveDocument.Sections.Count ; j++)
Console.Writeln("Section #"+j +" = " +ActiveDocument.Sections[j].Name)
9-18 Objects
Control (Object)
Description: The Control object represents an individual control. All controls are inherited
from this basic object. As a result, the Control object itself is not called.
Description: The Controls collection contains all the control objects for a specific EIS
section. This collection is used to gain access to an EIS sections control. The
Controls collection returns a specific control object. Each control object has
generic methods and properties, which are the same for all controls, and
methods and properties that are specific to the type of control returned.
Example: The following example shows you how to enable all disabled controls in a
particular EIS section:
var ControlCount = ActiveDocument.Sections["EIS"].Controls.Count
for (I = 1 ; I <= ControlCount; I++)
{
// if the control is disabled then enable it
if (ActiveDocument.Sections["EIS"].Controls[I].Enabled != true)
ActiveDocument.Sections["EIS"].Controls[I].Enabled = true
}
9-20 Objects
ControlsCheckBox (Object)
Example: The following example shows you how to change the text associated with the
checkbox control and to determine if it is checked and visible. The following
script assumes that there is a checkbox control named “CheckBox” in an EIS
section.
CheckBox.Text = "Click here to change the value"
//if the CheckBox is not being shown, show it.
if (CheckBox.Visible != true)
CheckBox.Visible = true
if(CheckBox.Checked == true)
Alert("Checkbox is Checked","Info")
else
Alert("Checkbox is Not Checked","Info")
Method OnClick()
Example: The following example shows you how to change the text, the font type, and
the font size of a Command button.
CommandButton.Text = "Click Here"
CommandButton.Font.Name = "Courier"
CommandButton.Font.Size = 12
Method OnClick()
9-22 Objects
ControlsDropDown (Object)
Description: The ControlsDropDown object represents an EIS dropdown list object. The
Dropdown list control is a user-interface control that allows the user to select
one item from a list of items.
Example: The following example shows how to populate a dropdown list control from
an existing query limit.
// Connect to the database to ensure showvalues will work
ActiveDocument.Sections["Query"].DataModel.Connection.Username = "brio"
ActiveDocument.Sections["Query"].DataModel.Connection.SetPassword("Brio
Brio")
ActiveDocument.Sections["Query"].DataModel.Connection.Connect()
//Load the list of Available Values
ActiveDocument.Sections["Query"].Limits[1].RefreshAvailableValues()
var ValueCount =
ActiveDocument.Sections["Query"].Limits[1].AvailableValues.Count
Description: The ControlsListBox object represents an EIS list box. A list box is a user-
interface control that allows a user to select one or more items from a list.
Example: The following example shows you how to clear the values in a listbox and
repopulate it with values from a results column. This example uses JavaScript’s
built in sorting functions. This feature sorts the data before populating the
control.
✏ Note JavaScript Arrays are 0 based; all Brio Collections are 1 based.
ListBox.RemoveAll()
MyArray = new Array()
RowCount = ActiveDocument.Sections["Results"].RowCount
//GetCell Returns the value of an individual cell in a Column
for (j = 1; j <= RowCount; j++)
MyArray[j] = ActiveDocument.Sections["Results"].Columns[1].GetCell(j)
//Use JavaScripts built in Array sorting to sort the values
SortedArray = MyArray.sort()
// Add all the sorted items to the listbox control
for (j = 0; j< MyArray.length;j++)
ListBox.Add(SortedArray[j])
9-24 Objects
ControlsRadioButton (Object)
Example: The next example shows you how to determine which Radio button has been
selected from a group of buttons.
NumControls = ActiveDocument.Sections["EIS2"].Shapes.Count
for (I = 1; I <= NumControls;I++)
{
if (ActiveDocument.Sections["EIS2"].Shapes[I].Group == "ButtonGroup")
if(ActiveDocument.Sections["EIS2"].Controls[I].Checked==true)
Alert("Radio Button"+ ActiveDocument.Sections["EIS2"].Controls[I].Name
+" Is checked")
}
Methods: OnClick()
Description: The ControlsTextBox represents an EIS textbox. Each text box in an EIS tab has
a unique name. Use this name to reference the object when scripting.
Example: The following example shows you how to change the text in a Textbox control
and how to enable a Textbox control. This script assumes that it is being run
from the same EIS section as the Textbox control named "TextBox."
TextBox.Text = "Hello World"
if (TextBox.Enabled == false)
TextBox.Enabled = true
9-26 Objects
Cookies (Collection)
Description: The cookies collection represents a list of key value pairs, stored as cookies, in
the current browser. Cookies are small nuggets of text (less than 4K) which are
stored in a Web browser to enable persistent data storage. The cookies
collection provides read-only access to the cookies stored in the current
browser. Since cookies are browsers based, this collection only applies to the
plug-in products. However, the cookies collection is exposed in the client
server products to assist in developing plug-in scripts.
Example 1 Shows how to display the value of the BRIOUSER cookie in an alert box.
var Username = Session.Cookies["BRIOUSER"]
Alert("The username entered on the OnDemand Server login is:
"+Username,"ODSUSername")
Example 2 Shows how to test scripting in the client server version by creating temporary
values in the cookies collection.
✏ Note Added key value pairs to the cookies collection does NOT write them back to the Web browser.
9-28 Objects
CornerLabels (Object)
Description: The CornerLabels object represents the Pivot report's corner labels feature.
Corner labels mirror the names of the values in the Pivot Outliner in the actual
pivot. Using the CornerLabels object you can include corner labels on your
pivot report and specify their position (none, top, side, or both).
Example 1: In the following example, corner labels are displayed on the side of the pivot
report.
LabelActiveDocument.Sections["Pivot"].CornerLabels.Display=
BqPivotLabelDisplaySide
Example 2: In the following example, corner labels are displayed on the top of the pivot
report.
ActiveDocument.Sections["Pivot"].CornerLabels.Display= BqPivotLabelDisplayTop
Example 3: In the following example, corner labels are displayed on both the top and side
of the pivot report.
ActiveDocument.Sections["Pivot"].CornerLabels.Display= BqPivotLabelDisplayBoth
Description: The DataLabels object represents the Pivot report's data labels feature. Data
labels are the column and row heading on the top and sides of the pivot report
and define the categories by which the numeric values are organized.Using the
DataLabels object you can include datalabels on your pivot report and specify
their position (none, top, side, or both).
Example 1: In the following example, data labels are displayed on the side of the pivot
report.
ActiveDocument.Sections["Pivot"].DataLabels.Display= BqPivotLabelDisplaySide
Example 2: In the following example, data labels are displayed across the top of the pivot
report.
ActiveDocument.Sections["Pivot"].DataLabels.Display= BqPivotLabelDisplayTop
Example 3: In the following example, data labels are displayed on both the top and side of
the report.
ActiveDocument.Sections["Pivot"].DataLabels.Display= BqPivotLabelDisplayBoth
9-30 Objects
DataModelSection (Object)
Description: The Data Model object represents the underlying Data Model for a Query
Section or DataModelSection object. The Data Model object contains
information about the connection, table catalog, etc. It can be accessed from
either the Data Model or Query sections.
Example 1: The following example shows you how to set some basic properties of a Data
Model. It turns off AutoJoin and AutoAlias, limits queries to 20 minutes and
enables joins between iconized topics. Using the with statement enables you to
call methods and properties for an object without fully qualifying it.
with (ActiveDocument.Sections["Query"].DataModel)
{
AutoAlias = false
AutoJoin = false
TimeLimit = 20
ShowIconJoins = true
}
Example 2: The following example shows you how to build a Data Model using the Table
Catalog object. This example assumes that you are already connected to a
database.
with (ActiveDocument.Sections["Query"].DataModel)
{
Topics.RemoveAll()
AutoJoin = false
//Create two new topics from tables in table catalog
Catalog.Refresh()
Table1 =Catalog.CatalogItems["WINE"]
Table2 =Catalog.CatalogItems["WINE_SALES"]
Topics.Add(Table1)
Topics.Add(Table2)
Field1 = Topics[1].TopicItems["Wine Id"]
Field2 = Topics[2].TopicItems["Wine Id"]
//Create a new join by joining two TopicItems together
Joins.Add(Field1,Field2,bqJoinSimpleEqual)
// Now add topic items to the request line
for (I = 1; I <= Topics[1].TopicItems.Count; I++)
ActiveDocument.Sections["Query"].Requests.Add(Topics[1].Name,Topics[1].
TopicItems[I].DisplayName)
}
9-32 Objects
DefinedJoinPaths (Collection)
Description: Defined Join Paths are customized join preferences that enable BrioQuery to
include or exclude appropriate tables based on the items referenced on the
Request and Limit lines. The net effect limits the query to all referenced tables
based on available table groupings, generating the most efficient SQL for
queries of the Data Model. The features in this collection correspond to the
options available on the Define Join Paths dialog.
Example 1: The following example shows you how to select a user defined join path option
and delete the existing join path.
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.Type=
bqDataModelJoinsOptionDefJoin
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.DefinedJoinPath
["MyJoinPath"].Remove()
Example 2: The following example shows you how to select the user defined join path
option, and change an existing defined join path by adding a join path topic.
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.Type=
bqDataModelJoinsOptionDefJoin
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.DefinedJoinPath
["MyJoinPath"].AddTopic("Periods")
Example 3: The following example shows you how to select the user defined join path
option, create a defined join path, and add all join path topics to the defined
join path.
9-34 Objects
DefinedJoinPath (Object)
Description: A defined join path object contains the customized join preferences that enable
BrioQuery to include or exclude appropriate tables based on the items
referenced on the Request and Limit lines.
Example 1: The following example shows you how to select the user defined join path
option, and change an existing defined join path by adding a join path topic.
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.Type=
bqDataModelJoinsOptionDefJoin
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.DefinedJoinPath
["MyJoinPath"].AddTopic("Periods")
Example 2: The following example shows you how to select the user defined join path
option, create a defined join path, and add all join path topics to the defined
join path.
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.Type=
bqDataModelJoinsOptionDefJoin
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.DefinedJoinPath.Add("MyJo
inPath")
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.DefinedJoinPath["MyJoinPa
th"].AddAllTopics()
Description: The DMCatalog object represents the Table Catalog. This object provides
access to the names of the database tables that are used when a Data Model is
built.
Example: The following example shows you how to create a Data Model by inserting
tables from the Table Catalog. It also shows you how to change the basic
display properties of the Table Catalog.
with (ActiveDocument.Sections["Query"].DataModel)
{
Catalog.ShowFullName= true
//Updates the Table Catalog with the most current view of the tables
Catalog.Refresh()
Table1 =Catalog.CatalogItems["WINE"]
Table2 =Catalog.CatalogItems["WINE_SALES"]
//Create two new topics from tables in table catalog
Topics.Add(Table1)
Topics.Add(Table2)
}
Methods: Refresh()
9-36 Objects
DMCatalogItem (Object)
Example: The following example shows you how to write all the information about the
tables in the Table Catalog to the console window.
with (ActiveDocument.Sections["Query"].DataModel)
{
var NumTables = Catalog.CatalogItems.Count
for (I = 1; I <= NumTables;I++)
{
OutputString = "Database Name =" +
Catalog.CatalogItems[I].DatabaseName
OutputString = OutputString +":Database Owner=" +
Catalog.CatalogItems[I].Owner
OutputString = OutputString +":Table Name=" +
Catalog.CatalogItems[I].Name
Console.Write(OutputString+"\r\n")
}
}
Methods: None
Description: The DMCatalogItems collection represents a list of all the items in the Table
Catalog.
Example: The following example shows you how to write all the information about the
tables in the Table Catalog to the console window.
With (ActiveDocument.Sections["Query"].DataModel)
{
var NumTables = Catalog.CatalogItems.Count
for (I = 1; I <= NumTables;I++)
{
OutputString = "Database Name =" +
Catalog.CatalogItems[I].DatabaseName
OutputString = OutputString +":Database Owner=" +
Catalog.CatalogItems[I].Owner
OutputString = OutputString +":Table Name=" +
Catalog.CatalogItems[I].Name
Console.Write(OutputString+"\r\n")
}
}
9-38 Objects
Document (Object)
Description: The document object contains the content of the file (document) created by
BrioQuery that you store on your personal computer. Each BrioQuery
document consists of one or more sections.
Example 1: The following example shows how a document object can be referenced by
enumerating the documents collection object or by referring to the
ActiveDocument object. The following commands all set myDoc to the same
document object.
myDoc = Documents[1] or
myDoc = Documents["Testdoc.bqy"] or
if "Testdoc.bqy" is the current document then
myDoc = ActiveDocument
Example 2: In this example, the Section Title bar has been turned off in the
ActiveDocument, and the document is saved with a new filename.
ActiveDocument.ShowSectionTitlebar = false
ActiveDocument.SaveAs("d:\\Brio Docs\\Updated File.bqy")
ActiveDocument.Close()
Description: This is a collection of all document collections objects within the application.
Example: The following example shows you how to print the names of all open
documents to the console window. It also compares the names of the open
documents with the ActiveDocument (the document which has Focus) and
prints “Active” next to its name.
For (I= 1;I <= Documents.Count;I++)
{
if (Documents[I].Name == ActiveDocument.Name)
Console.Writeln(ActiveDocument.Name + "- Active")
else
Console.Writeln (Documents[I].Name)
}
9-40 Objects
EISSection (Object)
Example: The following example shows how to access the list of controls in an EIS
section. It also shows you how to rename the section, and how to show or hide
the section.
MyEIS = ActiveDocument.Sections["EIS"]
Console.Write("Number of Controls = "+MyEIS.Controls.Count)
Console.Write("The First Control is Named: "+MyEIS.Controls[1].Name)
MyEIS.Name = "My Eis Section"
//If the section is hidden then show it
if (MyEIS.Visible == false)
MyEIS.Visible = true
Description: An object that represents a chart's Y-axis. The Facts object's properties affect
the display of the Y-axis and the Y-Facts categories in the Outliner.
Example: In this example, a chart is built from scratch using the request items specified
in the query. First, all the items in the outliner are removed, and then the
specific items are added to the outliner.
ActiveDocument.Sections["Chart"].Facts.RemoveAll()
ActiveDocument.Sections["Chart"].Facts.Add("Product")
ActiveDocument.Sections["Chart"].Facts.Add("State")
9-42 Objects
Fill (Object)
Description: The Fill object contains all of the properties associated with object background
formatting.
Example: The following example shows you how to change the color of a rectangle.
MyRectangle = ActiveDocument.Sections["EIS"].Shapes["Rectangle"]
MyRectangle.Fill.Color = bqBlue
Methods: None
Description: The Font object contains all of the methods and properties of fonts.
Example: The following example shows you how to change the size and color of a text
label control.
ActiveDocument.Sections["EIS"].Shapes["TextLabel1"].Font.Color=bqBlue
ActiveDocument.Sections["EIS"].Shapes["TextLabel1"].Font.Style=bqFontStyleItalic
Methods: None
9-44 Objects
Form (Collection)
Description: The Form collection represents a list of key value pairs stored generated from a
POST method of an HTML form. Form elements are the controls, which allow
users to make selections on an HTML page. The Form collection provides
read-only access to the form elements values which as environment variables
in the current browser. Since HTML forms are browsers based this collection
only applies to the plug-in products. However, the Form collection is exposed
in the client server products to assist in developing plug-in scripts.
Example: Shows how to read the values of a Form elements and use them inside a plug-in
script.
Basic HTML Form:
<HTML>
<BODY>
<!—Note: The Action Key have a value which opens a document from the OnDemand
Server. You MUST include the "Jscript=enable" key-value pair to initialize the
plug-in scripting ->
<FORM METHOD = "post" ACTION = "http://your.server.com/ods-
cgi/odscgi.exe?Method=getDocument&Docname=-1835-83481598112-58541278350-125-8-1-
1387-9434&JScript=enable">
<P>Text Box <INPUT id=text1 name=text1></P>
<P>Password <INPUT id=password1 name=password1 type=password></P>
<P>Text Area <TEXTAREA id=TEXTAREA1 name=TEXTAREA1></TEXTAREA></P>
<P>Check Box<INPUT id=checkbox1 name=checkbox1 type=checkbox></P>
<P>Radio <INPUT id=radio1 name=radio1 value = "1st" type=radio><INPUT
id=radio1 name=radio1 type=radio value = "2nd" CHECKED></P>
<P>DropDown<SELECT id=select1 name=select1 >
<OPTION value=Value1>Display1
9-46 Objects
Join (Object)
Description: The Join object represents an individual join between topics in a Data Model.
Example: The following example shows you how to change the type of join to a left join
and print the names of the joined topic items to the console window.
ActiveDocument.Sections["Query"].DataModel.Joins[1].Type = bqJoinLeft
Console.Writeln(ActiveDocument.Sections["Query"].DataModel.Joins[1].TopicItem1.Di
splayName=”Sales”)
Console.Writeln(ActiveDocument.Sections["Query"].DataModel.Joins[1].TopicItem2.Ph
ysicalName)
Description: The Joins collection is a collection of joins between topics in a Data Model.
Example: The following example shows you how to remove all the joins in the current
Data Model and create a simple join between the Wine.Wine_Id and
Wine_Sales.Wine_Id topic items.
with(ActiveDocument.Sections["Query"].DataModel)
{
Joins.RemoveAll()
Field1 = Topics["WINE"].TopicItems["Wine Id"]
Field2 = Topics["WINE_SALES"].TopicItems["Wine Id"]
//Create a new join by joining two TopicItems together
Joins.Add(Field1,Field2,bqJoinSimpleEqual)
}
9-48 Objects
JoinsOptions (Collection)
Description: The JoinsOptions collection represents the available join usage preferences.
The features in this collection correspond to the options available on the Joins
tab of the Data Model Option dialog.
Example: The following example shows you how to specify to use only topics represented
by items on the Request line for joins.
ActiveDocument.Sections["Query"].DataModel.JoinsOptions.Type=
bqDataModelJoinsOptionMinTopics
Methods: None
✏ Note If you choose to programmatically define your own join paths by selecting the bqDataModel
JoinsOptionDefJoin constant, specify your join preferences using the DefinedJoinPath
(Collection).
Description: The LabelsAxis object acts as a logical container for both of the labels axis
contained in a chart.
Example: The following example shows you how to set basic properties of the XAxis label
and the ZAxis label.
with(ActiveDocument.Sections["Chart"])
{
LabelsAxis.XAxis.ShowValues = true
LabelsAxis.XAxis.ShowTickmarks = true
LabelsAxis.ZAxis.ShowValues = false
LabelsAxis.ZAxis.ShowTickmarks = false
}
Methods: None
Properties: None
9-50 Objects
LabelValues (Object)
Member of: ChartSection Object, XLabels Object, YLabels Object and Zlabels Object
Description: The LabelValues object represents the values on the YLabel, XLabel, or ZLabel.
✰ Tip For simplicity, the “[]” can be used in place of the call to the “Item()” method.
For example, the following statements are identical in behavior:
myItem = Documents[1]
myItem = Documents.Item(1)
myItem = Documents["StartUp.bqy"]
myItem = Documents.Item("StartUp.bqy")
Example: The following example shows you how to set up LabelValues items 1 and 2 in a
new array. The new array could then be used with the FocusSelection and
HideSelection methods.
var Xarray = new Array();
Xarray[0] = ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(1)
Xarray[1] = ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(2)
Properties: None
Description: The Legend object represents all of the methods and properties of a chart
legend.
Example: The following example shows you how to change the chart axis type to the X-
axis category.
ActiveDocument.Sections["Chart"].Legend.Focus=bqChartXAxis
Methods: None
9-52 Objects
Legend (Collection)
Description: The Legend collection allows you to set and get legend item attributes of a
chart. You might use this collection to set and retrieve the line width of a line
chart; or to modify the foreground color of a Bar chart.
Example 1: The following example shows you how to change the color, the fill pattern, the
line color, and the line width of a legend item.
ActiveDocument.Sections["Chart"].Legend.Items[1].Fill.Color=bqBlue
ActiveDocument.Sections["Chart"].Legend.Items[1].Fill.BrushStyle =
bqBrushStyleCross
ActiveDocument.Sections["Chart"].Legend.Items[1].Line.Color= bqBlue
ActiveDocument.Sections["Chart"].Legend.Items["Q1"].Line.Width= 6
Example 2: The following example shows you how to set the marker style, the marker size,
the marker border color, and the marker fill color of a legend item.
ActiveDocument.Sections["Chart"].Legend.Items["Q1"].Line.MarkerStyle = bqSquare
ActiveDocument.Sections["Chart"].Legend.Items[1].Line.MarkerSize = bq6pt
ActiveDocument.Sections["Chart"].Legend.Items[1].Line.MarkerBorderColor= bqRed
ActiveDocument.Sections["Chart"].Legend.Items["Q1"].Line.MarkerFillColor= bqGreen
Methods: LegendItems.Item(NameOrIndex)
Description: The LeftAxis object represents all the left values axis properties contained in a
chart.
Example: The following example shows you how to set some basic properties of the left
axis.
with(ActiveDocument.Sections["Chart"].ValuesAxis)
{
LeftAxis.AutoScale = true
LeftAxis.AutoInterval = true
LeftAxis.ShowLabel = false
}
Methods: None
9-54 Objects
Limit (Object)
Description: The Limit object represents an individual limit. The limit object applies to
Results, Data Model and Query Limits.
Example 1 The following example shows you how to modify values of an existing Results
limit.
MyLimit = ActiveDocument.Sections["Results"].Limits[1]
//Clear all the values which are currently set
MyLimit.SelectedValues.RemoveAll()
// add new values to the selectedvalues collection
MyLimit.SelectedValues.Add(2000)
//Change the limit criteria
MyLimit.Operator = bqLimitOperatorLessThan
Example 2 The following example shows you how to create a new query limit from an
existing topic.
//Create an empty Limit object from the "Wine.Cost" Topic Item.
MyLimit = ActiveDocument.Sections["Query"].Limits.CreateLimit("Wine.Cost")
MyLimit.Operator = bqLimitOperatorGreaterThan
MyLimit.SelectedValues.Add(10)
MyLimit.Name = "Costly Wine"
//Adds the limit to the Limit Line -
ActiveDocument.Sections["Query"].Limits.Add(MyLimit)
Example 3 The following example shows you how to populate a list box control with the
list of available values for an existing results limit.
LimitCount = ActiveDocument.Sections["Results"].Limits[1].AvailableValues.Count
for (i=1;I<=LimitCount;i++)
ListBox.Add(ActiveDocument.Sections["Results"].Limits[1].AvailableValues[i])
9-56 Objects
Limits (Collection)
Description: The Limits collection is the collection of limits within a Results, Query or Data
Model section. The Limits collection is analogous to the Limit line in Brio
Enterprise.
Example 1: The following example shows you how to remove all existing limits and create
a new query limit from an existing topic.
ActiveDocument.Sections["SalesQuery"].Limits.RemoveAll()
MyLimit = ActiveDocument.Sections["SalesQuery"].Limits.CreateLimit
("Sales_Fact.Unit_Sales")
MyLimit.Operator = bqLimitOperatorGreaterThan
MyLimit.CustomValues.Add(50)
MyLimit.SelectedValues.Add(50)
//Adds the limit to the Limit Line -
ActiveDocument.Sections["SalesQuery"].Limits.Add(MyLimit)
Example 2: The following example shows you how to remove all existing limits and create
a new query computed item limit.
ActiveDocument.Sections["SalesQuery"].Limits.RemoveAll()
MyLimit = ActiveDocument.Sections["SalesQuery"].Limits.CreateLimit
("Requests.Sales_Per_Unit")
MyLimit.Operator = bqLimitOperatorLessThan
MyLimit.CustomValues.Add(20)
MyLimit.SelectedValues.Add(20)
//Adds the limit to the Limit Line -
ActiveDocument.Sections["SalesQuery"].Limits.Add(MyLimit)
✏ Note The argument for CreateLimit method is different for regular limits, computed item limits, and
aggregate limits. For regular limits the argument is a reference to the table topic and the topic
item, for example, CreateLimit(“Sales_Facts.Amount_Sales”). For both computed item limits
and aggregate limits the argument is a reference to the item’s Display Name on the request
line, for example, CreateLimit(“Request.Amount Sales”).
9-58 Objects
LimitValues (Collection)
Description: The LimitValues collection is a collection of all the values associated with the
different types of limits—regular, computed, and aggregate. Each limit object
has three LimitValues collections: AvailableValues, SelectedValues, and
CustomValues. The AvailableValues collection is used for regular limits only.
Example 1: The following example shows you how to add all the values in the
AvailableValues collection to the SelectedValues collection. This is essentially
the same as performing a select all values and transferring the selection in the
Limit User Interface.
LimitCount =
ActiveDocument.Sections["Results"].Limits[1]. AvailableValues.Count
for (i=1;i<=LimitCount;i++)
{
MyVal =
Add(ActiveDocument.Sections["Results"].Limits[1]. AvailableValues[i]
ActiveDocument.Sections["Results"].Limits[1]. SelectedValues.Add(MyVal)
}
Example 2: The following example adds a CustomValue to the computed item limit.
ActiveDocument.Sections[“Query”].Limits[2]. CustomValues.Add(‘2’)
9-60 Objects
LineChart (Object)
Description: The Line Chart object represents all the methods and properties specific to
Line Charts.
Methods: None
Description: The Line object contains all of the properties assocated with border formating.
Example 1: The following example shows you how to change the border color, width and
DashStyle of a rectangle.
MyRectangle = ActiveDocument.Sections["EIS"].Shapes["Rectangle"]
MyRectangle.Line.Color = bqRed
MyRectangle.Line.Width = 4
MyRectangle.Line.DashStyle = bqDashStyleDotDotDash
Example 2: The following example shows you how to change the marker color and style for
a line chart.
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.
MarkerBorderColor=bqRed
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.
MarkerStyle=bqMarkerStyleTriangle
Methods: None
9-62 Objects
LocalJoins (Collection)
Description: The LocalJoins collection provides you with the ability to derive the Topic
Name of a topic item contained in a join or local join. You can also retrieve the
Topic Item Name for joins (but not for a local join).
Example 1: The following example shows you how to use a simple equal join.
Topic1=ActiveDocument.Sections[“Query”].DataModel.Topics[“Sales Fact”].
TopicItems.Item(2)
Topic2=ActiveDocument.Sections[“Query”].DataModel.Topics[“Products”].
TopicItems.Item(1)
ActiveDocument.Sections[“Query”].DataModel.Joins.Add
(Topic1,Topic2,bqJoinSimpleEqual)
Example 2: The following example shows you how to use a simple equal join to join topics
1 and 2 in a local results set.
LRTopic1=ActiveDocument.Sections["Query2"].DataModel.LocalResults["1"].
LocalResultTopicItems.Item(7)
LRTopic2=ActiveDocument.Sections["Query2"].DataModel.LocalResults["2"].
LocalResultTopicItems.Item(7)
ActiveDocument.Sections["Query2"].DataModel.LocalJoins.Add(LRTopic1,LRTopic2,
bqJoinSimpleEqual)
Description: The LocalResults collection provides you with the ability to use local results in
joins and the Request line for processing results sets.
Example 1: The following example adds a local results topic to a query section.
vDM=
ActiveDocument.Sections["Query"].DataModel.Catalog.Results.Item("sales_fact")
ActiveDocument.Sections["Query"].DataModel.LocalResults.Add(vDM)
Example 2: The following example shows how to remove all local results topics and how to
count the local results topics in a query section.
ActiveDocument.Sections["Query"].DataModel.LocalResults.RemoveAll()
ActiveDocument.Sections["Query"].DataModel.LocalResults.Count
Example 3: The following example removes a single local results topic and gets the topic
item count of the “Results2” local topic.
ActiveDocument.Sections["Query"].DataModel.LocalResults["Results2"].Remove()
ActiveDocument.Sections["Query"].DataModel.LocalResults["Results2"].
LocalResultsTopicItems.Count
Example 4: The following example adds a join between a topic and a local results topic.
Topic1=ActiveDocument.Sections["Query"].DataModel.LocalResults["Sales Fact"].
LocalResultTopicItems.Item("Store Id")
Topic2=ActiveDocument.Sections["Query"].DataModel.Results["Results2"].TopicItems.
Item("Store Id")
ActiveDocument.Sections["Query"].DataModel.LocalJoins.Add(Topic1,Topic2,
bqJoinLeft)
9-64 Objects
Example 5: The following example adds a topic from a local results to the request line.
ActiveDocument.Sections["Query"].Requests.Add("Results2","Quarter")
Description: The LocalResultsTopicItems collection provides you with the ability to use
local results topic items in joins and in the Request line for processing results
sets.
Example 1: The following example removes a single local results topic and gets the topic
item count of the “Results2” local topic.
ActiveDocument.Sections["Query"].DataModel.LocalResults["Results2"].Remove()
ActiveDocument.Sections["Query"].DataModel.LocalResults["Results2"].
LocalResultsTopicItems.Count
Example 2: The following example adds a join between a topic and a local results topic.
Topic1=ActiveDocument.Sections["Query"].DataModel.LocalResults["Sales Fact"].
LocalResultTopicItems.Item("Store Id")
Topic2=ActiveDocument.Sections["Query"].DataModel.Results["Results2"].TopicItems.
Item("Store Id")
ActiveDocument.Sections["Query"].DataModel.LocalJoins.Add(Topic1,Topic2,
bqJoinLeft)
Methods: Item()
9-66 Objects
OLAPConnection (Object)
Description: The OLAPConnection object represents either an OLAP Query connection file
(OCE) or the connection to a database. The OLAPQuery connection file is
used to capture and store connection information such as the connection
software, the database software, and the address of your database server and
your database user name for a multi-dimensional database.
Example: The following example shows you how to connect an OLAP database using an
OCE saved locally.
//Connecting to OLAP
MyConnection=ActiveDocument.Sections["OLAPQuery"].Connection
MyConnection.Open("c:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\essbase.oce")
MyConnection.Username="essbase"
MyConnection.SetPassword("essbase")
MyConnection.Connect()
Description: The OLAPLabel object represents an individual (either a top or side) label
within an OLAP report.
9-68 Objects
OLPLabels (Collection)
Description: The OLAPLabels collection consists of the OLAP Query TopLabels and
SideLabels collections. These collections correspond to the labels within a
OLAP Query section. These are columns added to the side and top labels
groups in the outliner.
BrioQuery supports different OLAP datasources, including OLEDB for DB,
Essbase, and MetaCube. Depending on the datasource, different filter
operators are supported. If you use an operator that is not applicable for the
datasource, an exception is thrown.
OLEDB for OLAP only allows users to add filter values by selecting them from
the Show Values pane on the Filter dialog box. Otherwise, use the
FilterOperator property and Add FilterValue() method.
Examples: The sample scripts below use a simple OLAPQuery with a value of “State (All)”
as a side label, a value of “Year (All)” as a top label and a value “Amount” as a
measure in the user interface.
When creating a script that includes OLAP objects, methods and properties, it
is important to observe the hierarchy of dimensions and levels. For example,
levels from the same dimension must be grouped together in both the Side and
Top labels.
In addition, the hierarchy of a dimension cannot be broken. For example,
“Year” must come before “Quarter,” which must come before “Month.”
Example 2: In the following script the Arizona state abbreviation code is added as a filter
value. Note that the “State” side label must exist before you can execute this
script properly:
OQPath = ActiveDocument.Sections[“OLAPQuery”]
QPath.SideLabels[1].AddFilterValue{‘AZ’,bqOperatorEqual)
OQPath.Process()
OQPath.Activate()
Example 3: When you do not want to use the Show Value method of filtering, use the Add
method as shown below.
//When NOT using Show Value method of filtering
ActiveDocument.Sections[“OLAPQuery”]
TopLabels.Add(‘Time.(hierarchy).Year’,’1999’)
Example 4: When you want to use the Show Value method of filtering, use the
AddFilterValue method as in the following example.
//When using Show Value method of filtering
ActiveDocument.Sections["OLAPQuery"].TopLabels.Add(‘Time.{hierarchy}.Year')
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘Time.{hierarchy}.Year'].
SetFilterOperator= bqOperatorEqual
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘Time.{hierarchy}.Year'].
AddFilterValue((‘Time.{hierarchy}.Year’,’1999’)
ActiveDocument.Sections["OLAPQuery"].TopLabels.Add(‘Time.{hierarchy}.Quarter’)
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘Time.{hierarchy}.Quarter’].
SetFilterOperator= bqOperatorNotEqual
ActiveDocument.Sections["OLAPQuery"].TopLabels[‘LabelName’].AddFilterValue
((‘Time.{hierarchy}.Year’),’Q1’)
ActiveDocument.Sections["OLAPQuery"].SideLabels.Add(‘Country.{hierarchy}.Region’)
9-70 Objects
OLAPMeasure (Object)
Example: The following example shows you how to add a measure limit called “Units
Plan.”
ActiveDocument.Sections["OLAPQuery"].Measures.Add(‘Measure.Units Plan’)
9-72 Objects
OLAPQuerySection (Object)
✏ Note With this object you can process OLAP queries, but not build them.
Example: The following example shows you how to activate and process an OLAP Query.
ActiveDocument.Sections["OLAPQuery"].Activate()
ActiveDocument.Sections["OLAPQuery"].Process()
Description: The OLAPSlicer object represents an individual slicer within an OLAP Query
report.
Methods: Remove()
9-74 Objects
OLAPSlicers (Collection)
Description: The OLAPSlicers collection consists of the OLAP Query Slicers collections.
These collections correspond to the slicer within a OLAP Query section. This is
the column added to the slicer in the outliner.
Example: The following example shows you how to add a slicer that limits the scope to
Oakland, California.
ActiveDocument.Sections["OLAPQuery"].Slicers.Add(‘ProductLocation.{hierachy}.
Store Type’,’USA.California.Oakland’)
Example: The following example shows you how to set the formatting for a specific pie
chart.
with(ActiveDocument.Sections["Chart"])
{
PieChart.ShowLabels = true
PieChart.ShowValues = true
PieChart.ShowPercentages = false
PieChart.ShowAllPositive = False
}
Methods: None
9-76 Objects
PivotFact (Object)
Description: The PivotFacts collection is a set of facts within a pivot section. These columns
are added to the facts groups in the outliner.
Example: The following example shows you how to add a number of request items to the
facts collections.
ActiveDocument.Sections["Pivot"].Facts.RemoveAll()
ActiveDocument.Sections["Pivot"].Facts.Add("Year")
ActiveDocument.Sections["Pivot"].Facts.Add("Region")
9-78 Objects
PivotLabel (Object)
Description: The PivotLabel object represents an individual (either a top or side) label
within a Pivot report.
Description: The PivotLabels collection consists of the pivot TopLabels and SideLabels
collections. These collections correspond to the labels within a pivot section.
These are columns added to the side and top labels groups in the outliner.
Example: The following example shows you how to add a number of request items to the
side and top labels collections.
ActiveDocument.Sections["SalesPivot"].TopLabels.RemoveAll()
ActiveDocument.Sections["SalesPivot"].SideLabels.RemoveAll()
ActiveDocument.Sections["SalesPivot"].TopLabels.Add("Year")
9-80 Objects
PivotLabelTotals (Object)
myItem = Documents[1]
myItem = Documents.Item(1)
myItem = Documents["StartUp.bqy"]
myItem = Documents.Item("StartUp.bqy")
Example 1: The following example shows you how to add a Totals column (using the
default data function of “sum”) for the “Product Line” from the Totals
collection or from the Toplabels collection.
ActiveDocument.Sections["SalesPivot"].TopLabels["Product Line"].Totals.Add()
or
ActiveDocument.Sections["SalesPivot"].TopLabels["Product Line"].AddTotals()
Example 2: The following example shows you how to determine the average using the data
function property and the totals collection.
ActiveDocument.Sections["SalesPivot"].TopLabels["Product Line"].Totals[1].
DataFunction=bqDataFunctionAverage
ActiveDocument.Sections["SalesPivot"].TopLabels["Product Line"].Totals.Add()
Example: The following example shows you how to modify the top and side labels on a
pivot, and create a chart based on the new pivot.
with(ActiveDocument.Sections["Pivot"])
{
TopLabels.Add("Year")
SideLabels.Add("Winery")
ChartThisPivot()
}
9-82 Objects
QuerySection (Object)
Example 1 The following example shows you how to build a Data Model using the Table
Catalog object. This example assumes that you are already connected to a
database.
with (ActiveDocument.Sections["Query"].DataModel)
{
Topics.RemoveAll()
AutoJoin = false
//Create two new topics from tables in table catalog
Catalog.Refresh()
Table1 =Catalog.CatalogItems["WINE"]
Table2 =Catalog.CatalogItems["WINE_SALES"]
Topics.Add(Table1)
Topics.Add(Table2)
Field1 = Topics[1].TopicItems["Wine Id"]
Field2 = Topics[2].TopicItems["Wine Id"]
//Create a new join by joining two TopicItems together
Joins.Add(Field1,Field2,bqJoinSimpleEqual)
// Now add topic items to the request line
for (I = 1; I <= Topics[1].TopicItems.Count; I++)
ActiveDocument.Sections["Query"].Requests.Add(
Topics[1].Name, Topics[1].TopicItems[I].DisplayName)
}
Example 2 The following example shows you how to connect to an existing connection,
remove all the limits and process a query.
MyQuery = ActiveDocument.Sections["Query"]
MyQuery.DataModel.Connection.Username = "brio"
MyQuery.DataModel.Connection.SetPassword("brio")
MyQuery.DataModel.Connection.Connect()
MyQuery.Limits.RemoveAll()
MyQuery.Process()
RowReturned = ActiveDocument.Sections["Results"].RowReturned
Console.Writeln("Returned "+ RowReturned+" Rows!")
9-84 Objects
RecentFiles (Collection)
Description: The Recent Files collection is a collection of strings, which represent the list of
currently, opened BrioQuery documents.
Example: The following example prints the list of recent files to the console window.
for (j = 1; j <= RecentFiles.Count; j++)
Console.Writeln(“File #” + j + “=” + RecentFiles[j])
Example: The following example prints out the display name and data type of each item
on the request line.
var count = ActiveDocument.Sections["Query"].Requests.Count
for(i=1;i<=count;i++)
{
myRequest = ActiveDocument.Sections["Query"].Requests[i]
switch(myRequest.DataType)
{
case 1:
myType = "String"
break;
case 2:
myType = "Integer"
break;
case 3:
myType = "Number"
break;
case 4:
myType = "Date"
break;
default:
myType = "Unknown"
}
Console.Write(myRequest.DisplayName +" DataType ="+myType+"\r\n")
}
Methods: Remove()
9-86 Objects
Requests (Collection)
Example: The following example shows you how to remove all the request line items and
add new items based on the topics in the query.
with(ActiveDocument.Sections["Query"])
{
Requests.RemoveAll()
for (I = 1; I <= DataModel.Topics[1].TopicItems.Count; I++)
{
TopicName = Topics[1].Name
TopicItemName = Topics[1].TopicItems[I].DisplayName
Requests.Add(TopicName,TopicItemName)
}
}
Description: The Results object represents an individual results set in a table catalog.
Methods: None
9-88 Objects
Results (Collection)
Description: The Results collection is a collection of local results sets in a table catalog.
Example: The following example shows you how to get a count of the LocalResults in the
Table Catalog.
ResultSetCount=ActiveDocument.Sections["Query2"].DataModel.Catalog.Results.Count
Example: The following example shows you how to set basic properties for the right axis.
with(ActiveDocument.Sections["Chart"].ValuesAxis)
{
RightAxis.AutoScale = true
RightAxis.ShowLabel = false
RightAxis.LabelText = "Right Axis"
}
Methods: None
9-90 Objects
Section (Object)
Description: The Section object represents the base object from which all section objects are
derived.
Description: The Sections collection represents all the sections, contained within a single
document.
Example: The following example shows how to create new report and query sections.
In the case of report sections (Chart and Pivot) the “SectionDependency”
parameter must be set or this method will fail. This is because all Charts and
Pivots must be associated with a query or results set.
MySection = ActiveDocument.Sections.Add(bqChart,"Query")
or
MySection = ActiveDocument.Sections.Add(bqPivot,"Results")
MySection.Name = "New Chart"
//Adding Queries does not require a section dependence
MySection = ActiveDocument.Sections.Add(bqQuery)
9-92 Objects
SelectedList (Object)
Description: The SelectedList object represents all of the selected items within a list box.
Example: The following example shows you how to add the selected items from a listbox
control to a preexisting results limit.
ActiveDocument.Sections["Results"].Limits[1].SelectedValues.RemoveAll()
for(I = 1; I <= ListBox.SelectedList.Count;I++)
{
NewLimitValue = ListBox.SelectedList[I]
ActiveDocument.Sections["Results"].Limits[1].SelectedValues.Add(NewLimitValue)
}
Description: The session object refers to the current Web browser’s session variables. The
Session object contains 3 collections, which logically group a browser’s
different type of data variables. The session object applies to the Web plug-ins
but is visible in the client server product to support script testing. To activate
the session object you must include the key value pair JScript=enable in the
URL. Please refer to the “URL (Collection)” on page 9-107 and “Form
(Collection)” on page 9-45 for more information.
Example: The following script shows how to determine if a session is active and process
the session variables.
//Session.Active = true if the script is running in the plug-in and JScript=enable
if (Session.Active)
Alert("Your web username is ="+ Session.Cookies["BRIOUSER"], "Web
Username")
else
Alert("You are not running a plug-in or you have not added the
JScript=enable key value pair to your URL")
Methods: None
9-94 Objects
Shape (Object)
Description: The Shape object represents an individual EIS graphic item contained in a
Shapes collection. Certain properties only apply to specific shape objects. For
example, PictureEffect property applies to a picture object and does NOT
apply to a line object. If you refer to a property that does not apply to the
object, no action occurs.
Example: The following example shows you how to change the properties of drawing
objects contained in an EIS section. The example assumes that the script is
running from the same EIS section. This allows the direct access to the drawing
objects by name.
Line1.DashStyle=bqDashStyleDotDash
Line1.LineWidth = 3
//note you may use Hex values instead of enumerated types for any color property
Rect1.BorderColor = bqBlue
Rect1.Line.DashStyle=bqDashStyleDotDash
TextLabel.Text = "Welcome to Brio Enterprise Scripting"
TextLabel.Font.Style = bqFontStyleBoldItalic
Methods: OnClick()
Description: The Shapes collection represents all the graphic objects contained in a specific
EIS tab.
9-96 Objects
SharedLibrary (Object)
Example: The following example shows how to call a function from a local dll.
MyLibrary = Application.LoadSharedLibrary("c:\\temp\mydll.dll")
MyLibrary.Call("SetTransaction","String",Value1)
Description: The SortItems collection is the collection of sorts within a Query, Results or
Table section.
In the Query section, sort line objects must be columns that are on the Request
line since theses are the only objects that can be placed on the Sort line. In the
Results and Table section, sort line objects have to be columns in the Results
set.
The SortItems collection provides you with the ability to create Sort Line
objects (column names), add them to the Sort Line, specify a sort order, and
force an immediate sort (for Results and Table).
✰ All collections have a method named “Item(NameOrIndex).” This is the
default method for all collections and returns an item in the collection at a
particular index or with a specific name. For simplicity, the “[]” can be used in
place of the call to the “Item()” method. For example: The following
statements are identical in behavior:
myItem = Documents[1]
myItem = Documents.Item(1)
myItem = Documents["StartUp.bqy"]
myItem = Documents.Item("StartUp.bqy")
Example 1: The following example shows you how to remove all sort line objects
(columns) and then how to add a sort line item in the Results section.
ActiveDocument.Sections["SalesResults"].SortItems.RemoveAll()
ActiveDocument.Sections["SalesResults"].SortItems.Add("Quarter")
ActiveDocument.Sections["SalesResults"].SortItems.SortNow()
Example 2: The following example shows you how to establish an ascending sort order in
the Query section.
ActiveDocument.Sections["SalesQuery"].SortItems[1].SortOrder=bqSortAscend
Example 3: The following example shows you how to remove a sort “Product Id” sort from
the Sort line in the Results section.
ActiveDocument.Sections["Results"].SortItems["Product Id"].Remove()
9-98 Objects
Methods: Add(Request As String), Item(NameOrIndex) As SortItem, RemoveAll(),
SortNow()
Description: The TableSection object represents a results or table section, contained within
a document.
Example: The following example shows you how to print the names of all the columns to
the console window.
MyResults = ActiveDocument.Sections["Results"]
ColumnCount = MyResults.Columns.Count
for (I=1;I<= ColumnCount;I++)
Console.Write("Column#"+I+":"+MyResults.Columns[I].Name+"\r\n")
9-100 Objects
Toolbar (Object)
Example: The following example shows you how to hide all the toolbars in the
application.
for(I = 1; I <= Application.Toolbars.Count;I++)
{
MyToolbar = Application.Toolbars[I]
MyToolbar.Visible = false
}
Methods: None
Description: The Toolbars collection represents all the toolbars, contained within the
application.
Example: The following example shows you how to hide all the toolbars in the
application.
for(I = 1; I <= Application.Toolbars.Count;I++)
Application.Toolbars[I].Visible = false
9-102 Objects
Topic (Object)
Description: The Topic object represents a topic in a data model or query section.
Example: The following example shows you how to print the names of all the topics in a
Data Model to the console window.
with(ActiveDocument.Sections["Query"].DataModel)
{
TopicsCount = Topics.Count
for(I=1;I<= TopicsCount;I++)
Console.Write(Topics[I].DisplayName+"\r\n")
}
Methods: Remove()
Example: The following example shows you how to print the names of all the topics and
topic items in a Data Model to the console window.
with(ActiveDocument.Sections["Query"].DataModel)
{
TopicsCount = Topics.Count
for(I=1;I<= TopicsCount;I++)
{
Console.Write(Topics[I].DisplayName+"\r\n")
TopicItemsCount = Topics[I].TopicItems.Count
for(j=1;j<= TopicItemsCount;j++)
Console.Write(Topics[I].TopicItems[j].DisplayName )
}
}
Methods: None
9-104 Objects
TopicItems (Collection)
Description: The TopicItems collection represents all of the fields, contained within an
individual topic.
Example: The following example shows you how to print the names of all the topics and
topic items in a Data Model to the console window.
with(ActiveDocument.Sections["Query"].DataModel)
{
TopicsCount = Topics.Count
for(I=1;I<= TopicsCount;I++)
{
Console.Write("\r\nTopic - "+Topics[I].DisplayName+"\r\n")
TopicItemsCount = Topics[I].TopicItems.Count
for(j=1;j<= TopicItemsCount;j++)
Console.Write(Topics[I].TopicItems[j].DisplayName)
}
}
Description: The Topics collection is a collection of all topics in the Data Model.
Example: The following example shows you how to print the names of all the topics and
topic items in a Data Model to the console window.
with(ActiveDocument.Sections["Query"].DataModel)
{
TopicsCount = Topics.Count
for(I=1;I<= TopicsCount;I++)
{
Console.Write(Topics[I].DisplayName)
TopicItemsCount = Topics[I].TopicItems.Count
for(j=1;j<= TopicItemsCount;j++)
Console.Write(Topics[I].TopicItems[j].DisplayName)
}
}
9-106 Objects
URL (Collection)
Description: The URL collection represents a list of key value pairs generated from a GET
method invocation in the current browser. URL key value pairs are variables,
which are appended to the end of a URL in a Web browser.
For example:
http://www.yourserver.com&name=test&version=6.0&jscript=enable
has two key value pairs, Name and Version. The URL collection provides read-
only access to these variables. Since URLs are browser based this collection
only applies to the plug-in products. However, the URL collection is exposed
in the client server products to assist in developing plug-in scripts.
Example: The following example shows how to read the values from a URL and use them
inside a script running on the plug-in.
http://www.yourserver.com&app=brioquery&group=pm&userid=2020&jscript=enable/
// Write the URL information to the console window.
BaseURL = Application.URL
Console.Write ("The URL of my server is = "+BaseURL)
Console.Write ("The value App variable is = " + Session.URL["App"])
Console.Write ("The value Group variable is = " + Session.URL["Group"])
Console.Write ("The value UserID variable is = " + Session.URL["UserID"])
Description: The ValuesAxis object logically represents all the properties of a charts values
axis.
Example: The following example shows you how to set some basic properties for the left
axis.
with(ActiveDocument.Sections["Chart"])
{
ValuesAxis.LeftAxis.AutoScale = true
ValuesAxis.LeftAxis.ShowLabel = false
ValuesAxis.RightAxis.AutoScale = true
ValuesAxis.RightAxis.ShowLabel = false
ValuesAxis.RightAxis.LabelText = "Right Axis"
}
Methods: None
9-108 Objects
WebClientDocument (Object)
Description: The WebClientDocument object represents a document that has been opened
inside a Brio Web application. This object, which is based on a document
object, has similar methods and properties. A WebClientDocument also has
methods and properties which are specific to Web environments.
9-110 Objects
XAxisLabel (Object)
Description: An object that represents a chart X-axis label. This object’s properties directly
affect the display of the X axis and corresponds to the options provided on the
Label Axis tab of the Properties dialog box.
Example: The following example shows how to modify the properties of the X Axis label.
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.AutoFrequency = true
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.LabelFrequency = 3
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.LabelText = “X Axis”
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.ShowLabel = true
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.ShowTickmarks = false
ActiveDocument.Sections["Chart1"].LabelsAxis.Xaxis.ShowValues = true
ActiveDocument.Sections["Chart1"].LabelsAxis.XAxis.TickmarkFrequency = 4
Methods: None
Description: An object that represents a chart's X-axis. This object's properties directly
affect the display of the X-axis and the X-Categories in the Outliner.
Example: In this example, a chart is built from scratch using the request items specified
in the query. First, all the items in the outliner are removed, and then the
specific items are added to the outliner.
ActiveDocument.Sections["Chart"].XCategories.RemoveAll()
ActiveDocument.Sections["Chart"].XCategories.Add("Product")
ActiveDocument.Sections["Chart"].XCategories.Add("State")
9-112 Objects
XLabels (Object)
Description: An object that represents a label value on the X-axis. This object’s properties
directly affect the display of the label value on the X-axis and correspond to the
options provided on the Chart menu or shortcut menu.
✏ Note You must specify the label value(s) in an array before using the FocusSelection, HideSelection
and UnhideAll methods.
Example: The following example shows how to modify the label value on the X-axis.
var OArray = new Array()
OArray[0]= ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(1)
OArray[1]= ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(3)
var ZArray = new Array()
ZArray[0]= ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(2)
ZArray[1]= ActiveDocument.Sections["Chart"].XLabels.LabelValues.Item(4)
ActiveDocument.Sections["Chart"].XLabels.FocusSelection(OArray)
ActiveDocument.Sections["Chart"].XLabels.HideSelection(ZArray)
ActiveDocument.Sections["Chart"].XLabels.UnhideAll(ZArray)
Description: An object that represents a label value on the Y-axis. This object’s properties
directly affect the display of the label on the Z-axis and correspond to the
options provided on the Chart menu or shortcut menu.
✏ Note You must specify the label value(s) in an array before using the FocusSelection, HideSelection
and UnhideAll methods.
Example: The following example shows how to modify the label value on the Y-axis.
var OArray = new Array()
OArray[0]= ActiveDocument.Sections["Chart"].YLabels.LabelValues.Item(1)
OArray[1]= ActiveDocument.Sections["Chart"].YLabels.LabelValues.Item(3)
ActiveDocument.Sections["Chart"].YLabels.FocusSelection(OArray)
ActiveDocument.Sections["Chart"].YLabels.HideSelection(ZArray)
ActiveDocument.Sections["Chart"].YLabels.UnhideAll(ZArray)
9-114 Objects
ZAxisLabel (Object)
Description: An object that represents a charts Z-axis. This object’s properties directly affect
the display of the Z-axis label.
Example: The following example shows how to modify the properties of the Z-axis label.
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.AutoFrequency = true
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.LabelFrequency = 3
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.LabelText = “X Axis”
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.ShowLabel = true
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.ShowTickmarks = false
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.ShowValues = true
ActiveDocument.Sections["Chart1"].LabelsAxis.ZAxis.TickmarkFrequency = 4
Methods: None
Description: An object that represents a chart's Z-axis. This object's properties directly
affect the display of the Z-axis and the Z-Categories in the Outliner.
Example: In this example, a chart is built from scratch using the request items specified
in the query. First, all the items in the outliner are removed, and then the
specific items are added to the outliner.
ActiveDocument.Sections["Chart"].ZCategories.RemoveAll()
ActiveDocument.Sections["Chart"].ZCategories.Add("Product")
ActiveDocument.Sections["Chart"].ZCategories.Add("State")
9-116 Objects
ZLabels (Object)
Description: An object that represents a label value on the Z-axis. This object’s properties
directly affect the display of the label on the Z-axis and correspond to the
options provided on the Chart menu or shortcut menu.
✏ Note You must specify the label value(s) in an array before using the FocusSelection, HideSelection
and UnHideAll methods.
Example: The following example shows how to modify the label value on the Z-axis.
var OArray = new Array()
OArray[0]= ActiveDocument.Sections["Chart"].ZLabels.LabelValues.Item(1)
OArray[1]= ActiveDocument.Sections["Chart"].ZLabels.LabelValues.Item(3)
ActiveDocument.Sections["Chart"].Zlabels.FocusSelection(OArray)
ActiveDocument.Sections["Chart"].Zlabels.HideSelection(ZArray)
ActiveDocument.Sections["Chart"].Zlabels.UnhideAll(ZArray)
10-1
Activate (Method)
Description: The activate method is used to switch the focus of a document or section.
Syntax: Expression.Activate()
Expression Required: An expression that returns an object for any of the following:
ChartSection
DataModelSection
Document
EISSection
OLAPQuerySection
PivotSection
QuerySection
ReportSection
ResultsSection
Sections
TableSection
WebClientDocument
Example: The following example shows you how to unhide and activate a section.
var MySection = ActiveDocument.Sections["Results"]
MySection.Visible = true
MySection.Activate()
10-2 Methods
Add (Method)
Description: The Add() method is a common method for most collections. It adds an object
to a collection and returns a reference to the newly added object.
✏ Note The Add() method works differently for the LimitValues (AvailableValues, CustomValues, and
SelectedValues) Collections. For the AvailableValues collection, the Add() does nothing since
the values are obtained from the database. For the CustomValues collection, Add() adds an
additional value to the list. For the SelectedValues collection, Add() adds a value to the
selected list.
Expression Required: An expression that returns an object for any of the following:
CategoryItems
ChartSection
Columns
ControlsDropDown
ControlsListBox
Documents
Joins
Limits
LimitValues
LocalJoints
Example 1: The following example shows you how to create a new limit, add values to the
limit, and then add the limit to the limit line.
var MyLimit =
ActiveDocument.Sections["Query"].Limits.CreateLimit("Stores.Store_Id")
MyLimit.SelectedValues.Add(2)
ActiveDocument.Sections["Query"].Limits.Add(MyLimit)
Example 2: The following example shows you how to add values to a list box and
dropdown.
ActiveDocument.Sections["EIS2"].Shapes["DropDown1"].Add(20)
ActiveDocument.Sections["EIS2"].Shapes["ListBox1"].Add(1)
Example 3: The following example shows you how to add two new topics to a Data Model
and how to add a join between the topics.
var Topic1 =
ActiveDocument.Sections["Query"].DataModel.Catalog.CatalogItems["sales_fact"]
ActiveDocument.Sections["Query"].DataModel.Topics.Add(Topic1)
var Topic2 =
ActiveDocument.Sections["Query"].DataModel.Catalog.CatalogItems["Store_ID"]
ActiveDocument.Sections["Query"].DataModel.Topics.Add(Topic2)
var TopicItem1 =
ActiveDocument.Sections["Query"].DataModel.Topics
["SalesFact"].TopicItems["Store_Id"]
var TopicItem2 =
ActiveDocument.Sections["Query"].DataModel.Topics
["Stores"].TopicItems["Store_Id"]
ActiveDocument.Sections["Query"].DataModel.Joins.Add(TopicItem1,TopicItem2,
bqJoinSimpleEqual)
10-4 Methods
Example 4: The following example shows you how to add a Pivot section type to the
Results section.
✏ Note A Chart, Pivot, and Table section type must be associated with a parent section, such as
Results. A Query, EIS, or Report section type does not have to be associated with a parent
section.
ActiveDocument.Sections.Add(bqPivot,"Results")
Description: The AddAll() method of the SelectedValues collection allows you to select all
values from either the AvailableValues or CustomValues collection depending
on what is selected. Use this method in conjunction with the LimitValueType
property so that you can determine in advance which limit value set is selected.
The value associated with this property is a member of the constant group
called BqLimitValueType. Two possible values of BqLimitValueType:
bqLimitValueTypeAvailable and bqLimitValueTypeCustom.
✏ Note You can select a single value at a time using the Add() method of the SelectedValues
collection, however, you must know all the values in advance. This way of selecting a value can
become very tedious when there are a lot of values.
Syntax: Expression.SelectedValues.AddAll();
Example: In the following example, a "Quarter" limit is created and added to the limit
line in the Query section. Then, all available values in the Limit dialog box are
added.
//Adds a limit to the limit line of the Query section
mylimit =ActiveDocument.Sections["Query"].Limits.CreateLimit("Periods.Quarter")
mylimit.Operator=bqLimitOperatorEqual
ActiveDocument.Sections["Query"].Limits.Add(mylimit)
//Selects ALL Available values in the Limits dialog
ActiveDocument.Sections["Query"].Limits[1].SelectedValues.AddAll()
10-6 Methods
AddComputed (Method)
Example: The following example shows you how to create a computed column that
concatenates the string “Manager =” with the value in the Store_Manager
column.
var ComputedExpression = " \"Manager =\" + Store_Manager"
ActiveDocument.Sections["Results"].Columns.AddComputed("MyComputed",
ComputedExpression)
Description: Creates a computed item and returns an object that represents the new item.
This method allows you to specify the name, expression, and index for the
computed item.
Calculated items created in the Chart section are always facts and are placed in
the Y-Facts pane of the chart outliner.
The “name” is the name of the computed item and appears in the Y-Fact pane
of the Chart or Pivot Outliner and the Chart legend.
The expression you specify must be a valid BrioQuery expression that appears
in the Computed Items dialog box.
The optional index determines the computed item’s position in a particular
pane. For example, an index of “2” places it as the second item in the Y-Fact
pane.
Example: The following example shows you how to create a computed column titled
“Double Sales”, which doubles the amount in the Unit Sales column.
ActiveDocument.Sections["Chart"].Facts.AddComputedItem
(‘Double_Sales’, ‘Unit_Sales *2’,2)
10-8 Methods
AddExportSection (Method)
✏ Note You cannot export the Query, OLAPQuery, and DataModel sections.
Expression Required: An expression that returns an object for any of the following: ChartSection,
PivotSection, TableSection, and Section.
Example 1: The following example shows you how to export selected sections of a .bqy
document.
//Export SELECTED Sections of .bqy document
ActiveDocument.AddExportSection(‘Report’)
ActiveDocument.AddExportSection(‘Report2’)
ActiveDocument.AddExportSection(‘Results’)
ActiveDocument.AddExportSection(‘Table’)
ActiveDocument.AddExportSection(‘Pivot’)
ActiveDocument.AddExportSection(‘Pivot2’)
ActiveDocument.AddExportSection(‘Pivot3’)
ActiveDocument.AddExportSection(‘Chart’)
ActiveDocument.AddExportSection(’Chart2’)
ActiveDocument.AddExportSection(’OLAPQuery’)
ActiveDocument.Export(‘C;\\Temp\\MyExportFile.htm’, bqExportFormatHTML)
Example 2: In the following example, selected sections are set to be exported and then later
cleared from the export buffer. The Export method in the last part of the script
allows all sections in the document to be exported.
//Export SELECTED Sections of .bqy document
Documents["MyDocument.bqy"].AddExportSection(‘Report’)
Documents["MyDocument.bqy"].AddExportSection(‘Report2’)
Documents["MyDocument.bqy"].AddExportSection(‘Results’)
Documents["MyDocument.bqy"].AddExportSection(‘Table’)
Documents["MyDocument.bqy"].AddExportSection(‘Pivot’)
Documents["MyDocument.bqy"].AddExportSection(‘Pivot2’)
Documents["MyDocument.bqy"].AddExportSection(‘Pivot3’)
Documents["MyDocument.bqy"].AddExportSection(‘Chart’)
Documents["MyDocument.bqy"].AddExportSection(‘Chart2’)
Documents["MyDocument.bqy"].AddExportSection(’OLAPQuery’)
Documents["MyDocument.bqy"].Export(‘C;\\Temp\\MyExportFile.htm’,
bqExportFormatHTML)
10-10 Methods
ActiveDocument.RemoveExportSections();
//Export ALL sections of .bqy document since Export buffer was flushed
ActiveDocument.Export(‘C;\\Temp\\MyExportFile.htm’, bqExportFormatHTML)
Description: Adds a new filter value and returns an object that represents the new item.
✏ Note If you are using this method to apply a filter to a measure value, this method can only be used
against an Essbase database. In addition, you cannot use an alias.
Constants BqOperator
bqOperatorEqual
bqOperatorGreaterThan
bqOperatorGreaterThanOrEqual
bqOperatorLessThan
bqOperatorLessThanOrEqual
bqOperatorNotEqual
Example 1 The following example shows you how to add the new filter “AZ” item to the
side label.
OQPath = ActiveDocument.Sections["OLAPQuery"]
OQPath.SideLabels[1].AddFilterValue(‘AZ’,bqOperatorEqual)
OQPath.Process()
OQPath.Activate()
Example 2 The following example shows you how to add a filter value to a “Profit”
measure. In this example, the operator used equals 13,438.
10-12 Methods
ActiveDocument.Sections["OLAPQuery"].Measures["Profit"].AddFilterValue
('1',bqOperatorEqual,'13438')
Description: Creates an additional row or column containing the totals for all columns or
rows of the pivot.
Syntax: Expression.AddTotals()
Example 1: The following example shows you how to total the top label columns called
“Product ID.”
ActiveDocument.Sections["Pivot"].TopLabels["Product Id"].AddTotals()
Example 2: The following example shows you how to a total to the side label rows called
“Quarter.”
ActiveDocument.Sections["Pivot"].SideLabels["Quarter"].AddTotals()
10-14 Methods
Alert (Method)
Description: Displays a simple dialog box. Up to three buttons can be displayed on the
dialog with custom names. When the user selects a button, an integer is
returned corresponding to the number of the button. If the user selects button
#1, the number 1 is returned and so on.
Example: The following example shows you how to display an Alert dialog and process
the user’s response.
var ReturnVal =0
ReturnVal = Alert("Please press a button","Alert Title","One","Two","Three")
switch (ReturnVal)
{
case 1:
Alert("The user pressed the One button")
break;
case 2:
Alert("The user pressed the Two button")
break;
case 3:
Alert("The user pressed the Three button")
break;
default:
Alert("An error occurred!")
}
Description: Allows you to define a SQL Statement that is executed when the audit event is
triggered. That is, you record how BrioQuery, a database server, or network
resources are being used. When triggered, the SQL statements update an audit
log table, which the administrator can query independently to track and
analyze usage data.
Example 1: In this example, an audit event is triggered when the user logs ons.
ActiveDocument.Sections["Query"].DataModel.AuditSQl(bqAuditLogon,"Select username
from all_users")
Example 2: In this example, an audit event is triggered when the user logs off.
ActiveDocument.Sections["Query"].DataModel.AuditSQl(bqAuditLogoff,"Select
username from all_users")
10-16 Methods
Example 3: In this example, an audit event is triggered when “Process” is selected, but
before the SQL query statement is executed.
ActiveDocument.Sections["Query"].DataModel.AuditSQl(bqAuditPreProcess,"Select
username from all_users")
Example 4: In this example, an audit event is triggered when the final row in the result set
is retrieved to the client workstation.
ActiveDocument.Sections["Query"].DataModel.AuditSQl(bqAuditPostProcess,"Select
username from all_users")
Description: By default, BrioQuery truncates Pivot fact columns evenly and without regard
to the length or height of data values. Numeric data that does not fit within the
height or length of the cell is replaced with pound signs (#).To size the height
of a Pivot fact column automatically so that all values are displayed within the
column, use the AutoSizeHeight method.
Syntax: Expression.AutoSizeHeight()
Expression Required: An expression that autosizes the height of a Pivot Fact column.
Example: The following example shows you how auto size the height and the width of
the "Unit Sales" fact column.
ActiveDocument.Sections["Pivot"].Facts["Unit Sales"].AutoSizeHeight()
ActiveDocument.Sections["Pivot"].Facts["Unit Sales"].AutoSizeWidth()
10-18 Methods
AutoSizeWidth (Method)
Description: By default, BrioQuery truncates Pivot fact columns evenly and without regard
to the length or height of data values. Numeric data that does not fit within the
height or length of the cell is replaced with pound signs (#).To size the width of
a Pivot fact column automatically so that all values are displayed within the
column, use the AutoSizeWidth method.
Syntax: Expression.AutoSizeWidth()
Expression Required: An expression that autosizes the width of a Pivot Fact column.
Example: The following example shows you how auto size the height and the width of
the "Unit Sales" fact column.
ActiveDocument.Sections["Pivot"].Facts["Unit Sales"].AutoSizeWidth()
ActiveDocument.Sections["Pivot"].Facts["Unit Sales"].AutoSizeHeight()
Example: The following example calls the Beep function of the Kernal32.dll for 4 seconds
with 5000Hz:
var oLibrary;
oLibrary = LoadSharedLibrary("kernel32.dll");
oLibrary.Call("Beep", "UI,UI", 5000, 4000);
10-20 Methods
ChartThisPivot (Method)
Description: Creates a new chart section using the criteria defined in a Pivot section.
Syntax: Expression.ChartThisPivot()
Example: The following example shows you how to chart a pivot and then change the
display characteristics of the chart.
MyChart = ActiveDocument.Sections["Pivot"].ChartThisPivot()
MyChart.Title = "Chart Created from Pivot"
Description: Closes the document. This method is equivalent to selecting Close from the
File menu.
Example: The following example shows you how to close all the open documents in the
application.
var OpenDocs = Documents.Count
for (j = 1 ; j <= OpenDocs ; j++)
Documents[j].Close()
10-22 Methods
Connect (Method)
Description: Tries to establish a connection to the database using the criteria set in the
connection object.
Syntax: Expression.Connect()
Example: The following example shows you how to establish a connection with a
database using the connection object.
MyConnection = ActiveDocument.Sections["Query"].DataModel.Connection
MyConnection.Open("c:\\OCEs\\SampleDB.oce")
MyConnection.Username = "brio"
MyConnection.SetPassword("brio")
MyConnection.Connect()
Syntax: Expression.Copy()
Expression Required: An expression that returns an object for any of the following:
ChartSection
DataModelSection
EISSection
OLAPQuerySection
PivotSection
QuerySection
Section
TableSection
Example: The following example shows you how to copy an entire Results section to the
clipboard.
ActiveDocument.Sections["Results"].Copy()
10-24 Methods
CreateConnection (Method)
Description: Creates a stand-alone connection object. Use this method to create oce files,
which are not automatically associated with a Data Model.
CreateConnection() returns a connection object. Refer to the Connection
object for a complete list of its methods and properties.
Example: The following example shows you how to create a connection from scratch,
save it as an OCE and use it as the current connection. In this example, the
hostname uses the ODBC datasource name “Bookmart”.
var myCon = CreateConnection()
myCon.Api = bqApiODBC
myCon.Database = bqDatabaseODBC
myCon.HostName = "Bookmart"
myCon.SaveAs("c:\\temp\\bookmart.oce")
var MyQuery = ActiveDocument.Sections.Add(bqQuery)
MyQuery.DataModel.Connection.Open("c:\\temp\\bookmart.oce")
MyQuery.DataModel.Connection.Connect()
Description: Creates a date group from a Results or Table column. The data in the column
must be a date.
Syntax: Expression.CreateDateGroup()
Example: The following example searches through a result set for a date column and
creates a date group.
ColCount = ActiveDocument.Sections["Results"].Columns.Count
for (i = 1; i <= ColCount ; i++)
{
if ( ActiveDocument.Sections["Results"].Columns[i].DataType ==bqDataTypeDate)
ActiveDocument.Sections["Results"].Columns[i].CreateDateGroup()
}
10-26 Methods
CreateLimit (Method)
Description: Creates a stand alone limit object. Use the CreateLimit method to create new
limits. After creating the limit, complete its properties before adding it to the
limits collection.
✏ Note The argument for CreateLimit method is different for regular limits, computed item limits, and
aggregate limits. For regular limits the argument is a reference to the table topic and the topic
item, for example, CreateLimit(“Sales_Facts.Amount_Sales”). For both computed item limits
and aggregate limits the argument is a reference to the item’s Display Name on the request
line, for example, CreateLimit(“Request.Amount Sales”).
Example 1: The following example shows you how to create a results limit. When creating
a local (results) limit the value for the LimitItem parameter needs to be the
name of the column the limit is being applied to.
MyLimit = ActiveDocument.Sections["Results"].Limits.CreateLimit("State")
MyLimit.Operator = bqLimitOperatorEqual
MyLimit.CustomValues.Add("CA")
MyLimit.SelectedValues.Add("CA")
ActiveDocument.Sections["Results"].Limits.Add(MyLimit)
ActiveDocument.Sections["Results"].Limits[1].DisplayName = "State"
Example 2: The following example shows you how to create a query limit. When creating a
server (query) limit the value for the LimitItem parameter needs to be the
name of the Topic and the TopicItem the limit is being applied to in the form
"Topic.TopicItem".
MyLimit = ActiveDocument.Sections["Query"].Limits.CreateLimit("Pcw_Items.OS")
MyLimit.Operator = bqLimitOperatorEqual
MyLimit.CustomValues.Add("Windows")
MyLimit.SelectedValues.Add("Windows")
Example 3: The following example shows you how to create a query aggregate limit. When
creating a query aggregate limit the value for the LimitItem parameter needs to
be in the form of Request.DisplayName.
myLimit=ActiveDocument.Sections["SalesQuery"].AggregateLimits.CreateLimit
("Request.Amount Sales")
myLimit.Operator=bqLimitOperatorEqual
myLimit.CustomValues.Add("50")
myLimit.SelectedValues.Add("50")
ActiveDocument.Sections["SalesQuery"].AggregateLimits.Add(myLimit)
10-28 Methods
CustomSQLFrom (Method)
Description: Sets the FROM clause of an SQL statement prior to processing. The FROM
clause indicates the specific tables to reference when the SELECT statement is
processed.The CustomSQLFrom, the CustomSQLWhere, and the
ResetCustomSQL methods correspond to the edit SQL functionality in the
user interface's Custom SQL dialog. However, no Custom SQL dialog will
display when this method is executed.
Example: The following example sets the FROM clause and the WHERE clause,
processes the query, and then restores the original SQL statement.
//Set the FROM clause, Set the WHERE clause, PROCESS, and then RESET
SQLActiveDocument.Sections["Query"].CustomSQLFrom(‘FROM From.Sales_Fact,
From.Periods, From.Products’)
ActiveDocument.Sections["Query"].CustomSQLWhere(‘WHERE
(Periods.Day_Id=Sales_Fact.Day_Id AND
Products.Product_Id=Sales_Fact.Product_Id) AND (Periods.Quarter='Q1')’)
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Query"].ResetCustomSQL();
Example: The following example sets the FROM clause and the WHERE clause,
processes the query, and then restores the original SQL statement.
//Set the FROM clause, Set the WHERE clause, PROCESS, and then RESET
SQLActiveDocument.Sections["Query"].CustomSQLFrom(‘FROM From.Sales_Fact,
From.Periods, From.Products’)
ActiveDocument.Sections["Query"].CustomSQLWhere(‘WHERE
(Periods.Day_Id=Sales_Fact.Day_Id AND
Products.Product_Id=Sales_Fact.Product_Id) AND (Periods.Quarter='Q1')’)
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Query"].ResetCustomSQL();
10-30 Methods
Disconnect (Method)
Description: Drops the connection between the connection object and the datasource.
Syntax: Expression.Disconnect()
Example: The following example shows you how to disconnect from the database.
if (ActiveDocument.Sections["Query"].DataModel.Connection.Connected == true)
ActiveDocument.Sections["Query"].DataModel.Connection.Disconnect()
Description: The DoEvents() method halts a script from executing and switches control to
the operating-environment kernel so that the application can respond to
pending or queued events. This method is typically placed at the end of a for-
loop statement. It is usually included in a script that runs continuously and
displays live data.
Syntax: Application.DoEvents()
Example: The following script processes a query five times with limits. A DoEvents
method is included to display the applied limits each time the query is
processed.
function Wait(ms)
{
var oStart = new Date();
var oNow = new Date();
while (oNow.getTime() - oStart.getTime() < ms)
{
oNow = new Date() ;
DoEvents();
}
}
10-32 Methods
DrillInto (Method)
Example The following example shows you how to drill into the fourth axis label.
ActiveDocument.Sections["AllChart"].XLabels.DrillInto(4,"Territory")
Syntax: Expression.Duplicate()
Expression Required: An expression that returns an object for any of the following:
ChartSection
DataModelSection
EISSection
PivotSection
ReportSection
10-34 Methods
ExecuteBScript (Method)
Description: Executes BrioQuery’s old scripting language commands. By default, all old
scripts are wrapped by this function when they are converted from an old
document.
Description: Creates a new file with the information from a section object. Files can be
created using the standard data formats from the BqExportFileFormat
constant group.
Expression Required: An expression that returns an object for any of the following:
ChartSection
DataModelSection
EISSection
OLAPQuerySection
PivotSection
QuerySection
Section
TableSection
10-36 Methods
Example: The following example shows you how to export a Results section to HTML.
The first part of the script creates a computed column that displays the
contents of the “URL” columns as HTML HREFs.
//Call the JavaScript link() method to convert the string to HREFs
var ComputedExpression = "URL.link()"
ActiveDocument.Sections["Results"].Columns.AddComputed("Clickable
URLS",ComputedExpression)
ActiveDocument.Sections["Results"].Export("C:\\HTML\\MyResults.htm",
bqExportFormatHTML,false)
Description: Allows you to single out selected label value item(s), enabling you to
concentrate your view to particular item(s) of interest.
✏ Note You must specify the label value(s) item in an array before using the FocusSelection method.
Example The following example shows you how to include LabelValues items 1 and 3 in
an array and then focus them in the Chart.
var NewArray = new Array()
NewArray[0]=ActiveDocument.Sections["AllChart"].XLabels.LabelValues.Item(1)
NewArray[1]=ActiveDocument.Sections["AllChart"].XLabels.LabelValues.Item(2)
ActiveDocument.Sections["AllChart"].XLabels.FocusSelection(NewArray)
10-38 Methods
GetCell (Method)
Example: The following example shows you how to populate a listbox from the values in
a Results section.
var MyList = ActiveDocument.Sections["EIS"].Controls["ListBox"]
var RowCount = ActiveDocument.Sections["Results"].RowCount
var MyCol = ActiveDocument.Sections["Results"].Columns["State"]
for (j = 1 ; j <= RowCount ; j = j+1)
{
var Temp = MyCol.GetCell(j)
MyList.Add(Temp)
}
Description: Allows you to hide a chart fact. When this script is executed, the selected item
is removed from the Y-Facts area of the Chart Outliner,
Syntax: Expression.Hide()
Example The following example shows you how to hide the fact “Amount Sales.”
ActiveDocument.Sections["Chart"].Facts["Amount Sales"].Hide()
10-40 Methods
HideSelection (Method)
Description: Allows you to hide selected label value item(s), enabling you to concentrate
your view to selected item(s) of interest.
✏ Note You must specify the label value(s) item in an Array before using the HideSelection method.
Example The following example shows you how to include LabelValues items 1 and 3 in
an array and then hide them in the Chart.
var NewArray = new Array()
NewArray[0]=ActiveDocument.Sections["AllChart"].XLabels.LabelValues.Item(1)
NewArray[1]=ActiveDocument.Sections["AllChart"].XLabels.LabelValues.Item(2)
ActiveDocument.Sections["AllChart"].XLabels.HideSelection(NewArray)
Example: The following example shows how to import a comma separated data file.
var Filename = "C:\\Imports\SalesData.csv"
var MySection = ActiveDocument.Sections.ImportDataFile(Filename,
bqImportFormatCommaText)
10-42 Methods
ImportSQLFile (Method)
Description: Imports a complete SQL statement from a text file into an existing query, and
retrieves the data set from the database server. When the file is imported, it is
scanned to determine the number of columns that will be returned by the SQL,
with the request line becoming populated with a column indicator for each of
the columns. Using this feature, you can take advantage of SQL statements you
have already written.
Before using this method, be sure that you are connected to a database server.
The Query section to which you are importing the SQL must have no tables.
In addition, the SQL file to be imported must begin with a SELECT statement
and you should know the number of columns to be displayed in the Results
section.Once the SQL file has been imported into the query you can drag items
from the table onto the Request line, use the custom SQL feature, or display its
properties.The imported SQL file cannot be edited, but you can specify a user-
friendly name for the Request line item and identify its data type.
Example: The following example shows you how to set the imported SQL file name, and
process the query.
var Filename = "C:\\Program
Files\\Brio\\BrioQuery\\Samples\\SQLLoad\\SalesData.sql"var
MySection = ActiveDocument.Sections["Query"].ImportSQLFile(Filename, 2)
ActiveDocument.Sections["Query"].Process()
Syntax: Expression.OnInterruptQueryProcess()
10-44 Methods
Item (Method)
Description: This is the accessor function for all collections. Item is the default method used
by all collections. It returns the value of an item in a collection referred to by
the name or index.
Expression Required: An expression that returns an object for any of the following objects:
Column
Control
ControlsDropDown
ControlsListBox
DMCatalogItem
DMResults
Document
Join
LabelValues
Limit
LimitValues
ListSelection
LocalJoins
LocalResults
OLAPLabel
OLAPMeasure
Example: The following example shows you how to return the 3rd section, named
“Query”, in the current document.
var MySection = ActiveDocument.Sections.Item(3)
or
var MySection = ActiveDocument.Sections[3]
or
var MySection = ActiveDocument.Sections.Item("Query")
or
var MySection = ActiveDocument.Sections["Query"]
10-46 Methods
LoadFromFile (Method)
Example: The following example loads a list of values from a file named limits.txt into a
query limit on the “Store_Id” topic item.
var Filename = "d:\\LimitData.txt"
ActiveDocument.Sections["Query"].Limits["Store_Id"].LoadFromFile(Filename)
Example: The following example calls the Beep function of the Kernal32.dll for 4 seconds
with 5000Hz.
var oLibrary;
oLibrary = LoadSharedLibrary("kernel32.dll");
oLibrary.Call("Beep", "UI,UI", 5000, 4000);
10-48 Methods
ModifyComputed (Method)
Description: Enables you to reference an existing column and change its expression while
still maintaining the column name (that is, without having to delete and
recreate the column which might be used by other columns).
Example: The first part of the script adds four undefined computed columns. The
second part of the script resolves the errors in the computed columns.
//This expression causes the four computed items to become undefined
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 2");
ActiveDocument.Sections["Results"].Columns.AddComputed("Fours","Twice * 2")
ActiveDocument.Sections["Results"].Columns["Twice"].Remove()
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 3");
//This expression resolves the problem
ActiveDocument.Sections["Results"].Columns.AddComputed("Twice","Unit_Sales * 2");
ActiveDocument.Sections["Results"].Columns.AddComputed("Fours","Twice * 2")
ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Results"].Columns.ModifyComputed("Twice",
"Unit_Sales *3";
Example: The following example shows you how to create a new BrioQuery document.
var MyName = "JavaScript Test"
var MyDoc = Documents.New(MyName)
MyDoc.Save()
10-50 Methods
OnActivate (Method)
Description: The OnActivate() method is a BrioQuery section level function. This method
is available regardless of the state of the application and can be accessed
through scripting. The OnActivate() method will execute a script stored under
the OnActivate event trigger. The method takes no arguments. Any scripts
associated with the OnActivate method are executed when entering an EIS
section.
Expression Required: An expression that returns an object for any of the following:
ControlsCheckBox
CommandButton
ListBox
Radio ButtonGraphicsLine
Hz Line
Vt Line
Rectangle
Round Rectangle
Oval
Text Label
Picture
Embedded Section Objects
Query
Results
Pivot
Chart
Example: The following example displays the OnActivate method for an active EIS
section.
ActiveDocument.Sections["EIS"].OnActivate()
10-52 Methods
OnChange (Method)
Description: The OnChange() method is a BrioQuery EIS Object level function. This
method is only available when an EIS section is included in the BrioQuery
document, and the EIS section contains a text box.The OnChange() method
will execute a script stored in an EIS section text box under the OnChange
event trigger. The method takes no arguments.
Syntax: Expression.OnChange()
Example: The following example shows you how to associate an OnChange method in a
text box.
TextBox1.OnChange()
Description: Simulates a user click event. This method exhibits the same behavior as simply
clicking on a control. Any scripts associated with an onclick event are
triggered.
Syntax: Expression.Click()
Expression Required: An expression that returns an object for any of the following:
ControlsCheckBox
ControlsCommandButton
ControlsDropDown
ControlsOptionsButton
ControlsTextBox
Shape
Example: The following example shows you how to invoke a command buttons event
handler.
MyEIS = ActiveDocument.Sections["EIS"]
MyEIS.Controls["CommandButton1"].OnClick()
10-54 Methods
OnDeactivate (Method)
Description: The OnDeactivate() method is a BrioQuery EIS section level event. This
method is available regardless of the state of the application and can be
accessed through scripting. The OnDeactivate() method will execute a script
stored under the OnDeactivate event trigger. The method takes no
arguments.Any scripts associated with the OnDeactivate method are executed
when leaving an EIS section.
Example: The following example displays the DeActivate method for an active EIS
section.
ActiveDocument.Sections["EIS"].OnDeactivate()
Description: The OnDoubleClick() method is a BrioQuery EIS Object level function. This
method is only available when an EIS section is included in the BrioQuery
document and the EIS section contains a listbox.The OnDoubleClick()
method will execute a script stored in an EIS section listbox under the
OnDoubleClick event trigger. The method takes no arguments.
Example: The following example shows you how to associate an OnDoubleClick method
with a list box.
ListBox1.OnDoubleClick()
10-56 Methods
OnEnter
Description: The OnEnter() method is a BrioQuery EIS Object level function. This method
is only available when an EIS section is included in the BrioQuery document
and the EIS section contains a text box.
Example: The following example shows you how to activate a text box.
ActiveDocument.Sections["EIS2"].Shapes["Textbox1"].OnEnter()
OnEnter 10-57
OnExit
Description: The OnExit() method is a BrioQuery EIS Object level function. This method is
only available when an EIS section is included in the BrioQuery document and
the EIS section contains a text box.
Syntax: Expression.OnExit()
Example: The following example shows you how to exit a text box.
ActiveDocument.Sections["EIS2"].Shapes["Textbox1"].OnExit()
10-58 Methods
OnPostProcess (Method)
✏ Note Calling the Process() method from the OnPreProcess() or OnPostProcess() events can result in
an infinite loop.
Syntax: Expression.OnPostProcess()
Example: The following example displays the OnPostProcess method for the active
document.
ActiveDocument.OnPostProcess()
✏ Note Calling the Process() method from the OnPreProcess() or OnPostProcess() events can result in
an infinite loop.
Syntax: Expression.OnPreProcess()
Example: The following example displays the OnPreProcess method for the active
document.
ActiveDocument.OnPreProcess()
10-60 Methods
OnShutdown (Method)
✏ Note Any OnShutDown events are executed before you are prompted to save or discard changes
made to a document in the Save dialog box.
Example: The following example shows you how to use the OnShutdown() method to
exit a document without executing BrioQuery. The second line of the script
shows you how to turn off the Prompt to Save dialog box when an
OnShutdown() method is executed.
Documents["Eistrigger.bqy"].OnShutdown()
Application.Quit(false)
Example: The following example displays the OnStartup method for an active
document.
ActiveDocument.OnStartup()
10-62 Methods
Open (Method)
Example 1 The following example shows you how to open an existing BrioQuery
document.
var MyFile = "C:\\BQDocs\\JavaTest.bqy"
var MyDoc = Documents.Open(MyFile)
Alert(MyDoc.Name + " is open")
Example 2 The following example shows how to open an existing Open Catalog Extension
file.
var MyOCE = "C:\\BQDocs\\SQL.oce"
var MyCon = ActiveDocument.Sections["Query"].DataModel.Connection.Open(MyOCE)
MyCon.Username = "brio"
MyCon.SetPassword("brio")
MyCon.Connect()
Description: Requests the browser to open a URL specified by the “url” parameter. The
target parameter refers to the browser window where the new url should be
displayed. Target may be the name of a browser frame or a keyword referring to
a specific browser window.
Target Description
“_self ” The current browser window.
“_new” A new browser window.
✏ Note The OpenURL() method is only applicable for Web-based clients (Brio.Insight users).
Example: The following example shows you how to open a Web page in a new window.
if(Application.Name != "BrioQuery")
{
var MyURL = http://www.SeasonPass.com
Application.OpenURL(MyURL,"_new")
}
10-64 Methods
PivotThisChart (Method)
Syntax: Expression.PivotThisChart()
Example: The following example shows you how to change the BooksChart object into
the form of a Pivot report.
ActiveDocument.Sections["BooksChart"].PivotThisChart()
Description: Changes the position of a pivot label. By default, calling the PivotTo method
moves a pivot label from one label collection to another. PivotTo performs the
same action as selecting or deleting a pivot label out of one group and
reinserting into a different group.
Example: The following example shows you how to pivot a label from the top labels
collection to the 1st position in the side labels collection. The Index is an
optional property, which specifies where the label pivots. If the property is
empty then the pivot will place the label at the end of the list.
ActiveDocument.Sections["Pivot"].TopLabels["Year"].PivotTo(1)
10-66 Methods
PrintOut (Method)
Expression Required: An expression that returns an object for any of the following:
ChartSection
DataModelSection
OLAPQuerySection
PivotSection
QuerySection
Section
TableSection
Example: The following example shows you how to print multiple copies of a Pivot
section to the printer.
var StartPage = 1
var EndPage = 1
var NumCopies =2
ActiveDocument.Sections["Pivot"].PrintOut(StartPage,EndPage,NumCopies)
Description: Executes a query. This method is equivalent to selecting the Process Current
item from the Tools menu.
Syntax: Expression.Process()
Example: The following example shows you how to process every query in a document.
for (j =1; j <= ActiveDocument.Sections.Count; j++)
{
if (ActiveDocument.Sections[j].Type == bqQuery)
{
var MyCon = ActiveDocument.Sections[j].DataModel.Connection
MyCon.Username = "Brio"
MyCon.SetPassword("Brio")
MyCon.Connect()
ActiveDocument.Sections[j].Process()
Console.Writeln(ActiveDocument.Sections[j].Name + " was processed.")
}
}
10-68 Methods
ProcessStoredProc (Method)
Description: This method provides you with the option to process stored procedures to
obtain results.
This method is used in conjunction with the SetStoredProcParam (Method).
Syntax: Expression.ProcessStoredProc()
Example: The following example shows you how to open and process a stored procedure
in the Query section.
ActiveDocument.Sections["Query"].SetStoredProcParam("Param1",1)
ActiveDocument.Sections["Query"].SetStoredProcParam("Param2",2)
ActiveDocument.Sections["Query"].ProcessStoredProc()
Description: Executes the query and stores the results as a table on the database. Items on
the Request line become the column headings of the new table, and you can
append new columns to the table and query it as needed.
✰ Tip The connection file and database to which you are connecting determine
whether or not you can use this feature. You must also have Create and Insert
priviledges on the database in order to process to a database table.
Example 1: In this example, the results are stored in a new table entitled “MyTable.”
ActiveDocument.Sections["Query"].ProcessToTable(‘MyTable’, bqProcessCreateTable,
‘Public’)
10-70 Methods
Quit (Method)
✏ Note The Quit method will not shut down a browser window.
Description: Forces a section to recalculate itself. Use this method to force a section to
recalculate. This is particularly important if you are using variables in
computed columns.
Syntax: Expression.Recalculate()
Expression Required: An expression that returns an object for the Results and Table sections.
Example: The following example forces a Results section to recalculate its values.
ActiveDocument.Sections["Results"].Recalculate()
10-72 Methods
Refresh (Method)
Syntax: Expression.Refresh()
Example: The following example shows you how to refresh the items in the table catalog.
ActiveDocument.Sections["Query"].Catalog.Refresh()
Description: Generates a list of values for a limit. This method is equivalent to clicking the
“Show Values” button on the Limit dialog box.
Syntax: Expression.RefreshAvailableValues()
Example: The following example shows how to update the available values for the “Unit
Sales” limit.
ActiveDocument.Sections["SalesQuery"].Limits["Unit Sales"].
RefreshAvailableValues()
10-74 Methods
RefreshDataNow (Method)
Syntax: Expression.RefreshDataNow()
Expression Required: An expression that returns an object for the Pivot or Chart sections.
Example: In the following example, the Pivot section is set to be refreshed manually and
immediately when the command is executed.
ActiveDocument.Sections["Pivot"].RefreshData=bqRefreshDataManually
ActiveDocument.Sections["Pivot"].RefreshDataNow()
Description: Removes an individual item from the CategoryItems collection. In all other
cases, Remove is called without a name or index to delete an individual object.
10-76 Methods
QuerySection
Request
Section
TableSection
Topic
Example: The following example shows you how to remove the “Product ID” column
from a Results section
ActiveDocument.Sections["Results"].Columns[Product Id].Remove()
Syntax: Expression.RemoveAll()
Expression Required: An expression that returns a collection for any of the following:
Limits
AxisLabels
CategoryItems
Columns
ControlsDropDown
ControlsListBox
Join
LimitValues
LocalJoins
OLAPLabels
OLAPMeasures
OLAPSlicers
Requests
Topics
Example: The following example shows how to remove every column from a Results or
Table section.
ActiveDocument.Sections["Results"].Columns.RemoveAll()
10-78 Methods
RemoveExportSection (Method)
Description: When sections are exported successfully, the Export() method clears the export
buffer. If sections are unsuccessful in being exported, then use this method to
flush the export buffer. All sections set for export are cleared from the export
buffer. For instance, if you specify a Report, Pivot, and Chart section to be
exported via the AddExportSection() method, a call to
RemoveExportSections() would nullify the section set up for export. You could
then specify the Export() method to export all sections.
Syntax: Expression.RemoveExportSections()
Example: In the following example, sections are set to be exported using the
AddExportSection () method, then cleared from the export buffer using the
Remove ExportSections() method, and then all of the documents sections are
exported using the Export ()method.
//Export SELECTED Sections of .bqy document
ActiveDocument.AddExportSection(‘Report’)
ActiveDocument.AddExportSection(‘Report2’)
ActiveDocument.AddExportSection(‘Results’)
ActiveDocument.AddExportSection(‘Table’)
ActiveDocument.AddExportSection(‘Pivot’)
ActiveDocument.AddExportSection(‘Pivot2’)
ActiveDocument.AddExportSection(‘Pivot3’)
ActiveDocument.AddExportSection(‘Chart’)
ActiveDocument.AddExportSection(’Chart2’)
ActiveDocument.AddExportSection(’OLAPQuery’)
//Flushes the Export buffer
ActiveDocument.RemoveExportSections()
//Export ALL sections of .bqy document since Export buffer was flushed
ActiveDocument.Export(‘C;\\Temp\\MyExportFile.htm’, bqExportFormatHTML)
Description: Resets the original SQL statement prior to processing. This CustomSQLFrom,
CustomSQLWhere and ResetCustomSQL methods correspond to the edit SQL
functionality in the user interface's Custom SQL dialog. However, no Custom
SQL dialog will display when this method is executed.
Example: The following example sets the From clause and the Where clause, processes
the query, and then restores the original SQL statement.
//Set the FROM clause, Set the WHERE clause, PROCESS, and then RESET SQL
ActiveDocument.Sections["Query"].CustomSQLFrom(‘FROM From.Sales_Fact,
From.Periods, From.Products’)
ActiveDocument.Sections["Query"].CustomSQLWhere(‘WHERE (Periods.Day_Id=Sales_Fact
.Day_Id AND Products.Product_Id=Sales_Fact.Product_Id)
AND
(Periods.Quarter='Q1')’)ActiveDocument.Sections["Query"].Process()
ActiveDocument.Sections["Query"].ResetCustomSQL();
10-80 Methods
ResizeToBestFit (Method)
Description: Changes the width of a column to fit the data without clipping any
information or displaying too much white space.
Syntax: Expression.ResizeToBestFit()
Example: The following example shows you how to change all the columns in a result set
to best fit the data.
for (j =1; j < = ActiveDocument.Sections["Results"].Columns.Count; j++)
ActiveDocument.Sections["Results"].Columns[j].ResizeToBestFit()
Syntax: Expression.Save()
Expression Required: An expression that returns an object for any of the following:
Connection
Document
WebClientDocument
Example: The following example shows you how to create a new BrioQuery document
and save it.
var MyDocs = "c:\\Mydocs"
var MyName = "JavaScript Test"
var MyDoc = Documents.New(MyName)
MyDoc.Save()
10-82 Methods
SaveAs (Method)
Description: Saves a document or Open Catalog Extensions file with a new name and/or
location.
Expression Required. An expression that returns an object for any of the following:
Connection
Document
WebClientDocument
Example: The following example shows you how to save a document using a different
name.
var MyDocs = "c:\\Mydocs"
var MyName = "JavaScriptTest.bqy"
var MyFilename = MyDocs + "\\"+ MyName
ActiveDocument.SaveAs(MyFilename)
Expression Required: An expression that returns an object for any of the following:
ControlsDropDown
ControlsListBox
ControlsTextBox
Example: The following example shows you how to set the selection of one dropdown
list based selected index in another dropdown list.
var MyIndex = DropDown1.SelectedIndex=1
DropDown2.Select(MyIndex)
10-84 Methods
SendSQL (Method)
Description: Sends a SQL string to a datasource. No data is retrieved from the database.
Currently, this will not send a SQL statement to the same database session to
which your query is connected.
✏ Note If your SendSQL string is sending data modification commands, your database may require a
commit statement. The commit behavior of the database may restrict which type of SQL string
you may be able to send.
Since the SendSQL method requires an .oce as an argument, it does not apply to a script
written specifically for Brio.Insight.
Example: The following example shows you how to send a SQL Statement to a database
associated with an OCE.
var SQL = "insert into test (store_id, store) values (2, 'Computer City')"
var OCE = "c:\\OCEs\\Oracle.oce"
var user = "brio"
var pass = "brio"
Application.SendSQL(OCE,user,pass,SQL)
Description: Sets the OnDemand Server password. This method is a Web-enabled method
and does not apply to BrioQuery. It can be used to automate logging on to the
OnDemand Server.
Example: The following example shows you how to set the OnDemand Server Password
from a password field in an EIS section. The name of the password field is
TextBox1.
var MyPass = TextBox1.Text
if (Application.Name != "BrioQuery")
ActiveDocument.SetODSPassword(MyPass)
10-86 Methods
SetPassword (Method)
Description: Sets the password that is used by the Open Catalog Extension when connecting
to the database.
✏ Note It is very important that you enclose the password with parentheses. If you don’t, the string is
created as a variable and there is no way to unassign it.
Example: The following example shows you how to set the Password from a password
field in an EIS section. The name of the password field is TextBox1.
var MyPass = TextBox1.Text
if (Application.Name != "BrioQuery")
ActiveDocument.Sections["Query"].DataModel.Connection.SetPassword(MyPass)
Description: This method provides you with the option to programmatically set up (select)
stored procedures for obtaining results.
The optional index parameter specifies the nth position in the stored
procedure argument list (with the first parameter being indexed at 1). If no
index value is provided, the assumed order is the order in which they are
defined (again, beginning at 1). If there is a mix of some method calls with the
index value and some without, the order will be those with indexes first
followed by definition order of those without indexes.
This method is used in conjunction with the ProcessStoredProc (Method).
Example: The following example shows you how to open and process a stored procedure
in the Query section.
ActiveDocument.Sections["Query"].SetStoredProcParam("Param1",1);
ActiveDocument.Sections["Query"].SetStoredProcParam("Param2",2);
ActiveDocument.Sections["Query"].ProcessStoredProc();
10-88 Methods
Shell (Method)
Description: Launches an external application and passes a command line argument to the
application.
Description: Sets a data value (rather than "label") criterion in the sort conditions available
in the Pivot and Chart sections. This method corresponds to the Sort by Values
feature in the Pivot and Chart report sections where the second list selection
orders each value of the target item specified in the first list selection by its
corresponding numeric value in the second list.
Example: The following example shows you how to sort the Product Name item by its
corresponding numeric value "Amount Sales".
ActiveDocument.Sections["Pivot2"].TopLabels["Product Name"].SortByFact("Amount
Sales", bqSortFunctionSum, bqSortAscend)
10-90 Methods
SortByLabel (Method)
Description: Sets the primary sort criterion on an item by label or name, rather than by
reference to corresponding numeric data values. This method corresponds to
the Sort by Labels feature in the Pivot and Chart report sections
Constants: The BqSort Order constant group contains the following values:
bqSortAscend
bqSortDescend
Example: The following example shows you how to sort the top labels "Product Name"
by region.
ActiveDocument.Sections["Pivot2"].TopLabels["Product Name"].
SortByLabel(bqSortAscend)
Description: Sets the Sort Now feature on items placed on the Sort Line in Results. The Sort
Now feature initiates the sorting function immediately on items on the Sort
Line.
Syntax: Expression.SortNow()
Example: The following example shows you how to use the SortNow method for items
on the Sort Line in the Results section.
ActiveDocument.Sections["Results"].SortItems.SortNow()
10-92 Methods
SyncWithDatabase (Method)
Description: Causes a Data Model to synchronize itself with the underlying database tables.
Syntax: Expression.SyncWithDatabase()
Example: The following example shows you how to synchronize a Data Model with the
database.
var MyDM = ActiveDocument.Sections["Datamodel"].DataModel
MyDM.SyncWithDatabase()
Description: Allows you to restore all hidden label value item(s) that are hidden through the
HideSelection and FocusSelection methods.
Syntax: Expression.XLabels.UnhideAll()
Example The following example shows you how to unhide all label value items on the
Xlabels.
ActiveDocument.Sections["AllChart"].XLabels.UnhideAll()
10-94 Methods
Unselect (Method)
Description: Causes an item in a list box to be unselected whether it has been selected or
not.
Dependency The Multiple Select property must be enabled for the ListBox object in order to
use this method.
Example: In the following example, a listbox has been populated with four values, which
can all be selected and counted in a text box. The Unselect method has been
added for each of the four values and any out of bound values.
//Selects all values in ListBox1 and performs a count
var cnt = ListBox1.Count
for (var i = 1; i <= cnt; i++)
{
ListBox1.Select(i)
}
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects first index value in ListBox1
ListBox1.Unselect(1)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects second index value in ListBox1
ListBox1.Unselect(2)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects third index value in ListBox1
ListBox1.Unselect(3)
TextBox1.Text=ListBox1.SelectedList.Count
//Unselects fourth index value in ListBox1
ListBox1.Unselect(4)
TextBox1.Text=ListBox1.SelectedList.Count
Syntax: Expression.UseAlternateMetadataLocation(Value As
Boolean, [MetadataOce As String])
Example: The following example shows you how to change the metadata location for the
current Data Model.
var MyDM = ActiveDocument.Sections["DataModel"].DataModel
var MyOCE = "c:\\OCEs\\MetaOracle.oce"
MyDM.Connection.UseAlternatieMetadataLocation(true,MyOCE)
10-96 Methods
Write (Method)
Description: Prints the output text specified by the OutputData parameter to the console
window.
Example: The following example shows you how to print the names of document
sections on a single line.
Console.Write(ActiveDocument.Name +"'s sections are: ")
for (j=1; j < ActiveDocument.Sections.Count; j++)
Console.Write(ActiveDocument.Sections[j].Name + ", ")
Description: Prints the output text specified by the OutputData parameter to the console
window and puts a new line after the inserted text.
Example: The following example shows you how to print the names of document
sections on individual lines.
Console.Writeln(ActiveDocument.Name +"'s sections are: ")
for (j=1; j < ActiveDocument.Sections.Count; j++)
Console.Writeln("Section #"+j +" = " +ActiveDocument.Sections[j].Name)
10-98 Methods
11 Properties
11-1
Active (Property)
Description: Section Object: Returns true if the section object refers to the current section;
otherwise, false.
Document Object: Returns true if the document object refers to the current
document; otherwise, false.
Example: The following example shows you how to find the active section in the
document.
var SectionCount = ActiveDocument.Sections.Count
for(j = 1 ; j <= SectionCount ; j++)
{
if(ActiveDocument.Sections[j].Active == true)
Alert (“The Active section is “+ActiveDocument.Sections[j].Name)
}
11-2 Properties
AdaptiveState (Property)
Description: Returns the current Adaptive state mode to which plug-in belongs.
Action: Read-only
Example: The following example shows you how to use the AdaptiveState property to
conditionally execute certain scripts.
var CurState = ActiveDocument.AdaptiveState
if( CurState == bqStateAnalyzeOnly || CurState == bqStateViewOnly)
ActiveDocument.Sections[“Start Here”].Activate()
else
ActiveDocument.Sections[“Query”].Activate()
Description: Returns or sets the horizontal alignment of the text in a column or shape.
Action: Read-write
Example: The following example shows how to change the horizontal alignment of text
in a column.
var MyResults=ActiveDocument.Sections["SalesResults"]
var ColCount = MyResults.Columns.Count
for (j = 1 ; j <= ColCount ; j++)
if (MyResults.Columns[j].DataType == bqDataTypeString)
MyResults.Columns[j].Alignment = bqAlignLeft
else
MyResults.Columns[j].Alignment = bqAlignRight
11-4 Properties
AllowNonJoinedQueries (Property)
Example: The following example opens a connection file named, SQL.oce, sets the
username and password, changes the connection file to support nonjoined
topics, and connects to the data source.
ActiveDocument.Sections["Query"].DataModel.Connection.Open("c:\\OCEs\\SQL.oce")
ActiveDocument.Sections["Query"].DataModel.Connection.Username = "brio"
ActiveDocument.Sections["Query"].DataModel.Connection.SetPassword("briobrio")
ActiveDocument.Sections["Query"].DataModel.Connection.AllowNonJoinedQueries =
true
ActiveDocument.Sections["Query"].DataModel.Connection.Connect()
Description: Returns or sets the value of the API associated with a connection file.
Action: Read-write
Example: The following example shows you how to create a connection file from scratch
and save it to a local file.
var myCon
myCon = Application.CreateConnection()
myCon.Api =bqApiSQLNet
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("C:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\PlutoSQL.oce")
//Now use this connection in a datamodel
ActiveDocument.Sections["SalesQuery"].DataModel.Connection.Open("C:\\Program
Files\\Brio\\BrioQuery\\Program\\Open Catalog Extensions\\PlutoSQL.oce")
11-6 Properties
AutoAlias (Property)
Example: The following example shows you how to activate AutoAliasing and
AutoJoining.
ActiveDocument.Sections["Query"].DataModel.AutoAlias = true
ActiveDocument.Sections["Query"].DataModel.AutoJoin = true
Description: Returns or sets the value of a connection object Autocommit property. Set this
property to false if your database does not support Autocommit.
Example: The following example shows you how to create a connection from scratch and
save it to a local file.
var myCon
myCon = Application.CreateConnection()
myCon.Api =bqApiSQLNet
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.AutoCommit = false
myCon.SaveAs("C:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\PlutoSQL.oce")
//Now use this connection in a datamodel
ActiveDocument.Sections["SalesQuery"].DataModel.Connection.Open("C:\\Program
Files\\Brio\\BrioQuery\\Program\\Open Catalog Extensions\\PlutoSQL.oce")
11-8 Properties
AutoFrequency (Property)
Description: Returns or sets the value of a chart objects’ AutoFrequency object. This
property enables/disables the chart function to choose automatically the
display frequency on the X-axis.
Example: The following example shows you how to change a chart X-axis to support
Auto Frequency.
ActiveDocument.Sections["Chart"].LabelsAxis.XAxis.AutoFrequency = true
Description: Returns or sets the value of a chart objects AutoInterval property. This
property enables/disables the chart function to choose automatically the data
interval on the left axis.
Example: The following example shows you how to change a charts left-axis to support
auto interval.
ActiveDocument.Sections["Chart"].ValuesAxis.LeftAxis.AutoInterval = true
11-10 Properties
AutoJoin (Property)
Description: Returns or sets the value of a Data Model objects AutoJoin property. This
property enables/disables the Data Model function to create automatic joins
between topics that are added to it.
Example: The following example shows you how to turn on Auto Aliasing and Auto
Joining.
ActiveDocument.Sections["Query"].DataModel.AutoAlias = true
ActiveDocument.Sections["Query"].DataModel.AutoJoin = true
Description: Returns or sets the value of a Query Section objects AutoProcess property. This
property enables/disables a query’s ability to automatically process itself when
it is opened or downloaded from the repository.
11-12 Properties
AutoScale (Property)
Description: Returns or sets the value of a chart axis’s AutoScale property. This property
enables/disables a chart axis’s ability to automatically determine the best scale.
Example: The following example enables Autoscaling on the left and right values axis.
ActiveDocument.Sections["Chart"].ValuesAxis.LeftAxis.AutoScale = true
ActiveDocument.Sections["Chart"].ValuesAxis.RightAxis.AutoScale = true
Description: Returns a collection of values that represent the entire list of valid criteria for a
limit.
Action: Read-only
Example: The following example shows you how to take every value from the
AvailableValues collection and add them to the SelectedValues collection. This
is essentially the same as performing a select all values and transferring the
selection in the Limit User Interface.
LimitCount = ActiveDocument.Sections[“Results”].Limits[1].AvailableValues.Count
for (i=1;i<=LimitCount;i++)
{
MyVal = ActiveDocument.Sections[“Results”].Limits[1].AvailableValues[i]
ActiveDocument.Sections[“Results”].Limits[1].SelectedValues.Add(MyVal)
}
11-14 Properties
AxisPlotValues (Property)
Description: Returns or sets the axis plot value of each fact in a line Chart. This property
corresponds to the features on the Line Chart Axis Properties dialog box.
Action: Read-write
Example: The following example shows you how to set the axis plot value to the primary
or left axis.
ActiveDocument.Sections["Chart"].Facts["Unit_Sales"].AxisPlotValue=
bqChartAxisPlotPrimary
Description: Returns an enumerated type that represents the type of axis (X, Y or Z).
Action: Read-only
Example: The following code shows how to determine the type of chart axis.
switch(ActiveDocument.Sections["Chart"].XCategories.AxisType )
{
case bqChartXAxis:
Alert(“The axis is X)
Break
case bqChartYAxis:
Alert(“The axis is Y)
Break
case bqChartZAxis:
Alert(“The axis is Z)
Break
}
11-16 Properties
ChartType (Property)
Description: Returns or sets the type of chart. This property controls which type of chart is
displayed in the chart section.
Action: Read-write
Example: The following example shows you how to change chart properties based on the
type of chart.
if (ActiveDocument.Sections["Chart"].ChartType == bqChartTypeBarLine)
{
ActiveDocument.Sections["Chart"].BarLineChart.ClusterBy = bqClusterByZ
ActiveDocument.Sections["Chart"].BarLineChart.IgnoreNulls = false
ActiveDocument.Sections["Chart"].BarLineChart.ShiftPoints = bqShiftCenter
ActiveDocument.Sections["Chart"].BarLineChart.StackClusterType = bqBarLineCluster
ActiveDocument.Sections["Chart"].BarLineChart.ShowBarValues = false
}
Description: Returns or sets the selection of a check box or radio button controls.
Example: The following example shows you how to change the selection of a Radio
button or check box. This script assumes that you are running in the same EIS
as two controls: RadioButton1, CheckBox1.
if (RadioButton1.Checked ==true)
CheckBox1.Checked = false
else
CheckBox1.Checked = true
11-18 Properties
Clusterby (Property)
Description: Returns or sets the type of clustering used when displaying Bar or Bar Line
charts.
Action: Read-write
Example: The following example shows you how to cluster the data according to the
values on the Z-axis.
ActiveDocument.Sections["Chart"].BarChart.ClusterBy = bqClusterByZ
Description: Returns or sets the color of text associated with a font object. The color
property may be set using the values in the BqColorType constant group or by
using a hexadecimal number that represents a RGB color value.
Action: Read-write
Constants: The following values are some of the values that are contained in the
BqColorType constant group. For a complete list see the BrioQuery object
model Script Editor.
bqAqua
bqBlack
bqBlue
bBlueGray
bqBrightGreen
bqBrown
bqDarkBlue
bqDarkYellow
bqLightBlue
bqLightOrange
bqWhite
bqYellow
Example: This example shows you how to set the color, width and dash style of the
border of an EIS text label box.
MyColor = ActiveDocument.Sections["EIS"].Shapes["TextLabel"]
MyColor.Line.Color = bqRed
MyColor.Line.Width = 4
MyColor.Line.DashStyle = bqDashStyleDotDotDash
11-20 Properties
ColumnType (Property)
Description: Returns a value that represents the type of Results or Table column. Possible
column types are: Normal, Computed, Date and Grouped.
Action: Read-only
Example: The following example shows you how to determine the column type in a
Results section.
for (j = 1 ; j < = ActiveDocument.Sections[“Results”].Columns.Count ;j++)
{
MyCol = ActiveDocument.Sections[“Results”].Column[j].
switch (MyCol.Type)
{
case bqComputedColumn:
Alert (“The column named “+MyCol.Name + “ is a Computed column”)
Break
case bqDateColumn:
Alert (“The column named “+MyCol.Name + “ is a Date column”)
Break
case bqGroupedColumn:
Alert (“The column named “+MyCol.Name + “ is a Grouped column”)
Break
case bqStandardColumn:
Alert (“The column named “+MyCol.Name + “ is a Standard column”)
Break
}
Description: Returns a value that represents the current connection status of a connection
object. Returns true if the user is connected to the data source; otherwise, false.
Example: The following example shows how to check the connection status of a
connection object and prompt the user to connect.
var MyCon =ActiveDocument.Sections["SalesQuery"].DataModel.Connection
if (MyCon.Connected ==false)
{
if (Alert
("Do you want to connect to the database?", "Get Connected"," Yes"," No")==1)
MyCon.Connect()
}
11-22 Properties
Count (Property)
Description: Returns a value that represents the number of items in a collection. The count
property is a standard property of all collections.
Example: The following example shows you how to determine the number of sections in
a document and the number of columns in a Results section.
var NumSections = ActiveDocument.Sections.Count
var NumColumns = ActiveDocument.Sections[“Results”].Columns.Count
Description: Returns a value that represents the working directory of the application. The
working directory specifies the path used by BrioQuery when using relative
referencing.
Example: The following example shows you how to change the working directory of the
application.
11-24 Properties
CustomSQL (Property)
Example: The following example shows you how to set the value of the custom SQL for a
limit.
var SQLString = “SELECT Name From Customers WHERE Cust_ID > 200”
ActiveDocument.Sections[“Query”].Limits[1].CustomSQL = SQLString
Description: Returns a collection of values that represent the entire list of custom values for
a limit.
Action: Read-only
Example: The following example shows you how to add all of the values from the
CustomValues collection to the SelectedValues collection. This is essentially the
same as performing a select custom values in the Custom Values list of the
Limit User Interface.
LimitCount =
ActiveDocument.Sections["SalesResults"].Limits["Amount Sales"].CustomValues.Count
for (i=1;i<=LimitCount;i++)
{
MyVal =
ActiveDocument.Sections["SalesResults"].Limits["Amount Sales"].CustomValues.
Item(i)
ActiveDocument.Sections["SalesResults"].Limits["Amount Sales"].SelectedValues.
Add(MyVal)
}
11-26 Properties
DashStyle (Property)
Description: Returns or sets the type of border style for a shape or control.
Action: Read-write
Example: The following example shows you how to change border color, width and the
dash style of a rectangle.
MyRectangle = ActiveDocument.Sections["EIS"].Shapes["Rectangle"]
MyRectangle.Line.Color = bqRed
MyRectangle.Line.Width = 4
MyRectangle.Line.DashStyle = bqDashStyleDotDotDash
Description: Returns or sets the name of the database vendor and version number.
Action: Read-write
Constants: The following values are some of the values that are contained in the
BqDataBase constant group. For a complete list see the BrioQuery object
model Script Editor.
bqDatabaseAS400
bqDatabaseBroadbase
bqDatabaseDB2Olap
bqDatabaseEssbase6
bqDatabaseInformix7
bqDatabaseSQLServer7
bqDatabasenone
bqDatabaseODBC
bqDatabaseOracle8
bqDatabaseRedBrick5Warehouse
bqDatabaseSybaseSystem11
bqDatabaseTeraData
11-28 Properties
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api =bqApiSQLNet
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("C:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\PlutoSQL.oce")
//Now use this connection in a datamodel
ActiveDocument.Sections["SalesQuery"].DataModel.Connection.Open("C:\\Program
Files\\Brio\\BrioQuery\\Program\\Open Catalog Extensions\\PlutoSQL.oce")
Description: Returns or sets the list of databases to which the OCE can connect..
Example:
var myCon
myCon = Application.CreateConnection()
myCon.Api =bqApiSQLNet
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DatabaseList = “master, customer, sales”?????????
myCon.SaveAs("C:\\Program Files\\Brio\\BrioQuery\\Program\\Open Catalog
Extensions\\PlutoSQL.oce"
11-30 Properties
DatabaseName (Property)
Description: Returns the name of the database associated with a table in the table catalog.
Action: Read-only
Example: The following example prints out the name of the database for each table in the
Table Catalog.
var TableCatalog = ActiveDocument.Sections["SalesQuery"].DataModel.Catalog
var TableCount = ActiveDocument.TableCatalog.CatalogItems.Count
for (j=1;j<=TableCount;j++)
Console.Writeln (TableCatalog.CatalogItems[j].Name)
Description: Returns aggegrate values which summarize groupings of data when applied to
Chart and Pivot facts. In the user interface, data functions are available from
the right-click menu and Chart and Pivot menus only if a fact value is selected.
Data functions are particularly useful when you need to show the kind of value
represented in the Chart and Pivot report. For example, you can show the total
sale, average sale, and maximum sale of each product by Quarter. The
supported data functions for Pivot and Chart Facts are:
Sum (default function)
Average
Count
Maximum
Minimum
Percent Grand
Percent Column
Percent Row
Null Count
Non-Null Count
Action: Read-only
11-32 Properties
Constants: The DataFunction property uses the BqDataFunction constant. The
BqDataFunction constant consists of the following values:
bqDataFunctionAverage
bqDataFunctionCount
bqDataFunctionIncrease (Pivot Totals properties, not Facts)
bqDataFunctionMaximum
bqDataFunctionMinimum
bqDataFunctionNone
bqDataFunctionNonNullAverage
bqDataFunctionNonNullCount
bqDataFunctionNullCount
bqDataFunctionPercentOfColumn
bqDataFunctionPercentOfRow
bqDataFunctionPercentofGrand (For Totals, not Facts)
bqDataFunctionSum
Example: The following example shows you how to set the "Product Line" TopLabels
column in the Pivot section to the average data function.
ActiveDocument.Sections["SalesPivot"].TopLabels["Product Line"].Totals[2].
DataFunction=bqDataFunctionAverage
Action: Read-only
Example: This script example returns the data type associated with all columns in a
Results section.
var ColCount = ActiveDocument.Sections[“Results”].Columns.Count
for (j = 1 ; j <= ColCount ; j++)
{
Console.Writeln(ActiveDocument.Sections[“Results”].Columns[j].DataType)
}
11-34 Properties
DBLibAllowChangeDatabase (Property)
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DBLibAllowChangeDatabase = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: DB-Lib only. Returns or sets the value of the DBLibApiSeverity property.
Changes the API’s error level severity.
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DBLibApiSeverity = 2
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-36 Properties
DBLibDatabaseCancel (Property)
Description: DB-Lib only. Returns or sets the value of the DBLibDatabaseCancel property.
Changes the Database cancel options.
Action: Read-write
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DBLibDatabaseCancel = bqDbLibPrompt
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: DB-Lib only. Returns or sets the value of the DBLibPacketSize property.
Changes the packet size of the query.
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DBLibPacketSize = 200
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-38 Properties
DBLibServerSeverity (Property)
Description: DB-Lib Only. Returns or sets the value of the DBLibServerSeverity property.
Changes the Server’s error level severity.
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.DBLibServerSeverity = 2
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
Var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
MyCon.HostName ="PlutoSQLSVR"
MyCon.DBLibUseQuotedIdentifiers = true
MyCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-40 Properties
DBLibUseSQLTable (Property)
Description: DB-Lib Only. Returns or sets the value of the DBLibUseSQLTable property. If
enabled the connection will use SQL to get tables.
Example: The following example shows how to create a new connection (OCE) from
scratch using JavaScript.
var myCon
myCon = Application.CreateConnection()
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
MyCon.HostName ="PlutoSQLSVR"
MyCon.DBLibUseSQLTable = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: Returns or sets the description associated with an Open Catalog Extension
(OCE).
Example: The following example creates a connection file from scratch and then applies
it to the current document.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-42 Properties
Display (Property)
Description: Returns the display value of a corner or data label. The Display property uses
the BqPivotLabelDisplay constant. Valid options for displaying the label are
side, top, both or none. The default corner label value is none.
Example: The following example shows you how to return a corner label at the top of the
pivot report .
ActiveDocument.Sections["SalesPivot"].CornerLabels.
Display=bqPivotLabelDisplayBoth
Description: Returns or sets the display name of one the objects listed above.
Example: The following example writes the names of all the topics and topic items to the
console window.
var Tcount = ActiveDocument.Sections[“Query”].DataModel.Topics.Count
for (j = 1; j <= Tcount ; j ++)
{
var myTopic = ActiveDocument.Sections[“Query”].DataModel.Topics[j]
Console.Writeln(“Topic : “+myTopic.PhysicalName)
var TICount =
ActiveDocument.Sections[“Query”].DataModel.Topics[j].TopicItems.Count
for (k = 1 ; k <= TICount ; k ++)
{
var myItem = ActiveDocument.Sections[“Query”].DataModel.
Topics[j].TopicItems[k]
Console.Writeln(“Topic Item: “+ myItem.DisplayName)
}
}
11-44 Properties
Effect (Property)
Description: Returns or sets the font effect of text associated with a font object.
Action: Read-write
Example: The following example changes the font effect of the text in a text label named,
Description.
ActiveDocument.Sections["EIS2"].Shapes["Description"].Font.Effect=
bqFontEffectUnderline
Example: The following example creates a connection file from scratch and then applies
it to the current document.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.EnableAsyncProcess = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-46 Properties
Enabled (Property)
Description: Returns or sets the current state of a control object. If a control is disabled,
then you cannot access it by way of the EIS section. The control is shown in the
EIS section in a “grayed out or disabled state.
Example: The following examples enables every shape and control object in an EIS
section named, EIS.
var EISSection = ActiveDocument.Sections[“EIS”]
var ShapeCount = EISSection.Shapes.Count
for (j=1;j <= ShapeCount ;j++)
{
EISSection.Shapes[j].Enable = true
}
Description: Returns or sets the value of the EnableTransactionMode property. If set to true,
transaction mode will be enabled for the OCE or current connection.
Example: The following example creates a connection file from scratch and then applies
it to the current document.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
MyCon.EnableTransAction = true
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-48 Properties
ExportWithoutQuotes (Property)
Description: When exporting section data, enables or disables the double quotes
surrounding column/cell values containing real values. The default value is
disabled.
Example 1: The following example exports Results to a tab delimited text file that retains
double quotes surrounding the Results column data.
ActiveDocument.Sections[“Results”].ExportWithoutQuotes=false
ActiveDocument.Sections[“Results”].Export(“C:\Temp\ExportTest\ MyFile”,
BqExportFormatText)
Example 2: The following example exports Results to a tab delimited text file without
double quotes surrounding the Results column data.
ActiveDocument.Sections[“Results”].ExportWithoutQuotes=true
ActiveDocument.Sections[“Results”].Export(“C:\Temp\ExportTest\ MyFile”,
BqExportFormatText)
Description: Returns the full name and path of the OCE file associated with the connection
object.
Example: The following example creates a connection file from scratch and then applies
it to the current document.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-50 Properties
FillUnderRibbon (Property)
Description: If set to true, the area under the ribbon on an area chart is filled in.
Example: The following example enables the FillUnderRibbion attribute of an area chart
for the section named “Sales Chart”.
var MyChart = ActiveDocument.Sections[“Sales Chart”]
MyChart.AreaChart.FillUnderRibbon = true
Description: Returns or sets the focus of the legend on a selected chart axis type (X-axis, Y-
axis, or Z axis. This property uses the BqChartAxisType constant group.
Example: The following example shows you how to change the chart axis type to the X-
axis category.
ActiveDocument.Sections["Chart"].Legend.Focus=bqChartXAxis
11-52 Properties
FullName (Property)
Description: Returns or sets the value of limits full name. The full name may include the
topic, which it is associated with (Query and Data Model Limits only).
Example: The following example prints out the full names of all the limits in a query
section named “SalesQuery”.
var MyQuery = ActiveDocument.Sections["SalesQuery"]
var LimitCount = MyQuery.Limits.Count
for (j =1 ; j <= LimitCount ; j++)
Console.Writeln("Limit fullname is " + MyQuery.Limits[j].FullName)
Description: Returns or sets the value of an EIS Radio buttons group property. Use the
group property to join together two or more Radio buttons.
Example: The following example shows you how to assign a group name to
radiobuttons.
RadioButton1.Group="Sales"
RadioButton2.Group="Sales"
RadioButton3.Group="Sales"
11-54 Properties
Height (Property)
Example: The following example shows you how to change the height of a pie chart in
the chart section named “Sales Pie Chart”.
var MyChart = ActiveDocument.Sections[“Sales Pie Chart”]
MyChart.PieChart.Height = 10
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR” which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.EnableAsyncProcess = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-56 Properties
HTMLExportBreakCount (Property)
Description: Enables users to set the number of rows per exported HTML page. The default
is 100. Setting the value to 0 causes the HTML pages to not break.
Example 2: The following example sets the number of rows per HTML page to 1000.
ActiveDocument.Sections[“Results”].HTMLExportBreakCount=1000
Description: Returns or sets the value of a limits ignore property. If set to true, the limit is
not applied to the query to recalculate results.
Example: The following example shows you how to temporarily ignore all the Data
Model limits prior to processing the query.
var MyQuery = ActiveDocument.Sections[“Query”]
var MyDM = MyQuery.DataModel
var DMLimitCount = MyDM.Limits.Count
for (j = 1 ; j <= DMLimitCount ; j++)
MyDM.Limits[j].Ignore = true
//Assumes you are already connected
MyQuery.Process()
11-58 Properties
IgnoreNulls (Property)
Description: Returns or sets the value of the IgnoreNulls property. If set to true, null values
will be ignored when displaying the chart.
Example: The following example shows you how to set the Bar Line and Line charts to
ignore null values.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.BarLineChart.IgnoreNulls = true
MyChart.LineChart.IgnoreNulls = true
Description: Returns or sets the value of the IncludeNulls property. If set to true then null
values will be included as part of the limit.
Example: The following example shows you how to set all the limits in the Data Model to
support null values.
var MyQuery = ActiveDocument.Sections[“Query”]
var MyDM = MyQuery.DataModel
var DMLimitCount = MyDM.Limits.Count
for (j = 1 ; j <= DMLimitCount ; j++)
MyDM.Limits[j].IncludeNulls = true
//Assumes you are already connected
MyQuery.Process()
11-60 Properties
Index (Property)
Example 1: The following example shows how to change the position of a PivotFact.
ActiveDocument.Sections["SalesPivot"].Facts["Unit Sales"].Index=3
Example 2: The following example shows how to change the position of a Column.
ActiveDocument.Sections["SalesResults"].Columns["Unit Sales"].Index=3
Description: Returns or sets the value of a chart’s left axis IntervalFrequency property.
Example: The following example shows how to change the left axis to display the data in
intervals of 20,000.
ActiveDocument.Sections["AllChart"].ValuesAxis.LeftAxis.IntervalFrequency=20000
11-62 Properties
LabelFrequency (Property)
Example: The following example shows how to change the frequency of when to display
the labels on the X-axis.
ActiveDocument.Sections[“Chart”].LabelsAxis.XAxis.LabelFrequency =3
Description: Returns or sets the value of the text associated with a chart Axis or label.
Example: The following example shows how to set the text for the different labels.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.ValuesAxis.LeftAxis.LabelText = “Left Axis”
MyChart.ValuesAxis.RightAxis.LabelText = “Left Axis”
MyChart.LabelsAxis.XAxis.LabelText = “Xaxis”
MyChart.LabelsAxis.ZAxis.LabelText = “Zaxis”
11-64 Properties
LastPrinted (Property)
Description: Returns a data object corresponding to the last date a section was printed. To
get the date value you will need to use the methods and properties of the Date
Object.
Example: The following example shows how to print the date the document was last
printed to the console window.
Console.Writeln(ActiveDocument.Sections[“Pivot”].LastPrinted.toString())
Thu Jun 03 13:56:13 GMT-0700 (Pacific Daylight Time) 2001
Description: Returns a value corresponding to the date on which a document was last saved.
To get the date value you will need to use the methods and properties of the
Date Object.
Example: The following example shows how to print the date the document was last
saved to the console window.
Console.Writeln(ActiveDocument.LastSaved.toString())
Thu Jun 03 13:56:13 GMT-0700 (Pacific Daylight Time) 2001
11-66 Properties
LastSQLStatement (Property)
Action: Read-only
Example The following example shows you how to display the last SQLStatement
generated by a query in an Alert box.
Alert (ActiveDocument.Sections[“Query”].LastSQLStatement)
Description: Returns or sets the value of the selected limit value set. That is, you can select in
advance whether to use the Available values (Show values) or Custom values
on the Limit dialog box.
Action: Read-write
Example: The following example shows you how to select the custom values for the
second limit item on the Limit dialog.
ActiveDocument.Sections["Query"].Limits[2].LimitValueType=bqLimitValueTypeCustom
11-68 Properties
LogicalOperator (Property)
Description: Sets the value of the limit logical operator of each limit object. The limit
LogicalOperator property is ignored when only one limit value appears for the
particular section. The limit LogicalOperator property is also always ignored
for the first limit value when there is more than one limit value. If more than
one limit value appears in a particular section, then the LogicalOperator of the
second limit applies to the relationship between the first and second limit
values; the LogicalOperator of the third limit applies to the relationship
between the second and third limit values, and so on.
Action: Read-write
Example: The following example shows you how to set the "OR" logical operator on a
limit object.
ActiveDocument.Sections["SalesQuery"].Limits["Year"].LogicalOperator=bqLogicalOperatorOR
Description: Returns or sets the color of a marker's border. A marker depicts an individual
data value or point that emerges in a cell.
Action: Read-write
Constants: The following values are some of the values that are contained in the
BqColorType constant group. For a complete list see the BrioQuery object
model Script Editor.
bqAqua
bqBlack
bqBlue
bBlueGray
bqBrightGreen
bqBrown
bqDarkBlue
bqDarkYellow
bqLightBlue
bqLightOrange
bqWhite
bqYellow
Example: The following example shows you how to set the marker border color to blue.
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.
MarkerBorderColor=bqBlue
11-70 Properties
MarkerFillColor (Property)
Description: Returns or sets the fill color property of a marker. A marker depicts an
individual data value or point that emerges in a cell.
Action: Read-write
Constants: The following values are some of the values that are contained in the
BqColorType constant group. For a complete list see the BrioQuery object
model Script Editor.
bqAqua
bqBlack
bqBlue
bBlueGray
bqBrightGreen
bqBrown
bqDarkBlue
bqDarkYellow
bqLightBlue
bqLightOrange
bqWhite
bqYellow
Example: The following example shows you how to set the marker fill color to green.
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.
MarkerFillColor=bqGreen
Description: Returns or sets the size property of a marker. A marker depicts an individual
data value or point that emerges in a cell.
Example: The following example shows you how to set the marker size property to six
points.
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.MarkerSize=6
11-72 Properties
MarkerStyle (Property)
Action: Read-write
Example: The following example shows you how to set the marker style property.
ActiveDocument.Sections["AllChart"].Legend.Items["Unit Sales"].Line.
MarkerStyle=bqMarkerStyleTriangle
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR” which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.MetadataUsername = “brio”
myCon.MetadataPassword = “briobrio”
myCon.UseAlternateMetadataLocation(true,c:\\OCEs\\PlutoMeta.OCE)
myCon.EnableAsyncProcess = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-74 Properties
MetadataUser (Property)
Description: Returns or sets the value of the username used to connect to the metadata data
source.
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR” which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.MetadataUsername = “brio”
myCon.MetadataPassword = “briobrio”
myCon.UseAlternateMetadataLocation(true,c:\\OCEs\\PlutoMeta.OCE)
myCon.EnableAsyncProcess = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: Returns or sets the value of the MetaData source from the Bqmeta0.ini file. The
metadata source is the name of the predefined metadata vendor.
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR” which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.MetadataUsername = “brio”
myCon.MetadataPassword = “briobrio”
myCon.MetaFileChoice = “Broadbase”
myCon.UseAlternateMetadataLocation(true,c:\\OCEs\\PlutoMeta.OCE)
myCon.EnableAsyncProcess = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-76 Properties
MultiSelect(Property)
Description: Returns or sets the value of the Multiselect property. If set to true, multiple
items may be selected from a list box control.
Example: The following example shows you how to configure a list box to support
multiple user selections.
var MyEIS = ActiveDocument.Sections[“EIS”]
MyEIS.Shapes[“Listbox1”].MultiSelect = true
MultiSelect(Property) 11-77
Name (Property)
Example: The following example prints a list of all the sections in a document to the
console.
for (j = 1 ; j <= ActiveDocument.Sections.Count ; j ++)
Console.Writeln(ActiveDocument.Sections[j].Name)
11-78 Properties
Negate (Property)
Description: Returns or sets the value of the negate property. If negate is set to true then the
negation will be applied to the limit operator. For example, if a limit is set to
select only the values Equal to a criteria and the negate property is true, then
the values returned from the query will be NOT Equal to the criteria.
Example: The following example shows you how to set the negate property of a limit.
var MyLimit = ActiveDocument.Sections[“Query”].Limits[“State”]
MyLimit.Negate = true
Description: Returns or sets the value of the number format property. Use this property to
format the data in a results or table column.
Example: The following example shows you how to apply currency number formatting
to data in the Results section.
ActiveDocument.Sections["SalesResults"].Columns["Amount Sales"].
NumberFormat="$#,##0.00"
11-80 Properties
ODBCDatabasePrompt (Property)
Description: ODBC Only. Returns or sets the value of the ODBCDatabasePrompt property.
If set to true, users will be prompted to enter the name of the ODBC database.
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR” which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.ODBCDatabasePrompt = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR”, which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()myCon.Description = “This OCE configures
the connection via ODBC, to a SQLServer 6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.ODBCEnableLargeBufferMode = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-82 Properties
ODSUsername (Property)
Description: Returns or sets the value of the username when connecting to the OnDemand
Server. This property only applies if a Web document has been saved to a local
file system. This property can be used to reconnect without prompting to
logon to the ODS.
Example: The following example shows you how to connect to the OnDemand server
from a script.
✏ Note This script only applies to documents that have already been registered to the OnDemand
server and saved locally.
ActiveDocument.ODSUsername = “Brio”
ActiveDocument.SetODSPassword(“BrioBrio”)
Description: Returns or sets the value of a limits operator. The operator is applied to the
limit criteria when executing a query or recalculating a results set. If the
operator is set to Equal, only the values, which are exactly equal to the limit
criteria, are returned or displayed.
Action: Read-write
Example: The following example shows you how to modify values of an existing results
limit.
MyLimit = ActiveDocument.Sections["Results"].Limits[1]
//Clear all the values which are currently set
MyLimit.SelectedValues.RemoveAll()
// add new values to the selectedvalues collection
11-84 Properties
MyLimit.SelectedValues.Add(2000)
//Change the limit criteria
MyLimit.Operator = bqLimitOperatorLessThan
Description: Returns the value of the database owner name associated with table in the table
catalog.
Example: The following example shows you how to write all the information about the
tables in the Table Catalog to the console window.
with (ActiveDocument.Sections["Query"].DataModel)
{
var NumTables = Catalog.CatalogItems.Count
for (I = 1 ; I <= NumTables ;I++)
{
OutputString = "Database Name =" + Catalog.CatalogItems[I].DatabaseName
OutputString = OutputString +":Database Owner=" + Catalog.CatalogItems[I].Owner
OutputString = OutputString +":Table Name=" + Catalog.CatalogItems[I].Name
Console.Writeln(OutputString)
}
}
11-86 Properties
Password (Property)
Description: Returns or sets the value of a text box’s password setting. If this property is
true, the text in the text box will be replaced with ****.
Example: The following example shows you how to set the password property on a text
box.
ActiveDocument.Sections[“EIS”].Shapes[“TextBox1”].Password = true
Description: Returns a string containing the full path and name of the document.
✏ Note A plugin document name will be the temporary name and path of the document on the local
file system. For information about Web server path, refer to the URL property.
Example: The following example prints out the path information for all the open
documents to the console window.
for ( j = 1 ; j < = Documents.Count ; j++)\
Console.Writeln( Documents[j].Name + is located on +Documents[j].Path)
11-88 Properties
PathSeparator (Property)
Description: Returns the separator used by the operating systems file system.
Windows – “\
UNIX – “/
Macintosh – “:
Example: The following example shows you how to use the path separator to build a
path.
var PS = Application.PathSeparator
Alert(PS)
Description: Returns the actual name of the topic or topicitem. This name cannot be
changed through scripting or through the user interface.
Example: The following example writes the names of all the topics and topic items to the
console window.
var Tcount = ActiveDocument.Sections[“Query”].DataModel.Topics.Count
for (j = 1; j <= Tcount ; j ++)
{
var myTopic = ActiveDocument.Sections[“Query”].DataModel.Topics[j]
Console.Writeln(“Topic : “+myTopic.PhysicalName)
var TICount =
ActiveDocument.Sections[“Query”].DataModel.Topics[j].TopicItems.Count
for (k = 1 ; k <= TICount ; k ++)
{
var myItem = ActiveDocument.Sections[“Query”].DataModel.Topics[j].TopicItems[k]
Console.Writeln(“Topic Item: “+ myItem.PhysicalName)
}
}
11-90 Properties
ProcessEventOrigin (Property)
Action: Read-only
Example: The following example shows how to identify the origin of the process event.
Console.Writeln("Start OnPreProcess")
case 1:
Console.Writeln("Switch: Process Event Origin is 1, Toolbar")
break;
case 2:
Console.Writeln("Switch: Process Event Origin is 2, Script")
break;
default:
break;
}
Console.Writeln("End OnPreProcess")
Description: Returns or sets the value of the text displayed on the limit dialog box.
Example: The following example shows you how to change the text displayed in a
variable limit.
var MyLimit = ActiveDocument.Sections[“Query”].Limits[“State”]
MyLimit.VariableLimit = true
MyLimit.Prompt = “Please select a state from the list box below.”
11-92 Properties
QueryInProcess (Property)
Description: Identifies the name of the query being processed. This property is only
appropiate for use in the OnPreProcess() and OnPostProcess() events.
Example: The following example shows you how to display the name of the query being
processed in an Alert box.
Console.Writeln("Start OnPreProcess")
switch(ActiveDocument.QueryInProcess)
{
case "Query":
Alert("Query");
break;
case "Query2":
Alert("Query2");
break;
case "OLAPQuery":
Alert("OLAPQuery");
break;
default: Alert("Default");
break;
}
Description: Returns the estimated number of rows the current query will return if
processed.
Example: The following example shows you how to check the size of the query before
processing and ask the user if they want to process the query given the size.
var MyCon = ActiveDocument.Sections[“Query”].DataModel.Connection
MyCon.Username = “Brio”
MyCon.SetPassword(“BrioBrio”)
MyCon.Connect()
var QS = ActiveDocument.Sections[“Query].QuerySize
if (QS > 5000)
{
var Msg = “The query you are about to run, returns “+QS+ rows. “Are you sure
you want to continue?”
var retVal = Alert(Msg,Alert,Yes,No)
if (retVal == 1)
ActiveDocument.Sections[“Query”].Process()
}
11-94 Properties
RefreshData (Property)
Description: You can set a separate refresh frequency for each Pivot and Chart in your
document. When the query is processed, reports are populated with data
according to their refresh frequencies. There are three methods available for
refreshing reports: After Process, OnActivate and Manually. These options are
mutually exclusive. An additional option, the RefreshDataNow method, is
only available when "Manually" is the selected option.
✏ Note Refresh options are set on a per-report basis. For example, if you have ten Pivot reports that
you want to refresh when activated, you need to set the When Section Displayed option for
each report.
Action: Read-Write
Example1 : In this example, a request is made to manually refresh the Pivot section, after
which an immediate refresh to the current section is invoked.
//Manual Refresh of Data
ActiveDocument.Sections["Pivot"].RefreshData=bqRefreshDataManually
ActiveDocument.Sections["Pivot"].RefreshDataNow()
Example 3: In example 3, a request is made to refresh when the section is accessed and
displayed.
//Refresh Data When Section is Displayed
ActiveDocument.Sections["Pivot"].RefreshData=bqRefreshDataOnActivate
11-96 Properties
ResetPrintProperties (Property)
Description: Provides users with the option to use the most current default print settings or
to use the documents original print settings. When ResetPrintProperties is
false (the default), the original default print settings are used for all sections of
the document. When ResetPrintProperties is true, the document uses the most
current default print settings.
✏ Note Unexpected print behavior may occur when this option is enabled in the user interface and
disabled through the object model in a document OnStartup script.
Example: This example shows you how to set the SetPrintProperties to true.
Application.ResetPrintProperties=true
Description: Returns or sets the value of a pie charts rotation. Use this property to change
the visual perspective of a pie chart.
Example: The following example shows you how to change the rotation of a pie chart.
ActiveDocument.Sections["AllChart"].PieChart.Rotation=45
11-98 Properties
RowCount (Property)
✏ Note The number of rows in section can be affected by local limits. Consequently, this property does
not always equal the number of rowsreturned by a query. Use the QuerySize property to
determine the number of rows returned by a query.
Example: The following example shows you how to transfer a list of values from a table
column to a list box in an EIS section.
var RC = ActiveDocument.Sections[“Table”].RowCount
for ( j = 1; j <= RC ; j++)
{
var MyVal = ActiveDocument.Sections[“Table”].Column[“State”].GetCell(j)
ActiveDocument.Sections[“EIS”].Shapes[“ListBox1”].Add(MyVal)
}
Description: Sets the maximum of rows to be retrieved by a query against the Data Model.
This property corresponds to the Rows field on the General tab of the Data
Model Options dialog.
Example: The following example shows you how to set the row limit to 100 and then
process the query.
ActiveDocument.Sections["Query2"].DataModel.RowLimitActive = true
ActiveDocument.Sections["Query2"].DataModel.RowLimit = 100
ActiveDocument.Sections["Query2"].Process()
11-100 Properties
RowLimitActive (Property)
Description: Returns the enable/disable for Row Limit setting property. This property
corresponds to the Return First field on the General tab of the Data Model
Options dialog.
Example: The following example enables the Row Limit setting, sets the maximum
number of rows to retrieve, and processes the query.
ActiveDocument.Sections["Query2"].DataModel.RowLimitActive = true
ActiveDocument.Sections["Query2"].DataModel.RowLimit = 200
ActiveDocument.Sections["Query2"].Process()
Description: Returns the selected row in a Results/Table section. The RowNumber property
can be called from the OnRowDoubleClick event as well as from within any
other BQ event, including those in the EIS section, Startup/Shutdown, and
Custom Menu items. RowNumber is determined by what row is selected in the
Row/Table section. This property also applies to a Results/Table section that is
"actively" embedded in an EIS section when you select a row from the
embedded Results/Table. Selecting a Results/Table section sets the
RowNumber property to a number that represents the nth row in the section.
When no row is selected, the RowNumber property is reset to 0.
Example: The following example shows you how to display the RowNumber.
Alert (ActiveDocument.Sections["Results"].RowNumber)
11-102 Properties
SaveResults (Property)
Description: Returns or sets the value of the “Save Results with document” options. Setting
this property equal to true will save the results of a query with the document.
Example: The following example shows you how to save the results with the query
section named “SalesQuery”.
ActiveDocument.Sections["SalesQuery"].SaveResults=true
Description: Returns or sets the value of the SaveWithoutUsername property. Setting this
property equal to true will NOT save the database username with the Open
Catalog Extension file.
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR”, which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.EnableAsyncProcess = true
myCon.SaveWithoutUsername = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
11-104 Properties
ScaleMax (Property)
Description: Returns or sets the maximum scale values for the right and/or left chart axis.
Example: The following example shows you how to change the maximum scale of left
and right chart axes.
ActiveDocument.Sections["AllChart"].ValuesAxis.LeftAxis.ScaleMax=2000000
ActiveDocument.Sections["AllChart"].ValuesAxis.RightAxis.ScaleMax=2000000
Description: Returns or sets the minimum scale values for the right and/or left chart axes.
Example: The following example shows you how to change the minimum scale of a left
and right chart axis.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.ValuesAxis.LeftAxis.ScaleMin = 25
MyChart.ValuesAxis.RightAxis.ScaleMin = 25
11-106 Properties
Scrollable (Property)
Description: Returns or sets the value of the textbox’s scrollable property. Setting this
property to true will enable vertical scrolling of text in the Text box control.
Example: The following example shows you how to change the properties of a text box.
ActiveDocument.Sections[“EIS”].Shapes[“TextBox1”].Scrollable= true
Description: Provides the option of having scrollbars always showing for embedded section
objects. This property does not apply to hyperlinked embedded section objects
or view-only embedded sections with auto-sizing enabled.
The default setting, show scrollbars after the embedded section is selected, is
false.
Example: The following example shows how to enable embedded section objects to
always show scrollbars.
ActiveDocument.Sections["EIS"].Shapes["Chart1"].ScrollbarsAlwaysShown=true
11-108 Properties
SelectedIndex (Property)
Description: Returns or sets the selections index in a dropdown control. Setting this value
will cause the dropdown to change its selection.
Example: The following example shows you how to display the number of the selected
item in an Alert dialog box.
Index=ActiveDocument.Sections["EIS2"].Shapes["DropDown1"].SelectedIndex=3
Alert("The user selected " + String(Index))
Description: Returns or sets the value of the BarLine chart’s ShiftPoints property.
Action: Read-write
Example: The following example shows you how to change a Bar Line charts shift points.
ActiveDocument.Sections["AllChart"].BarLineChart.ShiftPoints=bqShiftLeft
11-110 Properties
Show3DObjects (Property)
Description: Returns or sets the value of the chart sections Show3DObjects property.
Setting this property to true will display charts using 3D objects, setting it to
false will display charts using 2D objects.
Example: The following example shows you how to change a chart to display 3D objects.
ActiveDocument.Sections[“Chart”].Show3DObjects = true
Description: Returns or sets the Show advanced options property of a connection file.
Setting this property to true will enable the advanced properties dialog in the
OCE wizard.
Example: The following example shows you how to set the advanced property.
ActiveDocument.Sections["Query"].DataModel.Connection.Open
("d:\\OCEs\\PlutoSQL.oce")
ActiveDocument.Sections["Query"].DataModel.Connection.ShowAdvanced = true
ActiveDocument.Sections["Query"].DataModel.Connection.Save()
11-112 Properties
ShowAllPositive (Property)
Description: Returns or sets the ShowAllPositive Property for Pie charts. Setting this
property to true will display all values (both positive and negative) as positive
when displaying a pie chart.
Example: The following example shows you how to display all the values as positive
values in a pie chart.
var MyChart = ActiveDocument.Sections[“Sales Pie Chart”]
MyChart.PieChart.ShowAllPositive = true
Description: Returns or sets the ShowBackPlane property of a chart. Setting this property
equal to true will cause charts to display a back plane.
Example: The following example shows you how to display the back plane in a chart
section.
var MyChart = ActiveDocument.Sections[“Sales Chart”]
MyChart.ShowBackPlane = true
11-114 Properties
ShowBarValues (Property)
Description: If set to true data values are displayed on the tops of individual bars in Bar and
Bar Line Charts.
Example: The following example shows you how to display the values on top of the bars
in bar and bar line charts.
var MyChart = ActiveDocument.Sections[“AllChart”]
MyChart.BarChart.ShowBarValues = true
Description: Returns or sets a charts ShowBorder property. Setting this property equal to
true will display a border around a chart.
Example: The following example shows you how to display the chart border.
var MyChart = ActiveDocument.Sections[“Sales Chart”]
MyChart.ShowBorder = true
11-116 Properties
ShowBrioRepositoryTables (Property)
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is:
“PlutoSQLSVR”, which is a user DSN using the SQL Server 6.5 driver.
Var myCon = Application.CreateConnection()
MyCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
MyCon.HostName ="PlutoSQLSVR"
MyCon.EnableAsyncProcess = true
MyCon.ShowBrioRepositoryTables = true
MyCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Example: The following example shows you how to hide and show various user interface
elements in Brio based on the application they are running.
if (Application.Name == “BrioQuery”)
{
ActiveDocument.ShowCatalog = true
ActiveDocument.ShowMenuBar = true
}
else
{
//Save space in plugin by hiding catalog and turning off menu bar
ActiveDocument.ShowCatalog = false
Application.ShowMenuBar = false
}
11-118 Properties
ShowFullNames (Property)
Description: Returns or sets a table catalogs ShowFullNames property. Setting this property
equal to true will display the full names of tables in the table catalog.
Example: The following example shows you how to display the full names of tables in a
table catalog.
var myQuery = ActiveDocument.Sections[“Query”]
myQuery.DataModel.Catalog.ShowFullNames = true
Example: The following example shows you how to display the chart border.
var MyChart = ActiveDocument.Sections[“Sales Chart”]
MyChart.ShowBorder = true
MyChart.ShowHorizontalPlane = true
11-120 Properties
ShowIconJoins(Property)
Example: The following example shows you how to show icon joins in a Data Model.
ActiveDocument.Sections[“Query”].DataModel.ShowIconJoins = true
ShowIconJoins(Property) 11-121
ShowIntervalTickmarks (Property)
Example: The following example shows you how to enable Interval tickmarks for a chart.
ActiveDocument.Sections[“Chart”].ValuesAxis.ShowIntervalTickmarks = true
11-122 Properties
ShowIntervalValues (Property)
Example: The following example shows you how to enable Interval tickmarks for a chart.
ActiveDocument.Sections[“Chart”].ValuesAxis.ShowIntervalValues = true
Description: Returns or sets a charts ShowLabel property. Setting this property equal to true
will display the label associated with an axis.
Example: The following example shows you how to show all the labels for the various
chart objects.
ActiveDocument.Sections[“Chart”].Activate()
ActiveSection.ValuesAxis.RightAxis.ShowLabel = true
ActiveSection.LabelsAxis.XAxis.ShowLabel = true
ActiveSection.ValuesAxis.LeftAxis.ShowLabel = true
ActiveSection.LabelsAxis.ZAxis.ShowLabel = true
11-124 Properties
ShowLabels (Property)
Description: Returns or sets a pie chart’s ShowLabels property. Setting this property equal to
true will display the labels associated with a pie chart.
Example: The following example shows you how to set pie chart specific properties.
ActiveDocument.Sections[“Chart”].PieChart.ShowLabels = true
ActiveDocument.Sections[“Chart”].PieChart. ShowPercentages = true
Description: Returns or sets a charts ShowLegend property. Setting this property equal to
true will display the legend associated with a chart.
Example: The following example shows you how to enable the chart legend.
ActiveDocument.Sections[“Chart”].ShowLegend = true
11-126 Properties
ShowLocalResults (Property)
Example: The following example shows you how to search through the document for
more than one results set and then display the local results in the Table
Catalog.
var ResultsCount = 0
for (j =1 ; j <= ActiveDocument.Sections.Count ; j++)
if (ActiveDocument.Sections[j].Type == bqQuery)
ResultsCount++
if (ResultsCount > 1 )
ActiveDocument.Sections[“Query”].DataModel.ShowLocalResults = true
Description: Returns or sets the applications ShowMenuBar property. Setting this property
equal to true will display the applications menu bar. The default value is true.
Example: The following example shows how to hide and show various user interface
elements in Brio based on the application they are running.
if (Application.Name == “BrioQuery Designer”)
{
ActiveDocument.ShowCatalog = true
Application.ShowMenuBar = true
}
else
{
//Save space in plugin by hiding catalog and turning off menu bar
ActiveDocument.ShowCatalog = false
Application.ShowMenuBar = false
}
11-128 Properties
ShowMetadata (Property)
Example: The following example creates a connection file from scratch and then applies
it to the current document. The data source name in this example is
“PlutoSQLSVR”, which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
mmyCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.EnableAsyncProcess = true
myCon.ShowMetaData = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: Returns or sets a ShowOutliner property. Setting this property equal to true
will display the Outliner associated with a section. The default value is true.
Example: The following example shows you how to display the chart outliner.
ActiveDocument.Sections[“Chart”].ShowOutliner = true
11-130 Properties
ShowPercentages (Property)
Description: Returns or sets a pie charts ShowPercentages property. Setting this property
equal to true will display the percentages next to the pie slices in a pie chart.
Example: The following example shows how to set pie chart specific properties.
ActiveDocument.Sections[“Chart”].PieChart.ShowLabels = true
ActiveDocument.Sections[“Chart”].PieChart. ShowPercentages = true
11-132 Properties
ShowSectionTitleBar (Property)
Example: The following example shows you how to hide and show various user interface
elements in Brio based on the application you are running.
if (Application.Name == “BrioQuery Designer”)
{
ActiveDocument.ShowCatalog = true
ActiveDocument.ShowSectionTitleBar = true
Application.ShowStatusBar = true
Application.ShowMenuBar = true
}
else
{
//Save space in plugin by turning off various user interface elements
ActiveDocument.ShowCatalog = false
ActiveDocument.ShowSectionTitleBar = false
Application.ShowStatusBar = false
Application.ShowMenuBar = false
}
Description: Returns or sets the applications ShowStatusBar property. Setting this property
equal to true will display the status bar. Changing this property is equivalent to
showing/hiding the status bar from the view menu.
Example: The following example shows you how to hide and show various user interface
elements in Brio based on the application they are running.
if (Application.Name == “BrioQuery Designer”)
{
ActiveDocument.ShowCatalog = true
ActiveDocument.ShowSectionTitleBar = true
Application.ShowStatusBar = true
Application.ShowMenuBar = true
}
else
{
//Save space in plugin by hiding by various user interface elements
ActiveDocument.ShowCatalog = false
ActiveDocument.ShowSectionTitleBar = false
Application.ShowStatusBar = false
Application.ShowMenuBar = false
}
11-134 Properties
ShowSubtitle (Property)
Description: Returns or sets the charts ShowSubTitle property. Setting this property equal
to true will display the sub title.
Example: The following example shows you how to add a sub-title to a chart.
var MyChart=ActiveDocument.Sections["Chart"]
MyChart.SubTitle="This is the Sub Title"
MyChart.ShowSubTitle=true
Description: Returns or sets the charts ShowTickmarks property. Setting this property equal
to true will display the tickmarks on X-axis and/or Z-axis.
Example: The following example shows how to display tickmarks on the X-axis and hide
them on the Z-axis.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.LabelsAxis.XAxis.ShowTickmarks = true
MyChart.LabelsAxis.ZAxis.ShowTickmarks = false
11-136 Properties
ShowTitle (Property)
Description: Returns or sets the charts ShowTitle property. Setting this property equal to
true will display the chart title.
Example: The following example shows you how to add a title to a chart.
var MyChart=ActiveDocument.Sections["Chart"]
MyChart.Title="This is the Title"
MyChart.ShowTitle=true
Description: Returns or sets the charts ShowValues property. Setting this property equal to
true will display the values along the X-axis and/or the Z-axis.
Example: The following example shows how to display the values on the X-axis and hide
them on the Z-axis.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.LabelsAxis.XAxis.ShowValues = true
MyChart.LabelsAxis.ZAxis.ShowValues = false
11-138 Properties
ShowValuesAtRight (Property)
Description: Returns or sets the charts ShowValuesAtRight property. Setting this property
equal to true will display the values to the right of the values axis.
Example: The following example shows how to display the values to the right of the axis.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.ValuesAxis.ShowValuesAtRight = true
Description: Returns or sets the charts ShowVerticalPlane property. Setting this property
equal to true will display the vertical plane in a chart section.
Example: The following example shows how to display the vertical plane on a chart.
ActiveDocument.Sections["Chart"].ShowVerticalPlane=true
11-140 Properties
Size (Property)
Description: Returns or sets the value of a font objects size property. This property controls
the size of the text associated with a font object.
Example: The following example shows how to change the size of the text associated with
a text label.
var MyLabel = ActiveDocument.Sections[“EIS”].Shapes[“TextLabel1”]
MyLabel.Font.Size = 14
MyLabel.Font.Style = bqFontStyleBoldItalic
Description: Returns or sets the sort criteria for a pivot fact. This property is used in
conjunction with the SortByFact (Method).
Example The following example shows you how to sort the side label "Product Name"
by the fact value.
ActiveDocument.Sections["Pivot3"].SideLabels["Product Name"].SortFactName="Unit
Sales"
11-142 Properties
SortFunction (Property)
Example The following example shows you how to sort values based on the average
statistical function.
ActiveDocument.Sections["Pivot3"].SideLabels["Product Name"].SortFunction=
bqSortFunctionAverage
Action: Read-write
Constants The constant associated with this property is a member of the constant group
called BqSortOrder. The BqSortOrder constant group consists of the following
values:
bqSortAscend
bqSortDescend
Example: The following example shows you how to sort in ascending order in the Table
section.
ActiveDocument.Sections["Table"].SortItems[1].SortOrder=bqSortAscend
11-144 Properties
SpecificMetadataLogin (Property)
Example: The following example creates an OCE from scratch and then applies it to the
current document. The data source name in this example is: “PlutoSQLSVR”,
which is a user DSN using the SQL Server 6.5 driver.
var myCon = Application.CreateConnection()
myCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiOpenClient
myCon.Database = bqDatabaseSQLServer
myCon.HostName ="PlutoSQLSVR"
myCon.EnableAsyncProcess = true
myCon. SpecificMetadataLogin = true
myCon.SaveAs("d:\\OCEs\\PlutoSQL.oce")
Description: Returns the value of a request object’s SQLName property. The value of this
property is the name of the request object, which is used in building the SQL
statement.
Example: The following example shows you how to display all the names used in the SQL
statement corresponding to the request line items.
var RequestCount = ActiveDocument.Sections[“Query”].Requests.Count
for (j =1 ; j <= RequestCount ; j++)
{
var DisplayName = ActiveDocument.Sections[“Query”].Requests[j].DisplayName
var SQLName = ActiveDocument.Sections[“Query”].Requests[j].SQLName
Console.Writeln(“The column named “+ DisplayName + “is actually known by “+
SQLName + “to the database.”)
}
11-146 Properties
SQLNetRetainDateFormats (Property)
Example: The following example creates a connection file from scratch and then applies
it to the current document.
Var myCon = Application.CreateConnection()
MyCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
MyCon.Api = bqApiSQLNet
MyCon.Database = bqDatabaseOracle71
MyCon.HostName ="PlutoORACLE"
MyCon. SQLNetRetainDateFormats =true
MyCon.SaveAs("d:\\OCEs\\PlutoORACLE.oce")
Action: Read-write
Example: The following example shows how to change the type of BarLineChart.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.BarLineChart.StackClusterType = bqClusterByY
11-148 Properties
StringRetrieval (Property)
Example: The following example creates a connection from scratch and then applies it to
the current document.
Var myCon = Application.CreateConnection()
MyCon.Description = “This OCE configures the connection via ODBC, to a SQLServer
6.5 database named pluto.”
myCon.Api = bqApiSQLNet
myCon.Database = bqDatabaseOracle71
myCon.HostName ="PlutoORACLE"
myCon. StringRetrieval =true
myCon.SaveAs("d:\\OCEs\\PlutoORACLE.oce")
Description: Returns or sets the value of a font objects style property. This property changes
the look and feel of the text associated with the font object.
Action: Read-write
Example: The following example shows you how to change the size of the text associated
with a text label.
var MyLabel = ActiveDocument.Sections[“EIS”].Shapes[“TextLabel1”]
MyLabel.Font.Size = 14
MyLable.Font.Style = bqFontStyleBoldItalic
11-150 Properties
SubTitle (Property)
Example: The following example shows how to add a sub title to a chart.
ActiveDocument.Sections["Chart"].SubTitle ="This is the sub title"
ActiveDocument.Sections["Chart"].ShowSubTitle=true
Example: The following example shows you how to suppress duplicate results on specific
columns within a Results section.
var Col1 = “State”
var Col2 = “City”
ActiveDocument.Sections[“Results”].Columns[Col1].SupressDuplicates = true
ActiveDocument.Sections[“Results”].Columns[Col2].SupressDuplicates = true
11-152 Properties
SurfaceValues (Property)
Description: Returns or sets the value of the Pivot Section's surface values property. Surface
values instruct the entire Pivot to perform calculations based on surface values
as opposed to the entire underlying results set. Changes to the property are
selected in the UI when the property is set. Changes to the UI are reflected
when the property is read. The default value is false.
Example 1: The following example shows you how to turn on surface values.
//Surface Values ON
ActiveDocument.Sections["Pivot"].SurfaceValues=true
Example 2: The following example shows you how to turn off surface values.
//Surface Values OFF
ActiveDocument.Sections["Pivot"].SurfaceValues=false
✏ Note You must use the Recalculate() method to force a recalculation when using this property.
Example: The following example shows you how to increase the performance of limits
applied to a results set using the Suspend Recalculation property.
var MyLimit = ActiveDocument.Sections[“Results”].Limits[“Units”]
MyLimit.SuspendRecalculation = true
MyLimit.SelectedValues.RemoveAll()
MyLimit.SelectedValues.Add(10)
MyLimit.SelectedValues.Add(11)
MyLimit.SelectedValues.Add(12)
MyLimit.SuspendRecalculation = false
ActiveDocument.Sections[“Results].Recalculate()
✏ Note Instead of calculating the results limit four times, the script above only calculates it once.
11-154 Properties
Text (Property)
Description: Returns or sets the value of the text that is displayed in a Text box control or
Text label shape.
Example: The following example shows you how to set an initial value for a text box.
ActiveDocument.Sections["EIS2"].Shapes["TextBox1"].Text="Hello World"
Alert (ActiveDocument.Sections["EIS2"].Shapes["TextBox1"].Text)
Description: Returns or sets the value of a column objects Textwrap property. Setting this
property equal to true will cause the text in a column to wrap and extend the
height of the column.
Example: The following example shows you how to force text to wrap on specific
columns within the Results section.
var Col1 = “State”
var Col2 = “City”
ActiveDocument.Sections[“Results”].Columns[Col1].TextWrap = false
ActiveDocument.Sections[“Results”].Columns[Col2]. TextWrap = true
11-156 Properties
TickmarkFrequency (Property)
Example 1: The following example shows how to display a tickmark for every value on the
X-axis.
ActiveDocument.Sections["AllChart"].LabelsAxis.XAxis.TickmarkFrequency=1
ActiveDocument.Sections["AllChart"].LabelsAxis.XAxis.ShowTickmarks=true
Example 2: The following example shows how to display a tickmark for every other value
on the X-axis.
ActiveDocument.Sections["AllChart"].LabelsAxis.XAxis.TickmarkFrequency=2
ActiveDocument.Sections["AllChart"].LabelsAxis.XAxis.ShowTickmarks=true
Description: Returns or sets the value of the timelimit property. This property controls the
maximum time limit a query can process before timing out. It can be set on the
OCE, DataModel or Connection level. The time increment is minutes.
Example: The following example shows you how to set the Time limit property for all the
supported objects.
//Connections
var myCon = Application.CreateConnection()
myCon.Api = bqApiSQLNet
myCon.Database = bqDatabaseOracle71
myCon.HostName ="PlutoORACLE"
myCon.TimeLimit = 20
myCon.SaveAs("d:\\OCEs\\PlutoORACLE.oce")
//DataModel
ActiveDocument.Sections[“Query].DataModel.TimeLimit = 30
//Query
ActiveDocument.Sections[“Query].TimeLimit = 30
11-158 Properties
TimeLimitActive (Property)
Description: Returns the enable/disable for Time Limit setting property. It is associated
with the TimeLimit property.
Example: The following example shows you how to enable the Time Limit setting, set the
maximum time limit to process a query before timing out,. and process the
query.
ActiveDocument.Sections["Query"].DataModel.TimeLimitActive = true
ActiveDocument.Sections["Query"].DataModel.TimeLimit = 30
ActiveDocument.Sections["Query"].Process()
Description: Returns or sets the value of the title property. This property changes the value
of the title displayed on a chart.
Example: The following example shows you how to add a title to a chart.
var MyChart = ActiveDocument.Sections[“Chart”]
MyChart.Title = “This is the Title”
MyChart.ShowTitle = true
11-160 Properties
TopicName (Property)
Description: Retrieves the parent of the Topic item, which is the Topic Name in a join or
local join. It also allows you to retrieve the Topic Item Names of joins (and not
local joins).
Example 1 The following example shows you how to retrieve the topic names 1 and 2
from a join.
//Get Join Topic Names
TextBox1.Text=ActiveDocument.Sections["Query"].DataModel.Joins["1"].Topic1Name;
TextBox2.Text=ActiveDocument.Sections["Query"].DataModel.Joins["1"].Topic2Name;
TextBox3.Text=ActiveDocument.Sections["Query"].DataModel.Joins["1"].Type;
Example 2 The following example shows you how to retrieve the Topic Item Names from
a join.
/Get Join Topic Item Names
TextBox4.Text=ActiveDocument.Sections["Query"].DataModel.Joins["1"].TopicItem1.Di
splayName
TextBox5.Text=ActiveDocument.Sections["Query"].DataModel.Joins["1"].TopicItem2.Ph
ysicalName
Example 3 The following example shows you how to retrieve the topic names 1 and 2
from a local join.
//Get Local Join Topic Names
TextBox6.Text=ActiveDocument.Sections["Query"].DataModel.LocalJoins["1"].Topic1Na
me;
TextBox7.Text=ActiveDocument.Sections["Query"].DataModel.LocalJoins["1"].Topic2Na
me;
TextBox8.Text=ActiveDocument.Sections["Query"].DataModel.LocalJoins["1"].Type;
Action: Read-only
11-162 Properties
Join – BqJoinType
bqJoinLeft
bqJoinOuter
bqJoinRight
bqJoinSimpleEqual
bqJoinSimpleGreaterThan
bqJoinSimpleGreaterThanOREqual
bqJoinSimpleLessThan
bqJoinSimpleLessThanOrEqual
bqJoinSimpleNotEqual
Toolbar – BqToolbars
bqToolbarFormat
bqToolbarNavigation
bqToolbarSections
bqToolbarStandard
Topic – BqTopicType
bqTopicTypeMeta
bqTopicTypeNone
bqTopicTypeQueryObject
bqTopicTypeResults
bqTopicTypeStoredProcedure
Shape – BqShapeType
bqButton
bqCheckBox
bqDropBox
bqEmbeddedSection
Example: The following example shows you how to use the type property to determine
which properties apply to a specific object. In this example, checking the Type
property of the Section objects allows the script to process every query in a
document.
var SecCount = ActiveDocument.Sections.Count
for (j = 1; j <= SecCount ; j++)
{
if (ActiveDocument.Sections[j].Type == bqQuery)
ActiveDocument.Sections[j].Process()
}
11-164 Properties
UnionController (Property)
Description: Returns or sets the value of the Append Query union operator. The union
operator governors how rows are retrieved when the Append Query Option
feature is used. This property uses the BqUnionController constant group,
which consists of the bqUnion and bqUnionAll constants value.Use the
bqUnion constant value when you want to programmatically retrieve all
distinct rows selected by either query without duplicates. Use the bqUnionAll
constant value when you want to programmatically retrieve all rows selected
by either query, including duplicate rows.
Action: Read-write
Example: The following example shows you how to append a query using the Union
operator.
ActiveDocument.Sections["Query"].AppendQueries.Add()
ActiveDocument.Sections["Query"].AppendQueries[1].UnionController=bqUnion
Description: Returns or sets the value of a query sections unique row property. Setting this
property to true will cause the query to return only unique rows of data.
Example: The following example sets each query in a document to return unique rows.
var SecCount = ActiveDocument.Sections.Count
for (j = 1; j <= SecCount ; j++)
{
if (ActiveDocument.Sections[j].Type == bqQuery)
ActiveDocument.Sections[j].UniqueRows = true
}
11-166 Properties
URL (Property)
Description: PluginDocument – Returns the value of the URL (Uniform Resource Locator)
associated with the document. If the document is registered with the
OnDemand Server, the URL contains the address to the server and the name of
the Broker. If the document came from a Web server or local file system, the
URL contains the fully qualified server name and directory.
Example: The following example illustrates the how to use the URL property to direct
users to help information stored on the same server.
if(Application.Name.indexOf(“BrioQuery”) != -1)
{
Alert(“This property is not valid in BrioQuery”)
}
else
{
var MyURL = ActiveDocument.URL
Application.OpenURL(MyURL + “\/helpinfo.html,_new”)
}
Description: Returns or sets the value of the username property. The username property of
the connection objects refers to the username used by the OCE (Open Catalog
Extension).
Example: The following example shows you how to create a connection from scratch and
how to set its various properties.
var myCon = Application.CreateConnection()
myCon.Api = bqApiSQLNet
myCon.Database = bqDatabaseOracle71
myCon.HostName ="PlutoORACLE"
myCon.TimeLimit = 20 //minutes
myCon.Username = “Brio
myCon.SaveAs("d:\\OCEs\\PlutoORACLE.oce")
11-168 Properties
ValueSource (Property)
Description: Returns the value of a limit object’s ValueSource property. This property
returns an enumerated value, which specifies where the limit values originated.
Action: Read-only
Example: The following example shows you how to use the ValueSource property to
determine the location of the limits values.
ActiveDocument.Sections["Query"].Limits[1].LoadFromFile("d:\\LimitData.txt")
if (ActiveDocument.Sections["Query"].Limits[1].ValueSource != bqLimitSourceFile)
Alert(“An error has occurred,Error!”)
Description: Returns or sets the value of a limit objects VariableLimit Property. This
property enables or disables a limit as a variable limit. If the VariableLimit
property is equal to true then a limit is considered a variable limit and will
prompt the user for a limit value when they process a query.
Example: The following example checks to see if any query limits are set as variable limits
and reverts them into normal limits.
for (j=1 ; j <= ActiveDocument.Sections[“Query”].Limits.Count; j++)
if (ActiveDocument.Sections[“Query”].Limits[j].VariableLimit == true)
ActiveDocument.Sections[“Query”].Limits[j].VariableLimit = false
11-170 Properties
Version (Property)
Example: The following example shows you how to display your current version number.
Alert (Application.Version)
Description: Returns or sets the vertical alignment of the text in a shape objectThis property
corresponds to the features on the Alignment Properties dialog box.
Action: Read-write
Example: The following example changes a text label to 8 points, bold Italic and
vertically aligned at the top.
var MyLabel = ActiveDocument.Sections["EIS"].Shapes["TextLabel"]
MyLabel.Font.Size = 8
MyLabel.Font.Style = bqFontStyleBoldItalic
MyLabel.VerticalAlignment=bqAlignTop
11-172 Properties
View (Property)
Description: Returns or sets the value of a topic objects view property. This property
controls the display characteristics of topics in a Data Model.
Action: Read-Write
Example: The following example resets all the Topics in a Data Model to the structure
view.
var TopicCount = ActiveDocument.Sections[“Query”].DataModel.Topics.Count
for (j =1 ; j <= TopicCount ; j++)
ActiveDocument.Sections[“Query”].DataModel.Topics[j].View = bqStructureView
Description: Returns or sets the value of the visible property. The visible property controls
the display of its base object. Setting visible equal to false will hide the object or
setting visible equal to true will show the object.
11-174 Properties
Width (Property)
Description: Returns or sets the value of the Lines Width property. This property effects the
size of the border of shape and control objects.
Example: The following example changes all the rectangles to have a border width of five
pixels.
var ShapeCount = ActiveDocument.Sections[“EIS”].Shapes.Count
var ShapesCol = ActiveDocument.Sections[“EIS”].Shapes
for ( j =1 ; j <= ShapeCount ; j++)
if (ShapesCol[j].Type == bqShapeTypeRectangle)
ShapesCol[j].Line.Width = 5
Description: Returns or sets the value of the applications WindowState property. This
property effects the display of the main application window. Using the
enumerated type BqWindowState the window can be minimized, maximized
or restored back to a default state.
Action: Read-write
Example: The following example checks if BrioQuery is maximized, and changes its state
based on the result.
if( Application.WindowState != bqWindowStateMaximized)
Application.WindowState = bqWindowStateMaximized
else
Application.WindowState = bqWindowStateNormal
11-176 Properties
12 JavaScript Examples
This chapter provides sample JavaScript scripts for these BrioQuery tasks:
■ Displaying and Entering Values in a Text Box
■ Retrieving and Setting the Properties of an Object
■ Enabling and Disabling Controls
■ Controlling the Visibility of Graphics and Controls
■ Creating an OCE (connection file)
■ Displaying a Connection Login Box
■ Downloading Data Models
■ Displaying a Table Catalog
■ Adding Topics to a Data Model Section
■ Setting up Topic Object Variables
■ Adding Joins
■ Adding Items to the Request Line
■ Adding a Computed Column to a Query Request Line
■ Creating and Setting Variable Limits
■ Using the ODS User Name as a Limit
■ Using a BrioQuery 5.5 Limit Dialog Box and Storing Selected
Value in Text Box
■ Turning off the Page Headers for the First Page in the Report
■ Including Limit Values in the URL Submitted to the ODS
■ Turning off the Prompt To Save Dialog Box
■ Processing Queries Using “Prompt For Database Logon”
■ Processing Queries Using “Don’t Prompt For Database Logon”
12-1
Displaying and Entering Values in a Text Box
A BrioQuery text box provides users a way to display output to and gather
input from the application. You can write values to a text box or read values
from a text box. There are three events associated with a text box—OnEnter,
OnChange, and OnExit.
Uses for a text box in Run Mode include:
■ Entering values
■ Displaying values
■ Displaying read-only information
■ Validating data
■ Calculating data
ActiveDocument.Sections["DataModel"]
.DataModel.Connection.Open("c:\\temp\\astro8.oce")
// need to connect ?
ActiveDocument.Sections["DataModel"]
.DataModel.Connection.UserName = "brio"
ActiveDocument.Sections["DataModel"]
.DataModel.Connection.SetPassword("brio")
ActiveDocument.Sections["DataModel"]
.DataModel.Connection.Connect()
Adding Joins
Example 17 shows the script to use to add a join.
Example 21 ActiveDocument.Sections["Query"].Limits[1]
.SelectedValues.RemoveAll()
ActiveDocument.Sections["Query"].Limits[1]
.SelectedValues.Add(ActiveDocument.ODSUsername)
Using a BrioQuery 5.5 Limit Dialog Box and Storing Selected Value in Text Box 12-9
Turning off the Page Headers for the First Page in the Report
The script in Example 23 shows how to turn off page headers for the first page
in the report.
Example 23 if ( PageNm==1)
{' '}
else
{"Query Processed: "+ Format(new Date(), "d-mmm-yyyy")}
Example 25 Application.Quit(false)
Example 26 Console.Writeln("Start")
Console.Writeln("Step1a")
for (i = 1; i <=ActiveDocument.Sections.Count ; i++)
{
if (ActiveDocument.Sections[i].Type == bqQuery)
{
Console.Writeln("Step 1b, " + ActiveDocument.Sections[i].Name
+ " is a query section")
try
{
ActiveDocument.Sections[i].Process()
}
catch(e)
{
Console.Writeln("Step 1c, " + ActiveDocument.Sections[i]
.Name + " failed, produced this error: "+ String(e))
}
Console.Writeln("Step1d, Processed " +
ActiveDocument.Sections[i].Name)
}
else
{
Console.Writeln("Step 1e, " + ActiveDocument.Sections[i].Name
+ " is not a query section")
}
}
Console.Writeln("Step2")
ActiveDocument.Sections["Results"].Activate()
Console.Writeln("Step3")
Console.Writeln("End")
Console.Writeln("Step5")
MyCon2 = ActiveDocument.Sections["Query2"]
.DataModel.Connection
Console.Writeln("Step6")
MyCon2.Username = "query2userid"
Alert("Username set")
Console.Writeln("Step7")
MyCon2.SetPassword("query2passwd")
Alert("Password set")
Console.Writeln("Step8a")
try
{
ActiveDocument.Sections["Query2"].Process()
Console.Writeln("Step8b, processed section Query")
}
catch(e)
{
Console.Writeln("Step8c, Query2 process failed, produced this
error: "+ String(e))
}
Console.Writeln("Step9")
Console.Writeln("End multi query prompt for db ODS logon")
This appendix provides a detailed map of how objects relate to one another
within the BrioQuery object model. The object model map is divided
according to these levels and/or sections of the object tree:
■ Object Model Hierarchy
■ Application Level
■ Active Document Level
■ Query Section
■ EIS Section
■ Chart Section
■ Results, Report, and Pivot Sections
■ Table and OLAPQuery Sections
13-1
Object Model Hierarchy
The object model map is an expanded view of selected objects in the object
model hierarchy, as seen in the EIS Script Editor. It starts at the highest level—
the Application level—and drills down through the object hierarchy. The top
levels of the object model heirarchy include:
■ Application Level
■ Active Document Level
■ Sections
Application Level
Sections
Application
Documents DocName
Sections
Active Document
LastSaved
Active Section
Standard
Formatting
Toolbars
Sections
Navigation
Recent Files Item Number
Console
URL
Session Form
Cookies
Application
Active Document
(Doc Name)
Sections
EIS
Report
Query
Results
Table
Chart
Pivot
DataModel
OLAPQuery
Last Saved
Application
Connection
MetaData
Results
Sections Connection
Limits
TopicItem1
Data Model
Local Results
TopicItem2
Local Joins
Requests RequestNum
AvailableValues
SelectedValues
SortItems
Query (base)
AppendQuery
Query (append)
Requests RequestNum
Limits AvailableValues
SelectedValues
Application
Active Document
CheckBox SelectedList Fill Font
Sections
CommandButton
TextBox
Font
EIS
DropDown
ListBox
HorizontalLine
Line Line
VerticalLine
Picture
Fill
Oval
Line
Rectangle
EmbeddedSection
Application
XCategories(C) XCategories(O)
Facts(C) Fact(O)
Active Document
ZCategories(C) ZCategories(O)
XLabels
Sections
YLabels LabelValues
ZLabels
Chart
BarChart
BarLineChart
PieChart
AreaChart
LineChart
XAxis
LabelAxis YAxis
ValueAxis LeftAxis
RightAxis
Fill
Application
Active Document
Sections
Columns Column
AvailableValues
SelectedValues
SortItems SortItem
Reports
TopLabels
PivotLabel
Pivots SideLabels
Facts PivotFact
DataLabels
CornerLabels
Application
Active Document
Section
Columns
Table Limits
SortItems SortItemName
Connection
SideLabels SideLabelNum
Measures TopLabelName
Slicers SlicerNumber
14-1
Arithmetic Operators
Arithmetic operators, described in Table 14-1, take numerical values (either
literals or variables) as their operands and return a single numerical value.
Operator Description
var++ or ++var
The increment operator increments (adds one to) its operand and returns a value.
If it is used postfix, with operator after operand (for example, x++), then it returns
the value before incrementing. If it is used prefix with operator before operand (for
example, ++x), then it returns the value after incrementing.
For example, if x is three, then the statement y = x++ sets y to 3 and increments x
to 4. If x is 3, then the statement y = ++x increments x to 4 and sets y to 4.
var-- or --var
The decrement operator decrements (subtracts one from) its operand and returns
a value. If it is used postfix (for example, x--), then it returns the value before dec-
rementing. If it is used prefix (for example, --x), then it returns the value after dec-
rementing.
For example, if x is three, then the statement y = x-- sets y to 3 and decrements x
to 2. If x is 3, then the statement y = --x decrements x to 2 and sets y to 2.
- (Unary negation, subtraction) As a unary operator, negates the value of its argu-
ment. As a binary operator, subtracts two numbers.
The unary negation operator precedes its operand and negates it. For example, y
= -x negates the value of x and assigns that to y; that is, if x were 3, y would
get the value -3and x would retain the value 3.
Operator Description
var1 % var2
The modulus operator returns the first operand modulo the second operand, that
is, var1 modulo var2, in the preceding statement, where var1 and var2 are
variables. The modulo function is the integer remainder of dividing var1 by
var2.
Assignment Operators
Assignment operators assign a value to a left operand based on the value of a
right operand. The basic assignment operators are described in Table 14-2.The
other assignment operators, described in Table 14-3, are shorthand for
standard operations.
Operator Description
%= Computes the modulus of two numbers and assigns the result to the first.
&= Performs a bitwise AND and assigns the result to the first operand.
^= Performs a bitwise XOR and assigns the result to the first operand.
Operator Description
|= Performs a bitwise OR and assigns the result to the first operand.
>>= Performs a sign-propagating right shift and assigns the result to the first operand.
>>>= Performs a zero-fill right shift and assigns the result to the first operand.
Shorthand
Operator Meaning
x += y x=x+y
x -= y x=x–y
x *= y x=x*y
x /= y x=x/y
x %= y x=x%y
x <<= y x = x << y
x >>= y x = x >> y
x >>>= y x = x >>> y
x &= y x=x&y
x ^= y x=x^y
x |= y x=x|y
Bitwise Operators
Bitwise operators, described in Table 14-4, treat their operands as a set of bits
(zeros and ones), rather than as decimal, hexadecimal, or octal numbers. For
example, the decimal number nine has a binary representation of 1001. Bitwise
operators perform their operations on such binary representations, but they
return standard JavaScript numerical values.
Operator Description
& (Bitwise AND) Returns a one in each bit position if bits of both operands are ones.
The Bitwise AND operator is used as follows:
a & b
Returns a one in each bit position if bits of both operands are ones.
^ (Bitwise XOR) Returns a one in a bit position if bits of one, but not if both oper-
ands are one. The bitwise XOR operator is used as follows:
a ^ b
Returns a one in a bit position if bits of one, but not both operands are one.
| (Bitwise OR) Returns a one in a bit if bits of either operand is one. The Bitwise OR
operator is used as follows:
a | b
~ (Bitwise NOT) Flips the bits of its operand. The Bitwise NOT operator is used as fol-
lows:
~ a
<< (Left shift) Shifts its first operand in binary representation the number of bits to the
left specified in the second operand, shifting in zeros from the right. The Left shift
operator is used as follows:
a << b
Shifts a in binary representation b bits to left, shifting in zeros from the right.
Operator Description
>> (Sign-propagating right shift) Shifts the first operand in binary representation the
number of bits to the right specified in the second operand, discarding bits shifted
off. The Sign-propagating right shift operator is used as follows:
a >> b
>>> (Zero-fill right shift) Shifts the first operand in binary representation the number of
bits to the right specified in the second operand, discarding bits shifted off, and
shifting in zeros from the left. The zero-fill right shift operator is used as follows:
a >>> b
Shifts a in binary representation b bits to the right, discarding bits shifted off,
and shifting in zeros from the left.
Operator Description
<< (Left Shift) This operator shifts the first operand the specified number of bits to the
left. Excess bits shifted off to the left are discarded. Zero bits are shifted
in from the right.
For example, 9<<2 yields thirty-six, because 1001 shifted two bits to
the left becomes 100100, which is thirty-six.
>> (Sign-Propagating This operator shifts the first operand the specified number of bits to the
Right Shift) right. Excess bits shifted off to the right are discarded. Copies of the left-
most bit are shifted in from the left.
For example, 9>>2 yields two, because 1001 shifted two bits to the
right becomes 10, which is two. Likewise, -9>>2 yields -3, because
the sign is preserved.
>>> (Zero-Fill Right This operator shifts the first operand the specified number of bits to the
Shift) right. Excess bits shifted off to the right are discarded. Zero bits are
shifted in from the left.
For example, 19>>>2 yields four, because 10011 shifted two bits to
the right becomes 100, which is four. For non-negative numbers, zero-
fill right shift and sign-propagating right shift yield the same result.
Operator Description
3 == var1
!= (Not equal) Returns true if the operands are not equal. For example:
var1 != 4
> (Greater than) Returns true if left operand is greater than right operand. For exam-
ple:
>= (Greater than or equal) Returns true if left operand is greater than or equal to right
operand. For example:
< (Less than) Returns true if left operand is less than right operand. For example:
<= (Less than or equal) Returns true if left operand is less than or equal to right oper-
and. For example:
Operator Description
&& (Logical AND) Returns true if both logical operands are true. Otherwise, returns
false. The Logical AND operator is used as follows:
|| (Logical OR) Returns true if either logical expression is true. If both are false,
returns false. The Logical OR operator is used as follows:
expr1 || expr2
! (Logical negation) If its single operand is true, returns false; otherwise, returns
true.
Short-Circuit Evaluation
As logical expressions are evaluated left to right, they are tested for possible
“short-circuit” evaluation using these rules:
false && anything is short-circuit evaluated to false.
true || anything is short-circuit evaluated to true.
The rules of logic guarantee that these evaluations are always correct. Note that
the anything part of the above expressions is not evaluated, so any side
effects of doing so do not take effect.
String Operators
Use the the concatenation operator (+) to concatenate two string values
together and areturn another string that is the union of the two operand
strings. For example, "my " + "string" returns the string "my string".
The shorthand assignment operator += can also be used to concatenate
strings. For example, if the variable mystring has the value “alpha,” then the
expression mystring += "bet" evaluates to “alphabet” and assigns this
value to mystring.
Table 14-8 describes the string operators.
Operator Description
+= Concatenates two strings and assigns the result to the first operand.
Operator Description
. Evaluates two expressions and returns the result of the second expression.
delete Lets you delete an object property or an element at a specified index in an array.
new Lets you create an instance of a user-defined object type or of one of the built-in
object types.
this Keyword that you can use to refer to the current object.
?: (Conditional operator)
The conditional operator is the only JavaScript operator that takes three
operands. This operator is frequently used as a shortcut for the if statement.
Description If condition is true, the operator returns the value of expr1; otherwise, it
returns the value of expr2. For example, to display a different message based
on the value of the isMember variable, you could use this statement:
Console.Write ("The fee is " + (isMember ? "$2.00" :
"$10.00"))
Description You can use the comma operator when you want to include multiple
expressions in a location that requires a single expression. The most common
usage of this operator is to supply multiple parameters in a for loop.
For example, if a is a 2-dimensional array with 10 elements on a side, the
following code uses the comma operator to increment two variables at once.
The code prints the values of the diagonal elements in the array:
for (var i=0, j=10; i <= 10; i++, j--)
Console.Write("a["+i+","+j+"]= " + a[i,j])
delete
The delete operator deletes an object’s property or an element at a specified
index in an array.
Car.prototype.color=null
car1.color="black"
birthday.description="The day you were born"
You can create any number of car objects by calls to new. For example,
kenscar = new car("Nissan", "300ZX", 1992)
Example 2: object property that is itself another object. Suppose you define an
object called person as follows:
function person(name, age, sex) {
this.name = name
this.age = age
this.sex = sex
}
Then you can rewrite the definition of car to include an owner property that
takes a person object, as follows:
function car(make, model, year, owner) {
this.make = make;
this.model = model;
this.year = year;
this.owner = owner;
}
Instead of passing a literal string or integer value when creating the new
objects, the above statements pass the objects rand and ken as the parameters
for the owners. To find out the name of the owner of car2, you can access the
following property:
car2.owner.name
this
A keyword that you can use to refer to the current object. In general, in a
method this refers to the calling object.
Syntax this[.propertyName]
typeof
The typeof operator is used in either of the following ways:
■ typeof operand
■ typeof (operand)
The typeof operator returns a string indicating the type of the unevaluated
operand. operand is the string, variable, keyword, or object for which the type
is to be returned. The parentheses are optional.
Suppose you define the following variables:
var myFun = new Function("5+2")
var shape="round"
var size=1
var today=new Date()
For the keywords true and null, the typeof operator returns these results:
typeof true is boolean
typeof null is object
For property values, the typeof operator returns the type of value the
property contains:
typeof document.lastModified is string
typeof window.length is number
typeof Math.LN2 is number
For methods and functions, the typeof operator returns results as follows:
typeof blur is function
typeof eval is function
typeof parseInt is function
typeof shape.split is function
void
The void operator is used in either of the following ways:
■ void (expression)
■ void expression
The void operator specifies an expression to be evaluated without returning a
value. expression is a JavaScript expression to evaluate. The parentheses
surrounding the expression are optional, but it is good style to use them.
15-1
Table 15-1 summarizes the JavaScript statements. Detailed descriptions of each
statement follow the table.
Statement Description
break Statement that terminates the current while or for loop and transfers program
control to the statement following the terminated loop.
comment Notations by the author to explain what a script does. The interpreter ignores
comments.
do...while Executes its statements until the test condition evaluates to false. Statement
is executed at least once.
for Statement that creates a loop that consists of three optional expressions,
enclosed in parentheses and separated by semicolons, followed by a block of
statement executed in the loop.
for...in Statement that iterates a specified variable over all the properties of an
object. For each distinct property, JavaScript executes the specified state-
ments.
labeled Provides an identifier that can be used with break or continue to indicate
where the program should continue execution.
switch Allows a program to evaluate an expression and attempt to match the expres-
sion's value to a case label.
while Statement that creates a loop that evaluates an expression, and if it is true,
executes a block of statements
with Statement that establishes the default object for a set of statements
15-2 Statements
break
Function Terminates the current while or for loop and transfers program control to
the statement following the terminated loop.
Syntax break
break label
Argument label
Identifier associated with the label of the statement.
Description The break statement can now include an optional label that allows the
program to break out of a labeled statement. This type of break must be in a
statement identified by the label used by break.
The statements in a labeled statement can be of any type.
Examples The following function has a break statement that terminates the while loop
when e is 3, and then returns the value 3 * x.
function testBreak(x) {
var i = 0
while (i < 6) {
if (i == 3)
break
i++
}
return i*x
}
break 15-3
checkiandj :
if (4==i) {
print("You've entered " + i);
checkj :
if (2==j) {
print("You've entered " + j);
break checkj;
Console.Write("The sum is " + (i+j));
}
Console.Write(i + "-" + j + "=" + (i-j));
}
15-4 Statements
comment
Function Comments are notes by the author explaining what the script does. The
interpreter ignores comments.
comment 15-5
continue
Function Terminates execution of the block of statements in a while or for loop, and
continues execution of the loop with the next iteration.
Syntax continue
continue label
Argument Label
Identifier associated with the label of the statement.
Description In contrast to the break statement, continue does not terminate the
execution of the loop entirely: instead in a while loop, it jumps back to the
condition; in a for loop, it jumps to the update expression.
The continue statement can now include an optional label that allows the
program to terminate execution of a labeled statement and continue to the
specified labeled statement. This type of continue must be in a looping
statement identified by the label used by continue.
Examples The following example shows a while loop that has a continue statement that
executes when the value of i is 3. Thus, n takes on the values 1, 3, 7, and 12.
i = 0
n = 0
while (i < 5) {
i++
if (i == 3)
continue
n += i
}
15-6 Statements
If continue had a label of checkiandj, the program would continue at the
top of the checkiandj statement.
checkiandj :
while (i<4) {
i+=1;
checkj :
while (j>4) {
print(j);
j-=1;
if ((j%2)==0)
continue checkj;
print(j);
}
Console.Write("i = " + i);
Console.Write("j = " + j);
}
continue 15-7
delete
You can only use the delete operator to deleteobject properties and array
entries. You cannot use this operator to deleteobjects or variables.
Consequently, you can only use the third form within a with statement, to
delete a property from the object.
15-8 Statements
do...while
Function Executes its statements until the test condition evaluates to false. Statement is
executed at least once.
Syntax do
statement
while (condition);
Arguments Statement
Block of statements that is executed at least once and is re-executed each time
the condition evaluates to true.
Condition
Evaluated after each pass through the loop. If condition evaluates to true,
the statements in the preceding block are re-executed. When condition
evaluates to false, control passes to the statement following do while.
Example In the following example, the do loop iterates at least once and reiterates until i
is no longer less than 5.
i=0
do {
i+=1;
Console.Write(i)
}
while (i<5)
do...while 15-9
for
Examples The following for statement starts by declaring the variable i and initializing
it to 0. It checks that i is less than nine, performs the two succeeding
statements, and increments i by 1 after each pass through the loop.
for (var i = 0; i < 9; i++) {
n += i
myfunc(n)
}
15-10 Statements
for...in
Function Iterates a specified variable over all the properties of an object. For each
distinct property, JavaScript executes the specified statements.
Arguments Variable
Variable to inerate over every property.
Object
Object for which the properties are iterated.
Statements
Specifies the statements to execute for each property.
Examples The following function takes as its argument an object and the object's name.
It then iterates over all the object's properties and returns a string that lists the
property names and their values.
function dump_props(obj, objName) {
var result = ""
for (var i in obj) {
result += objName + "." + i + " = " + obj[i]
}
return result
}
for...in 15-11
function
Arguments name
The function name.
param
The name of an argument to be passed to the function. A function can have up
to 255 arguments.
Description To return a value, the function must have a return statement that specifies
the value to return. You cannot nest a function statement in another statement
or in itself.
All parameters are passed to functions, by value. In other words, the value is
passed to the function, but if the function changes the value of the parameter,
this change is not reflected globally or in the calling function.
In addition to defining functions as described here, you can also define
Function objects.
Examples //This function returns the total dollar amount of sales, when
//given the number of units sold of products a, b, and c.
function calc_sales(units_a, units_b, units_c) {
return units_a*79 + units_b*129 + units_c*699
}
15-12 Statements
if...else
✏ Note The if …else statements must be in lowercase. If you type an uppercase “I" or “e", you will
get the “missing syntax error. A then statement is implied for values enclosed in the curly
braces { }. If you type the word then in a statement, an error message will be returned.
Syntax if (condition) {
statements1}
else {
statements2}
Arguments condition
Can be any JavaScript expression that evaluates to true or false. Parentheses are
required around the condition. If condition evaluates to true, the statements in
statements1 are executed.
statements 1, statements 2
Can be any JavaScript statements, including further nested if statements.
Multiple statements must be enclosed in braces.
if...else 15-13
labeled
Function Provides an identifier that can be used with break or continue to indicate
where the program should continue execution.
In a labeled statement, break or continue must be followed with a label,
and the label must be the identifier of the labeled statement containing break
or continue.
Syntax label :
statement
Arguments statement
Block of statements. break can be used with any labeled statement, and
continue can be used with looping labeled statements.
Example For an example of a labeled statement using break, see break. For an
example of a labeled statement using continue, see continue.
15-14 Statements
return
Examples The following function returns the square of its argument, x, where x is a
number.
function square(x) {
return x * x
}
return 15-15
switch
Arguments expression
Value matched against label.
label
Identifier used to match against expression
statement
Any statement.
15-16 Statements
Example In the following example, if expression evaluates to "Bananas," the program
matches the value with case "Bananas" and executes the associated statement.
When break is encountered, the program breaks out of switch and executes
the statement following switch. If break were omitted, the statement for
case "Cherries" would also be executed.
switch (i) {
case "Oranges" :
print("Oranges are $0.59 a pound.");
break;
case "Apples" :
Console.Write("Apples are $0.32 a pound.");
break;
case "Bananas" :
Console.Write("Bananas are $0.48 a pound.");
break;
case "Cherries" :
Console.Write("Cherries are $3.00 a pound.");
break;
default :
Console.Write("Sorry, we are out of " + i + ".");
}
Console.Write("Is there anything else you'd like?");
switch 15-17
var
Arguments varname
Variable name. It can be any legal identifier.
value
Initial value of the variable. Can be any legal expression.
Description The scope of a variable is the current function or, for variables declared outside
a function, the current application.
Using var outside a function is optional; you can declare a variable by simply
assigning it a value. However, it is good style to use var, and it is necessary in
functions if a global variable of the same name exists.
15-18 Statements
while
Function Creates a loop that evaluates an expression, and if it is true, executes a block of
statements. The loop then repeats, as long as the specified condition is true.
Arguments condition
Evaluated before each pass through the loop. If this condition evaluates to true,
the statements in the succeeding block are performed. When condition
evaluates to false, execution continues with the statement following
statements.
statements
Block of statements that are executed as long as the condition evaluates to true.
Although not required, it is good practice to indent these statements from the
beginning of the statement.
Examples The following while loop iterates as long as n is less than three.
n = 0
x = 0
while(n < 3) {
n ++
x += n
}
Each iteration, the loop increments n and adds it to x. Therefore, x and n take
on the following values:
■ After the first pass: n = 1 and x = 1
■ After the second pass: n = 2 and x = 3
■ After the third pass: n = 3 and x = 6
■ After completing the third pass, the condition n < 3 is no longer true, so
the loop terminates.
while 15-19
with
Function Establishes the default object for a set of statements. Within the set of
statements, any property references that do not specify an object are assumed
to be for the default object.
Arguments object
Specifies the default object to use for the statements. The parentheses around
object are required.
statements
Any block of statements.
Examples The following with statement specifies that the Math object is the default
object. The statements following the with statement refer to the PI property
and the cos and sin methods, without specifying an object. JavaScript
assumes the Math object for these references.
var a, x, y
var r=10
with (Math) {
a = PI * r * r
x = r * cos(PI)
y = r * sin(PI/2)
}
15-20 Statements
16 Core Objects
Object Description
Math Provides basic math constants and functions; for example, its PI property
contains the value of pi.
Regular Expression Represents a regular expression; also contains static properties that are
shared among all regular expression objects.
16-1
Array
Function An array allows you to store a list of common elements in a variable as shown
in the following example:
var models = new Array("Ford", "Mazda", "Honda");
You can easily access the elements of an array by using the index number
assigned to each element. Elements are stored in sequential order beginning
with index number 0, proceeding with index number 1, and so on. Since the
index numbering begins with 0, the array's item count will always be one
higher than the highest value of the array. The element's index number is
enclosed in square brackets and constitutes its location in the array. The Array
is a core object.
To set the first element of the array in the example shown above, you would
type:
models[0];
When you execute the JavaScript, the variable will contain the "Ford" string.
Parameters arrayLength
(Optional) The initial length of the array. You can access this value using the
length property.
element
(Optional) A list of values for the array's elements. When this form is specified,
the array is initialized with the specified values as its elements, and the array's
length property is set to the number of arguments.
Description An array's length increases if you assign a value to an element higher than the
current length of the array. The following code creates an array of length 0,
then assigns a value to element 99. This changes the length of the array to 100.
colors = new Array()
colors[99] = "midnightblue"
The result of a match between a regular expression and a string can create an
array. This array has properties and elements that provide information about
the match. An array is the return value of RegExp.exec, String.match,
and String.replace.
To help explain these properties and elements, look at the following example
and then refer to the table below:
//Match one d followed by one or more b's followed by one d
//Remember matched b's and the following d
//Ignore case
myRe=/d(b+)(d)/i;
myArray = myRe.exec("cdbBdbsbz");
Table 16-2 lists the properties and elements returned from this match.
Array 16-3
Examples The following example creates an array, msgArray, with a length of 0, then
assigns values to msgArray[0] and msgArray[99], changing the length of
the array to 100.
msgArray = new Array()
msgArray [0] = "Hello"
msgArray [99] = "world"
// The following statement is true,
// because defined msgArray [99] element.
if (msgArray.length == 100)
Console.Write("The length is 100.")
The following code creates a two-dimensional array and displays the results.
a = new Array(4)
for (i=0; i < 4; i++) {a[i] = new Array(4)
for (j=0; j < 4; j++)
{a[i][j] = "["+i+","+j+"]"}
}
for (i=0; i < 4; i++)
{str = "\r\nRow "+i+":"
for (j=0; j < 4; j++)
{str += a[i][j]}
Console.Write(str)
}
index For an array created by a regular expression match, the zero-based index of
the match in the string.
input For an array created by a regular expression match, reflects the original string
against which the regular expression was matched.
index
Property of Array
Description For an array created by a regular expression match, the zero-based index of the
match in the string. The index property is static.
input
Property of Array
Description For an array created by a regular expression mathc, reflects the original string
against which the regular expression was matched. The input property is
static.
Array 16-5
length
Property of Array
Description An integer that specifies the number of elements in an array. You can set the
length property to truncate an array at any time. You cannot extend an array;
for example, if you set length to 3 when it is currently 2, the array will still
contain only 2 elements. The length property is static.
Examples In the following example, the getChoice function uses the length property
to iterate over every element in the musicType array. musicType is a
select element on the musicForm form.
function getChoice() {
for (var i = 0; i < document.musicForm.musicType.length; i++)
{
if (document.musicForm.musicType.options[i].selected
== true) {
return
document.musicForm.musicType.options[i].text
}
}
}
prototype
Property of Array
Description Represents the prototype for this class. You can use the prototype to add
properties or methods to all instances of a class.
pop Removes the last element from an array and returns that element.
push Adds one or more elements to the end of an array and returns that last
element added.
reverse Transposes the elements of an array: the first array element becomes the last
and the last becomes the first.
shift Removes the first element from an array and returns that element.
unshift Adds one or more elements to the front of an array and returns the new length
of the array.
concat
Joins two arrays and returns a new array.
Applies to Array
Syntax concat(arrayName2)
Parameters ArrayName2
Name of the array to concatenate to this array.
Array 16-7
Description concat does not alter the original arrays, but returns a one level deep copy that
contains copies of the same elements combined from the original arrays.
Elements of the original arrays are copied into the new array as follows:
Object references (and not the actual object) — concat copies object
references into the new array. Both the original and new array refer to the same
object. If a referenced object changes, the changes are visible to both the new
and original arrays.
Strings and numbers (not String and Number objects) — concat copies
strings and numbers into the new array. Changes to the string or number in
one array do not affect the other arrays.
If a new element is added to either array, the other array is not affected.
join
Joins all elements of an array into a string.
Applies to Array
Syntax join(separator)
Parameters separator
Specifies a string to separate each element of the array. The separator is
converted to a string if necessary. If omitted, the array elements are separated
with a comma.
Description The string conversion of all array elements are joined into one string.
Examples The following example creates an array with three elements, then joins the
array three times: using the default separator, then a comma and a space, and
then a plus.
a = new Array("Wind","Rain","Fire")
Console.Write(a.join())
Console.Write(a.join(", "))
Console.Write(a.join(" + "))
pop
Removes the last element from an array and returns that element. This method
changes the length of the array.
Applies to Array
Syntax pop()
Parameters None
Example The following code displays the myFish array before and after removing its
last element. It also displays the removed element:
myFish = ["angel", "clown", "mandarin", "surgeon"];
Console.Write("\r\nmyFish before: " + myFish);
popped = myFish.pop();
Console.Write("\r\nmyFish after: " + myFish);
Console.Write("\r\npopped this element: " + popped);
push
Adds one or more elements to the end of an array and returns that last element
added. This method changes the length of the array.
Array 16-9
Applies to Array
Parameters elt1,...eltN
The elements to add to the end of the array.
Description The behavior of the push method is analogous to the push function in Perl 4.
Note that this behavior is different in Perl 5.
Example The following code displays the myFish array before and after adding
elements to its end. It also displays the last element added:
myFish = ["angel", "clown"];
Console.Write("myFish before: " + myFish);
pushed = myFish.push("drum", "lion");
Console.Write("myFish after: " + myFish);
Console.Write("pushed this element last: " + pushed);
reverse
Transposes the elements of an array: the first array element becomes the last
and the last becomes the first.
Applies to Array
Syntax reverse()
Parameters None
Description The reverse method transposes the elements of the calling array object.
Examples The following example creates an array myArray, containing three elements,
then reverses the array.
shift
Removes the first element from an array and returns that element. This
method changes the length of the array.
Applies to Array
Syntax shift()
Parameters None
Example The following code displays the myFish array before and after removing its
first element. It also displays the removed element:
myFish = ["angel", "clown", "mandarin", "surgeon"];
Console.Write("myFish before: " + myFish);
shifted = myFish.shift();
Console.Write("myFish after: " + myFish);
Console.Write("Removed this element: " + shifted);
slice
Extracts a section of an array and returns a new array.
Array 16-11
Applies to Array
Syntax slice(begin,end)
Parameters Begin
Zero-based index at which to begin extraction.
End
(Optional) Zero-based index at which to end extraction. slice extracts up to
but not including end. slice(1,4) extracts the second element through
the fourth element (elements indexed 1, 2, and 3). As a negative index, end
indicates an offset from the end of the sequence. slice(2,-1) extracts the
third element through the second to last element in the sequence. If end is
omitted, slice extracts to the end of the sequence.
Description slice does not alter the original array, but returns a new "one level deep"
copy that contains copies of the elements sliced from the original array.
Elements of the original array are copied into the new array as follows:
Object references (and not the actual object) -- slice copies object
references into the new array. Both the original and new array refer to the same
object. If a referenced object changes, the changes are visible to both the new
and original arrays.
Strings and numbers (not String and Number objects)-- slice copies
strings and numbers into the new array. Changes to the string or number in
one array does not affect the other array.
If a new element is added to either array, the other array is not affected.
splice
Changes the content of an array, adding new elements while removing old
elements.
Applies to Array
Parameters index
Index at which to start changing the array.
howMany
An integer indicating the number of old array elements to remove. If howMany
is 0, no elements are removed. In this case, you should specify at least one new
element.
Array 16-13
newElt1...newEltN
(Optional) The elements to add to the array. If you don't specify any elements,
splice simply removes elements from the array.
Description If you specify a different number of elements to insert than the number you're
removing, the array will have a different length at the end of the call. If
howMany is 1, this method returns the single element that it removes. If
howMany is more than 1, the method returns an array containing the removed
elements.
removed = myFish.splice(3, 1)
Console.Write("After removing 1: " + myFish);
Console.Write("removed is: " + removed);
Applies to Array
Syntax sort(compareFunction)
Parameters compareFunction
Specifies a function that defines the sort order. If omitted, the array is sorted
lexicographically (in dictionary order) according to the string conversion of
each element.
Array 16-15
JavaScript uses a stable sort: the index partial order of a and b does not change
if a and b are equal. If a's index was less than b's before sorting, it will be after
sorting, no matter how a and b move due to sorting.
a = new Array();
a[0] = "Ant";
a[5] = "Zebra";
function writeArray(x) {
for (i = 0; i < x.length; i++) {
Console.Write(x[i]);
if (i < x.length-1) Console.Write(", ");
}
}
writeArray(a);
a.sort();
Console.Write();
writeArray(a);
Examples The following example creates four arrays and displays the original array, then
the sorted arrays. The numeric arrays are sorted without, then with, a compare
function.
stringArray = new Array("Blue","Humpback","Beluga")
numericStringArray = new Array("80","9","700")
numberArray = new Array(40,1,5,200)
mixedNumericArray = new Array("80","9","700",40,1,5,200)
function compareNumbers(a, b) {
return a - b
}
Console.Write("stringArray:" + stringArray.join())
Console.Write("Sorted:" + stringArray.sort())
Console.Write("numberArray:" + numberArray.join())
Console.Write("Sorted without a compare function:" +
numberArray.sort())
Console.Write("Sorted with compareNumbers:" +
numberArray.sort(compareNumbers))
Console.Write("numericStringArray:" +
numericStringArray.join())
Console.Write("Sorted without a compare function:" +
numericStringArray.sort())
Console.Write("Sorted with compareNumbers:" +
numericStringArray.sort(compareNumbers))
Console.Write("mixedNumericArray:" + mixedNumericArray.join())
This example produces the following output. As the output shows, when a
compare function is used, numbers sort correctly whether they are numbers or
numeric strings.
stringArray: Blue,Humpback,Beluga
Sorted: Beluga,Blue,Humpback
numberArray: 40,1,5,200
Sorted without a compare function: 1,200,40,5
Sorted with compareNumbers: 1,5,40,200
numericStringArray: 80,9,700
Sorted without a compare function: 700,80,9
Sorted with compareNumbers: 9,80,700
mixedNumericArray: 80,9,700,40,1,5,200
Sorted without a compare function: 1,200,40,5,700,80,9
Sorted with compareNumbers: 1,5,9,40,80,200,700
toString
Returns a string representing the specified object.
Applies to Array
Syntax toString()
Parameters None
Description Every object has a toString method that is automatically called when it is to
be represented as a text value or when an object is referred to in a string
concatenation.
You can use toString within your own code to convert an object into a
string, and you can create your own function to be called in place of the default
toString method.
Array 16-17
For Array objects, the built-in toString method joins the array and
returns one string containing each array element separated by commas. For
example, the following code creates an array and uses toString to convert
the array to a string while writing output.
var monthNames = new Array("Jan","Feb","Mar","Apr")
Console.Write("monthNames.toString() is " +
monthNames.toString())
For information on defining your own toString method, see the Object:
toString method.
unshift
Adds one or more elements to the beginning of an array and returns the new
length of the array.
Applies to Array
Parameters elt1...eltN
The elements to add to the front of the araray.
Example The following code displays the myFish array before and after adding
elements to it.
myFish = ["angel", "clown"];
Console.Write("myFish before: " + myFish);
unshifted = myFish.unshift("drum", "lion");
Console.Write("myFish after: " + myFish);
Console.Write("New length: " + unshifted);
The Boolean object is an object wrapper for a boolean value. The Boolean
object is a core object.
Parameters value
The initial value of the Boolean object. The value is converted to a boolean
value, if necessary. If value is omitted or is 0, null, false, or the empty string
(""), the object has an initial value of false. All other values, including the string
"false", create an object with an initial value of true.
Description Use a Boolean object when you need to convert a non-boolean value to a
boolean value. You can use the Boolean object any place JavaScript expects a
primitive boolean value. JavaScript returns the primitive value of the Boolean
object by automatically invoking the valueOf method.
Examples The following examples create Boolean objects with an initial value of false:
bNoParam = new Boolean()
bZero = new Boolean(0)
bNull = new Boolean(null)
bEmptyString = new Boolean("")
bfalse = new Boolean(false)
The following examples create Boolean objects with an initial value of true:
btrue = new Boolean(true)
btrueString = new Boolean("true")
bfalseString = new Boolean("false")
bSuLin = new Boolean("Su Lin")
Boolean 16-19
Boolean Properties
Table 16-5 displays the boolean property. A detailed description of the
property follows the table.
prototype
Property of Boolean
Description Represents the prototype for this class. You can use the prototype to add
preoprties or methods toa ll instances of a class.
toString
Returns a string representing the specified object.
Syntax toString()
Parameters None
Description Every object has a toString method that is automatically called when it is to
be represented as a text value or when an object is referred to in a string
concatenation.
You can use toString within your own code to convert an object into a
string, and you can create your own function to be called in place of the default
toString method.
For Boolean objects and values, the built-in toString method returns "true" or
"false" depending on the value of the boolean object. In the following code,
flag.toString returns "true".
flag = new Boolean(true)
Console.Write("flag.toString() is " + flag.toString())
For information on defining your own toString method, see the Object:
toString method.
Boolean 16-21
Date
Lets you work with dates and times. Date is a core object.
Description If you supply no arguments, the constructor creates a Date object for
today's date and time. If you supply some arguments, but not others, the
missing arguments are set to 0. If you supply any arguments, you must supply
at least the year, month, and day. You can omit the hours, minutes, and
seconds.
The way JavaScript handles dates is very similar to the way Java handles dates:
both languages have many of the same date methods, and both store dates
internally as the number of milliseconds since January 1, 1970 00:00:00. Dates
prior to 1970 are not allowed.
prototype
Property of Date
Description Represents the prototype for this class. You can use the prototype to add
properties or methods to all instances of a class.
Date Methods
Table 16-8 displays a summary of the date methods. Detailed descriptions of
each method follow the table.
getDate Returns the day of the month for the specified date.
getDay Returns the day of the week for the specified date.
getTime Returns the numeric value corresponding to the time for the specified date.
GetTimezone- Returns the time-zone offset in minutes for the current locale.
Offset
Date 16-23
Tab l e 1 6 - 8 Date Methods (Continued)
parse Returns the number of milliseconds in a date string since January 1, 1970,
00:00:00, local time.
getDate
Returns the day of the month for the specified date.
Syntax getDate()
Parameters None
Examples The second statement below assigns the value 25 to the variable day, based on
the value of the Date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00")
day = Xmas95.getDate()
getDay
Returns the day of the week for the specified date.
Applies to Date
Syntax getDay()
Parameters None
Examples The second statement below assigns the value 1 to weekday, based on the
value of the Date object Xmas95. December 25, 1995, is a
Monday.
Xmas95 = new Date("December 25, 1995 23:15:00")
weekday = Xmas95.getDay()
getHours
Returns the hour for the specified date.
Applies to Date
Syntax getHours()
Parameters None
Examples The second statement below assigns the value 23 to the variable hours, based
on the value of the Date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00")
hours = Xmas95.getHours()
getMinutes
Returns the minutes in the specified date.
Applies to Date
Syntax getMinutes()
Parameters None
Date 16-25
Examples The second statement below assigns the value 15 to the variable minutes,
based on the value of the Date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00")
minutes = Xmas95.getMinutes()
getMonth
Returns the month in the specified date.
Applies to Date
Syntax getMonth()
Parameters None
Examples The second statement below assigns the value 11 to the variable month, based
on the value of the Date object Xmas95.
Xmas95 = new Date("December 25, 1995 23:15:00")
month = Xmas95.getMonth()
getSeconds
Returns the seconds in the current time.
Applies to Date
Syntax getSeconds()
Parameters None
getTime
Returns the numeric value corresponding to the time for the specified date.
Applies to Date
Syntax getTime()
Parameters None
Description The value returned by the getTime method is the number of milliseconds
since 1 January 1970 00:00:00. You can use this method to help assign a date
and time to another Date object.
getTimezoneOffset
Returns the time-zone offset in minutes for the current locale.
Applies to Date
Syntax getTimezoneOffset()
Parameters None
Description The time-zone offset is the difference between local time and Greenwich Mean
Time (GMT). Daylight savings time prevents this value from being a constant.
Date 16-27
Examples x = new Date()
currentTimeZoneOffsetInHours = x.getTimezoneOffset()/60
getFullYear
Returns the year in the specified date.
Applies to Date
Syntax getFullYear()
Parameters None
Description The value returned by getFullYear is the four-digit year. For example, if
the year is 1856, the value returned is 1856. If the year is 2026, the value
returned is 2026.
Examples The second statement assigns the value 1995 to the variable year.
Xmas = new Date("December 25, 1995 23:15:00")
year = Xmas.getFullYear()
The second statement assigns the value 2000 to the variable year.
Xmas = new Date("December 25, 2000 23:15:00")
year = Xmas.getFullYear()
The second statement assigns the value 95 to the variable year, representing
the year 1995.
Xmas.setYear(95)
year = Xmas.getFullYear()
parse
Returns the number of milliseconds in a date string since January 1, 1970,
00:00:00, local time. The parse method is static, read only.
Syntax Date.parse(dateString)
Parameters dateString
A string representing a date.
Description The parse method takes a date string (such as "Dec 25, 1995") and
returns the number of milliseconds since January 1, 1970, 00:00:00 (local
time). This function is useful for setting date values based on string values, for
example in conjunction with the setTime method and the Date object.
Given a string representing a time, parse returns the time value. It accepts the
IETF standard date syntax: "Mon, 25 Dec 1995 13:30:00 GMT." It
understands the continental US time-zone abbreviations, but for general use,
use a time-zone offset, for example, "Mon, 25 Dec 1995 13:30:00
GMT+0430" (4 hours, 30 minutes west of the Greenwich meridian). If you do
not specify a time zone, the local time zone is assumed. GMT and UTC are
considered equivalent.
Because parse is a static method of Date, you always use it as
Date.parse(), rather than as a method of a Date object you created.
Examples If IPOdate is an existing Date object, then you can set it to August 9, 1995 as
follows:
IPOdate.setTime(Date.parse("Aug 9, 1995"))
setDate
Sets the day of the month for a specified date.
Syntax setDate(dayValue)
Parameters datValue
An integer from 1 to 31, representing the day of the month.
Examples The second statement below changes the day for theBigDay to July 24 from
its original value.
Date 16-29
theBigDay = new Date("July 27, 1962 23:30:00"
theBigDay.setDate(24)
setHours
Sets the hours for a specified date.
Syntax setHours(hoursValue)
Parameters hoursValue
An integer between 0 and 23, representing the hour.
Examples theBigDay.setHours(7)
setMinutes
Sets the minutes for a specified date.
Syntax setMinutes(minutesValue)
Parameters mintuesValue
An integer between 0 and 59, representing the minutes.
Examples theBigDay.setMinutes(45)
setMonth
Sets the month for a specified date.
Syntax setMonth(monthValue)
Parameters monthValue
An integer between 0 and 11, representing the months January through
December.
Examples theBigDay.setMonth(6)
setSeconds
Sets the seconds for a specified date.
Syntax setSeconds(secondsValue)
Parameters secondsValue
An integer between 0 and 59.
Examples theBigDay.setSeconds(30)
setTime
Sets the value of a Date object.
Syntax setTime(timevalue)
Parameters timevalue
An integer representing the number of milliseconds since 1 January 1970
00:00:00.
Description Use the setTime method to help assign a date and time to another Date
object.
Date 16-31
Examples theBigDay = new Date("July 1, 1999")
sameAsBigDay = new Date()
sameAsBigDay.setTime(theBigDay.getTime())
setYear
Sets the year for a specified date.
Applies to Date
Syntax setYear(yearValue)
Parameters yearValue
An integer.
Description If yearValue is a number between 0 and 99 (inclusive), then the year for
dateObjectName is set to 1900 + yearValue. Otherwise, the year for
dateObjectName is set to yearValue.
Examples Note that there are two ways to set years in the 20th century.
■ The year is set to 1996.
theBigDay.setYear(96)
toGMTString
Converts a date to a string, using the Internet GMT conventions.
Syntax toGMTString()
Parameters None
In this example, the toGMTString method converts the date to GMT (UTC)
using the operating system's time-zone offset and returns a string value that is
similar to the following form. The exact format depends on the platform.
Mon, 18 Dec 1995 17:28:35 GMT
toLocaleString
Converts a date to a string, using the current locale's conventions.
Syntax toLocaleString()
Parameters None
Description If you pass a date using toLocaleString, be aware that different platforms
assemble the string in different ways. Using methods such as getHours,
getMinutes, and getSeconds gives more portable results.
Date 16-33
See also Date: toGMTString
UTC
Returns the number of milliseconds in a Date object since January 1, 1970,
00:00:00, Universal Coordinated Time (GMT). UTC is static, read only.
Applies to Date
Parameters year
A year after 1900.
month
A month between 0 and 11.
date
A day of the month between 1 and 31.
hrs
(Optional) A number of hours between 0 and 23.
min
(Optional) A number of minutes between 9 and 59.
sec
(Optional) A number of seconds between 0 and 59.
Description UTC takes comma-delimited date parameters and returns the number of
milliseconds since January 1, 1970, 00:00:00, Universal Coordinated Time
(GMT).
Because UTC is a static method of Date, you always use it as Date.UTC(),
rather than as a method of a Date object you created.
Examples The following statement creates a Date object using GMT instead of local
time:
gmtDate = new Date(Date.UTC(96, 11, 1, 0, 0, 0))
Description Function objects are evaluated each time they are used. This is less efficient
than declaring a function and calling it within your code, because declared
functions are compiled.
In addition to defining functions as described here, you can also use the
function statement, as described in the JavaScript Guide.
To call the Function object, you can specify the variable name as if it
were a function. The following code executes the function specified by the
changeName variable:
var newName="sales"
if (newName=="sales") {newName()}
function changeName() {
activeSection.name='sales'
}
Function 16-35
Assigning a function to a variable is similar to declaring a function, but they
have differences:
When you assign a function to a variable using var changeName = new
Function("..."), changeName is a variable for which the current
value is a reference to the function created with new Function().
When you create a function using function changeName() {...},
changeName is not a variable, it is the name of a function
■ Specifying arguments in a Function object
The following code specifies a Function object that takes two arguments.
var multFun = new Function("x", "y", "return x * y")
The string arguments "x" and "y" are formal argument names that are
used in the function body, "return x * y".
The following code shows a way to call the function multFun:
var theAnswer = multFun(7,6)
Console.Write("15*2 = " + multFun(15,2))
Function Properties
Table 16-9 displays a summary of the function properties. Detailed
descriptions of each property follow the table.
arguments
An array corresponding to the arguments passed to a function.
Description You can call a function with more arguments than it is formally declared to
accept by using the arguments array. This technique is useful if a function
can be passed a variable number of arguments. You can use
arguments.length to determine the number of arguments passed to the
function, and then treat each argument by using the arguments array.
The arguments array is available only within a function declaration.
Attempting to access the arguments array outside a function declaration
results in an error.
The this keyword does not refer to the currently executing function, so you
must refer to functions and Function objects by name, even within the
function body.
In JavaScript 1.2, arguments includes these additional properties:
■ formal arguments – Each formal argument of a function is a property of the
arguments array.
■ local variables – Each local variable of a function is a property of the
arguments array.
■ caller – A property whose value is the arguments array of the outer
function. If there is no outer function, the value is undefined.
■ callee – A property whose value is the function reference.
Function 16-37
Examples This example defines a function that creates test lists. The only formal
argument for the function is a string that changes the appearance of the list. To
create a bullet list (also called an "unordered list"), use "U". To create a
numbered list (also called an "ordered list"), use "O". The function is defined
as follows:
function list(type) {
Console.Write(type)
for (var i=1; i<list.arguments.length; i++) {
Console.Write(list.arguments[i])
Console.Write(type)
}
}
You can pass any number of arguments to this function, and it displays each
argument as an item in the type of list indicated. For example, the following
call to the function:
list("U", "One", "Two", "Three")
results in this output:
One
Two
Three
arity
Indicates the number of arguments expected by the function.
Description arity is external to the function, and indicates how many arguments the
function expects. By contrast, arguments.length provides the number of
arguments actually passed to the function.
Property of Function
Description The caller property is available only within the body of a function. If used
outside a function declaration, the caller property is null.
If the currently executing function was invoked by the top level of a JavaScript
program, the value of caller is null.
The this keyword does not refer to the currently executing function, so you
must refer to functions and Function objects by name, even within the
function body.
The caller property is a reference to the calling function, so if you use it in a
string context, you get the result of calling functionName.toString. That
is, the decompiled canonical source form of the function.
You can also call the calling function, if you know what arguments it might
want. Thus, a called function can call its caller without knowing the name of
the particular caller, provided it knows that all of its callers have the same form
and fit, and that they will not call the called function again unconditionally
(which would result in infinite recursion).
Examples The following code checks the value of a function's caller property.
function myFunc() {
if (myFunc.caller == null) {
alert("The function was called from the top!")
} else alert("This function's caller was " +
myFunc.caller)
}
prototype
A value from which instances of a particular class are created. Every object that
can be created by calling a constructor function has an associated prototype
property.
Function 16-39
Property of Object
Description You can add new properties or methods to an existing class by adding them to
the prototype associated with the constructor function for that class. The
syntax for adding a new property or method is:
fun.prototype.name = value
where
fun The name of the constructor function object you want to change.
name The name of the property or method to be created.
value The value initially assigned to the new property or method.
If you add a new property to the prototype for an object, then all objects
created with that object's constructor function will have that new property,
even if the objects existed before you created the new property. For example,
assume you have the following statements:
var array1 = new Array();
var array2 = new Array(3);
Array.prototype.description=null;
array1.description="Contains some stuff"
array2.description="Contains other stuff"
After you set a property for the prototype, all subsequent objects created with
Array will have the property:
anotherArray=new Array()
anotherArray.description="Currently empty"
Example The following example creates a method, str_rep, and uses the statement
String.prototype.rep = str_rep to add the method to all String
objects. All objects created with new String() then have that method, even
objects already created. The example then creates an alternate method and
adds that to one of the String objects using the statement s1.rep =
fake_rep. The str_rep method of the remaining String objects is not
altered.
var s1 = new String("a")
var s2 = new String("b")
var s3 = new String("c")
s2.rep(5) is bbbbb
s3.rep(2) is cc
s1.rep(1) is repeat a1 times.
s2.rep(4) is bbbb
s3.rep(6) is cccccc
The function in this example also works on String objects not created with
the String constructor. The following code returns "zzz".
"z".rep(3)
Function Methods
Table 16-10 displays the function method. A detailed description of the
method follows the table.
toString
Returns a string representing the specified object.
Function 16-41
Applies to Function
Syntax toString()
Parameters None
Description Every object has a toString method that is automatically called when it is
to be represented as a text value or when an object is referred to in a string
concatenation.
You can use toString within your own code to convert an object into a
string, and you can create your own function to be called in place of the default
toString method.
Any time Dog is used in a string context, JavaScript automatically calls the
toString function, which returns the following string:
function Dog(name, breed, color, sex) { this.name = name;
this.breed = breed; this.color = color; this.sex = sex; }
For information on defining your own toString method, see the Object:
toString method.
Function 16-43
Math
A built-in object that has properties and methods for mathematical constants
and functions. For example, the Math object's PI property has the value of pi.
Math is a core object.
Created by The Math object is a top-level, predefined JavaScript object. You can
automatically access it without using a constructor or calling a method.
Description All properties and methods of Math are static. You refer to the constant PI as
Math.PI and you call the sine function as Math.sin(x), where x is the
method's argument. Constants are defined with the full precision of real
numbers in JavaScript.
It is often convenient to use the with statement when a section of code uses
several Math constants and methods, so you don't have to type "Math"
repeatedly. For example:
with (Math) {
a = PI * r*r
y = r*sin(theta)
x = r*cos(theta)
}
E
Euler's constant and the base of natural logarithms, approximately 2.718. Math
is static, read-only.
Property of Math
Description Because E is a static property of Math, you always use it as Math.E, rather
than as a property of a Math object you created.
LN10
The natural logarithm of 10, approximately 2.302. LN10 is static, read-only.
Math 16-45
Property of Math
Description Because LN10 is a static property of Math, you always use it as Math.LN10,
rather than as a property of a Math object you created.
LN2
The natural logarithm of 2, approximately 0.693. LN2 is static, read-only.
Property of Math
Description Because LN2 is a static property of Math, you always use it as Math.LN2,
rather than as a property of a Math object you created.
LOG10E
The base 10 logarithm of E (approximately 0.434). LOG10E is static, read-
only.
Property of Math
Property of Math
PI
The ratio of the circumference of a circle to its diameter, approximately
3.14159. PI is static, read-only.
Property of Math
Description Because PI is a static property of Math, you always use it as Math.PI, rather
than as a property of a Math object you created.
SQRT1_2
The square root of ò; equivalently, 1 over the square root of 2, approximately
0.707. SQRT1_2 is static, read-only.
Property of Math
Math 16-47
Description Because SQRT1_2 is a static property of Math, you always use it as
Math.SQRT1_2, rather than as a property of a Math object you created.
SQRT2
The square root of 2, approximately 1.414. SQRT2 is static, read-only.
Property of Math
Description Because SQRT2 is a static property of Math, you always use it as Math.SQRT2,
rather than as a property of a Math object you created.
exp Returns Enumber, where number is the argument, and E is Euler's constant, the
base of the natural logarithms.
abs
Returns the absolute value of a number.
Math 16-49
Applies to Math
Syntax abs(x)
Parameters x
A number.
Example The following function returns the absolute value of the variable x:
function getAbs(x) {
return Math.abs(x)
}
Description abs is a static method of Math. As a result, you always use it as Math.abs(),
rather than as a method of a Math object you create.
acos
Returns the arccosine (in radians) of a number.
Applies to Math
Syntax acos(x)
Parameters x
A number.
Description The acos method returns a numeric value between 0 and pi radians. If the
value of number is outside this range, it returns 0.
acos is a static method of Math. As a result, you always use it as
Math.acos(), rather than as a method of a Math object you create.
asin
Returns the arcsine (in radians) of a number.
Applies to Math
Syntax asin(x)
Parameters x
A number.
Description The asin method returns a numeric value between -pi/2 and pi/2 radians. If
the value of number is outside this range, it returns 0.
asin is a static method of Math. As a result, you always use it as
Math.asin(), rather than as a method of a Math object you create.
atan
Returns the arctangent (in radians) of a number.
Applies to Math
Syntax atan(x)
Parameters x
A number.
Math 16-51
Description The atan method returns a numeric value between -pi/2 and pi/2 radians.
atan is a static method of Math. As a result, you always use it as
Math.atan(), rather than as a method of a Math object you create.
atan2
Returns the arctangent of the quotient of its arguments.
Applies to Math
Syntax atan2(y, x)
Parameters y,x
A number.
Description The atan2 method returns a numeric value between -pi and pi representing
the angle theta of an (x,y) point. This is the counterclockwise angle, measured
in radians, between the positive X axis, and the point (x,y). Note that the
arguments to this function pass the y-coordinate first and the x-coordinate
second.
atan2 is passed separate x and y arguments, and atan is passed the ratio of
those two arguments.
atan2 is a static method of Math. As a result, you always use it as
Math.atan2(), rather than as a method of a Math object you create.
Example The following function returns the angle of the polar coordinate:
function getAtan2(x,y) {
return Math.atan2(x,y)
ceil
Returns the smallest integer greater than or equal to a number.
Applies to Math
Syntax ceil(x)
Parameters x
A number.
Example The following function returns the ceil value of the variable x:
function getCeil(x) {
return Math.ceil(x)
}
If you pass 45.95 to getCeil, it returns 46; if you pass -45.95, it returns -45.
cos
Returns the cosine of a number.
Applies to Math
Syntax cos(x)
Parameters x
A number.
Math 16-53
Description The cos method returns a numeric value between -1 and 1, which represents
the cosine of the angle.
cos is a static method of Math. As a result, you always use it as Math.cos(),
rather than as a method of a Math object you create.
exp
Returns Ex, where x is the argument, and E is Euler's constant, the base of the
natural logarithms.
Applies to Math
Syntax exp(x)
Parameters x
A number.
Description exp is a static method of Math. As a result, you always use it as Math.exp(),
rather than as a method of a Math object you create.
Examples The following function returns the exponential value of the variable x:
function getExp(x) {
return Math.exp(x)
}
floor
Returns the largest integer less than or equal to a number.
Applies to Math
Syntax floor(x)
Parameters x
A number.
Examples The following function returns the floor value of the variable x:
function getFloor(x) {
return Math.floor(x)
}
If you pass 45.95 to getFloor, it returns 45; if you pass -45.95, it returns -46.
log
Returns the natural logarithm (base E) of a number.
Applies to Math
Syntax log(x)
Parameters x
A number.
Description If the value of number is outside the suggested range, the return value is always
-1.797693134862316e+308.
log is a static method of Math. As a result, you always use it as Math.log(),
rather than as a method of a Math object you create.
Math 16-55
Examples The following function returns the natural log of the variable x:
function getLog(x) {
return Math.log(x)
}
If you pass getLog the value 10, it returns 2.302585092994046; if you pass it
the value 0, it returns -1.797693134862316e+308 because 0 is out of range.
max
Returns the larger of two numbers.
Applies to Math
Syntax max(x,y)
Parameters x,y
Numbers.
Description max is a static method of Math. As a result, you always use it as Math.max(),
rather than as a method of a Math object you create.
If you pass getMax the values 10 and 20, it returns 20; if you pass it the values
-10 and -20, it returns -10.
min
Returns the smaller of two numbers.
Syntax min(x,y)
Parameters x,y
Numbers.
If you pass getMin the values 10 and 20, it returns 10; if you pass it the values
-10 and -20, it returns -20.
pow
Returns base to the exponent power, that is, baseexponent.
Applies to Math
Syntax pow(x,y)
Parameters base
The base number.
exponent
The exponent to which to raise base.
Description pow is a static method of Math. As a result, you always use it as Math.pow(),
rather than as a method of a Math object you create.
Math 16-57
Examples function raisePower(x,y) {
return Math.pow(x,y)
}
random
Returns a pseudo-random number between 0 and 1. The random number
generator is seeded from the current time, as in Java.
Applies to Math
Syntax random()
Parameters None
round
Returns the value of a number rounded to the nearest integer.
Applies to Math
Syntax round(x)
Parameters x
A number.
sin
Returns the sine of a number.
Applies to Math
Syntax sin(x)
Parameters x
A number.
Description The sin method returns a numeric value between -1 and 1, which represents
the sine of the argument.
sin is a static method of Math. As a result, you always use it as Math.sin(),
rather than as a method of a Math object you create.
Math 16-59
See also Math:acos, Math:asin, Math:atan, Math:atan2, Math:cos,
Math:tan
sqrt
Returns the square root of a number.
Applies to Math
Syntax sqrt(x)
Parameters x
A number.
Description If the value of number is outside the required range, sqrt returns 0.
sqrt is a static method of Math. As a result, you always use it as
Math.sqrt(), rather than as a method of a Math object you create.
Examples The following function returns the square root of the variable x:
function getRoot(x) {
return Math.sqrt(x)
}
If you pass getRoot the value 9, it returns 3; if you pass it the value 2, it
returns 1.414213562373095.
tan
Returns the tangent of a number.
Applies to Math
Syntax tan(x)
Parameters x
A number.
Description The tan method returns a numeric value that represents the tangent of the
angle.
Math 16-61
Number
Lets you work with numeric values. The Number object is an object wrapper
for primitive numeric values and a core object.
Parameters value
The numeric value of the object being created.
The properties of Number are properties of the class itself, not of individual
Number objects.
Number(x) now produces NaN rather than an error if x is a string that does
not contain a well-formed numeric literal. For example:
x=Number("three");
Console.Write(x);
prints NaN
Examples The following example uses the Number object's properties to assign values to
several numeric variables:
biggestNum = Number.MAX_VALUE
smallestNum = Number.MIN_VALUE
infiniteNum = Number.POSITIVE_INFINITY
negInfiniteNum = Number.NEGATIVE_INFINITY
notANum = Number.NaN
Number Properties
Table 16-13 displays a summary of the number properties. Detailed
descriptions of each property follow the table.
MAX_VALUE
The maximum numeric value representable in JavaScript.
Property of Number
Example The following code multiplies two numeric values. If the result is less than or
equal to MAX_VALUE, the func1 function is called; otherwise, the func2
function is called.
Number 16-63
if (num1 * num2 <= Number.MAX_VALUE)
func1()
else
func2()
MIN_VALUE
The smallest positive numeric value that can be represented in JavaScript.
Property of Number
Description The MIN_VALUE property is the number closest to 0, not the most negative
number, that JavaScript can represent.
MIN_VALUE has a value of approximately 2.22E-308. Values smaller than
MIN_VALUE ("underflow values") are converted to 0.
Example The following code divides two numeric values. If the result is greater than or
equal to MIN_VALUE, the func1 function is called; otherwise, the func2
function is called.
if (num1 / num2 >= Number.MIN_VALUE)
func1()
else
func2()
NaN
A special value representing Not-A-Number. This value is represented as the
unquoted literal NaN. NaN is a read-only property.
Property of Number
You might use the NaN property to indicate an error condition for a function
that should return a valid number.
NEGATIVE_INFINITY
A special numeric value representing negative infinity. This value is displayed
as -Infinity.
Description This value behaves mathematically like infinity; for example, anything
multiplied by infinity is infinity, and anything divided by infinity is 0.
NEGATIVE_INFINITY is a static, read-only property of Number. As a result,
you always use it as Number.NEGATIVE_INFINITY, rather than as a property
of a Number object you create.
Examples In the following example, the variable smallNumber is assigned a value that is
smaller than the minimum value. When the if statement executes,
smallNumber has the value -Infinity, so the func1 function is called.
var smallNumber = -Number.MAX_VALUE*10
if (smallNumber == Number.NEGATIVE_INFINITY)
func1()
else
func2()
POSITIVE_INFINITY
A special numeric value representing infinity. This value is displayed as
Infinity.
Property of Number
Description This value behaves mathematically like infinity; for example, anything
multiplied by infinity is infinity, and anything divided by infinity is 0.
JavaScript does not have a literal for Infinity.
Number 16-65
POSITIVE_INFINITY is a static, read-only property of Number. As a result,
you always use it as Number.POSITIVE_INFINITY, rather than as a property
of a Number object you create.
Example In the following example, the variable bigNumber is assigned a value that is
larger than the maximum value. When the if statement executes, bigNumber
has the value Infinity, so the func1 function is called.
var bigNumber = Number.MAX_VALUE * 10
if (bigNumber == Number.POSITIVE_INFINITY)
func1()
else
func2()
Prototype
Description Represents the prototype for this class. You can use the prototype to add
properties or methods to all instances of a class. For information on
prototypes, see Function.prototype.
Property of Number
toString
Returns a string representing the specified object.
Applies to Number
Syntax toString()
toString(radix)I I
Parameters radix
(Optional) An integer between 2 and 16 specifying the base to use for
representing numeric values.
Description Every object has a toString method that is automatically called when it is to
be represented as a text value or when an object is referred to in a string
concatenation.
You can use toString within your own code to convert an object into a
string, and you can create your own function to be called in place of the default
toString method.
You can use toString on numeric values, but not on numeric heliterals:
// The next two lines are valid
var howMany=10
("howMany.toString() is " + howMany.toString() )
// The next line causes an error
("45.toString() is " + 45.toString() )
Number 16-67
For information on defining your own toString method, see the
Object.toString method.
Object is the primitive JavaScript object type. All JavaScript objects are
descended from Object. That is, all JavaScript objects have the methods
defined for Object.
Parameters None
Object Properties
Table 16-15 displays a summary of the object properties. Detailed descriptions
of each property follow the table.
constructor
Specifies the function that creates an object's prototype. Note that the value of
this property is a reference to the function itself, not a string containing the
function's name.
Object 16-69
Example The following example creates a prototype, Tree, and an object of that type,
theTree. The example then displays the constructor property for the
object theTree.
function Tree(name) {
this.name=name
}
theTree = new Tree("Redwood")
Console.Write("theTree.constructor is" +
theTree.constructor)
Prototype
Represents the prototype for this class. You can use the prototype to add
properties or methods to all instances of a class. For more information, see
“prototype” on page 16-39.
Property of Object
Object Methods
Table 16-16 displays a summary of the object methods. Detailed descriptions
of each method follow the table.
eval
Evaluates a string of JavaScript code in the context of this object.
Syntax eval(string)
Parameters string
Any string representing a JavaScript expression, statement, or sequence of
statements. The expression can include variables and properties of existing
objects.
Description The argument of the eval method is a string. If the string represents an
expression, eval evaluates the expression. If the argument represents one or
more JavaScript statements, eval performs the statements. Do not call eval
to evaluate an arithmetic expression; JavaScript evaluates arithmetic
expressions automatically.
If you construct an arithmetic expression as a string, you can use eval to
evaluate it at a later time. For example, suppose you have a variable x. You can
postpone evaluation of an expression involving x by assigning the string value
of the expression, say "3 * x + 2", to a variable, and then calling eval at a
later point in your script.
eval is also a global function, not associated with any object.
Examples The following example creates breed as a property of the object myDog, and
also as a variable. The first write statement uses eval('breed') without
specifying an object; the string “breed” is evaluated without regard to any
object, and the write method displays Shepherd, which is the value of the
breed variable.
Object 16-71
The following example uses eval within a function that defines an object
type, stone. The statement flint = new stone("x=42") creates the
object flint with the properties x, y, z, and z2. The write statements
display the values of these properties as 42, 43, 44, and 45, respectively.
function stone(str) {
this.eval("this."+str)
this.eval("this.y=43")
this.z=44
this["z2"] = 45
}
toString
Returns a string representing the specified object.
Applies to Object
Syntax toString()
toString(radix)
Parameters radix
(Optional) An integer between 2 and 16 specifying the base to use for
representing numeric values.
Description Every object has a toString method that is automatically called when it is
to be represented as a text value or when an object is referred to in a string
concatenation. For example, the following examples require theDog to be
represented as a string:
Console.Write(theDog)
Console.Write("The dog is " + theDog)
The following code creates dogToString, the function that will be used
in place of the default toString method. This function generates a string
containing each property, of the form property = value;.
function dogToString() {
var ret = "Dog " + this.name + " is ["
for (var prop in this)
ret += " " + prop + " is " + this[prop] + ";"
return ret + "]"
}
Object 16-73
With the preceding code in place, any time theDog is used in a string
context, JavaScript automatically calls the dogToString function, which
returns the following string:
Dog Gabby is [ name is Gabby; breed is Lab; color is
chocolate; sex is girl; toString is function dogToString() {
var ret = "Object " + this.name + " is ["; for (var prop in
this) { ret += " " + prop + " is " + this[prop] + ";"; }
return ret + "]"; } ;]
Examples The following example prints the string equivalents of the numbers 0 through
9 in decimal and binary.
for (x = 0; x < 10; x++) {
("Decimal: ", x.toString(10), " Binary: ",
Console.write
x.toString(2))
}
unwatch
Removes a watchpoint set with the watch method.
Syntax unwatch(prop)
Parameters prop
The name of a property of the object.
valueOf
Returns the primitive value of the specified object.
Applies to Object
Syntax valueOf()
Parameters None
Description Every object has a valueOf method that is automatically called when it is to
be represented as a primitive value. If an object has no primitive value,
valueOf returns the object itself.
You can use valueOf within your own code to convert an object into a
primitive value, and you can create your own function to be called in place of
the default valueOf method.
Every object type has a built-in valueOf method, which JavaScript calls
whenever it needs to convert an object to a primitive value.
You rarely need to invoke the valueOf method yourself. JavaScript
automatically invokes it when encountering an object where a primitive value
is expected.
Table 16-17 shows object types for which the valueOf method is most useful.
Most other objects have no primitive value.
Object 16-75
Tab l e 1 6 - 1 7 Object Types for the valueOf Method
Function Function reference associated with the object. For example, typeof
funObj returns object, but typeof funObj.valueOf()
returns function.
You can create a function to be called in place of the default valueOf method.
Your function must take no arguments.
Suppose you have an object type myNumberType and you want to create a
valueOf method for it. The following code assigns a user-defined function to
the object's valueOf method:
myNumberType.prototype.valueOf = new Function(functionText)
With the preceding code in place, any time an object of type myNumberType
is used in a context where it is to be represented as a primitive value, JavaScript
automatically calls the function defined in the preceding code.
An object's valueOf method is usually invoked by JavaScript, but you can
invoke it yourself as follows:
myNumber.valueOf()
✰ Tip Objects in string contexts convert via the toString method, which is
different from String objects converting to string primitives using valueOf.
All string objects have a string conversion, if only [object type]. But many
objects do not convert to number, boolean, or function.
watch
Watches for a property to be assigned a value and runs a function when that
occurs.
Parameters prop
The name of a property of the object.
handler
A function to call.
Description Watches for assignment to a property named prop in this object, calling
handler(prop, oldval, newval) whenever prop is set and storing
the return value in that property. A watchpoint can filter (or nullify) the value
assignment, by returning a modified newval (or oldval).
If you delete a property for which a watchpoint has been set, that watchpoint
does not disappear. If you later recreate the property, the watchpoint is still in
effect.
To remove a watchpoint, use the unwatch method.
Example o = {p:1}
o.watch("p",
function (id,oldval,newval) {
Console.Write("o." + id + " changed from "
+ oldval + " to " + newval)
return newval
})
o.p = 2
o.p =
delete o.p
o.p = 4
o.unwatch('p')
o.p = 5
Object 16-77
String
Parameters string
Any string.
Description The String object is a built-in JavaScript object. You an treat any JavaScript
string as a String object.
A string can be represented as a literal enclosed by single or double quotation
marks; for example, "Brio" or 'Brio'.
length
The length of the string. The length property is read-only.
Property of String
prototype
Represents the prototype for this class. You can use the prototype to add
properties or methods to all instances of a class. For information on
prototypes, see Function.prototype.
Property of String
String 16-79
String Methods
Table 16-19 displays a summary of the string methods. Detailed descriptions of
each method follow the table.
charCodeat Returns a number indicating the ISO-Latin-1 codeset value of the charac-
ter at the given index.
concat Combines the text of two strings and returns a new string.
fromCharCode Returns a string from the specified sequence of numbers that are ISO-
Latin-1 codeset values.
indexOf Returns the index within the calling String object of the first occur-
rence of the specified value.
lastIndexOf Returns the index within the calling String object of the last occur-
rence of the specified value.
replace Used to find a match between a regular expression and a string, and to
replace the matched substring with a new substring.
search Executes the search for a match between a regular expression and a
specified string.
split Splits a String object into an array of strings by separating the string
into substrings.
substring Returns the characters in a string between two indexes into the string.
anchor
Creates an HTML anchor that is used as a hypertext target.
Applies to String
Syntax anchor(nameAttribute)
Parameters nameAttribute
A string.
String 16-81
Anchors created with the anchor method become elements in the
document.anchors array.
Examples The following example opens the msgWindow window and creates an anchor
for the table of contents:
var myString="Table of Contents"
Write(myString.anchor("contents_anchor"))
The previous example produces the same output as the following HTML:
<A NAME="contents_anchor">Table of Contents</A>
big
Causes a string to be displayed in a big font as if it were in a BIG tag.
Applies to String
Syntax big()
Parameters None
Description Use the big method with the Write method to format and display a string in
a document.
Example The following example uses string methods to change the size of a string:
var worldString="Hello, world"
Console.Write(worldString.small())
Console.Write(worldString.big())
Console.Write(worldString.fontsize(7))
The previous example produces the same output as the following HTML:
<SMALL>Hello, world</SMALL>
<BIG>Hello, world</BIG>
<FONTSIZE=7>Hello, world</FONTSIZE>
blink
Causes a string to blink as if it were in a BLINK tag.
Applies to String
Syntax blink()
Parameters None
Description Use the blink method with the Write method to format and display a string
in a document.
Example The following example uses string methods to change the formatting of a
string:
var worldString="Hello, world"
Console.Write(worldString.blink())
Console.Write("<P>" + worldString.bold())
Console.Write("<P>" + worldString.italics())
Console.Write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
bold
Causes a string to be displayed as bold as if it were in a B tag.
Applies to String
Syntax bold()
Parameters None
String 16-83
Description Use the bold method with the Write methods to format and display a string
in a document.
Example The following example uses string methods to change the formatting of a
string:
var worldString="Hello, world"
Console.Write(worldString.blink())
Console.Write("<P>" + worldString.bold())
Console.Write("<P>" + worldString.italics())
Console.Write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
charAt
Returns the specified character from the string.
Applies to String
Syntax charAt(index)
Parameters index
An integer between 0 and 1 less than the length of the string.
Description Characters in a string are indexed from left to right. The index of the first
character is 0, and the index of the last character in a string called
stringName is stringName.length - 1. If the index you supply is
out of range, JavaScript returns an empty string.
Example The following example displays characters at different locations in the string
"Brave new world":
var anyString="Brave new world"
charCodeAt
Returns a number indicating the ISO-Latin-1 codeset value of the character at
the given index.
Applies to String
Syntax charCodeAt(index)
Parameters index
(Optional) An integer between 0 and 1 less than the length of the string. The
default value is 0.
Description The ISO-Latin-1 codeset ranges from 0 to 255. The first 0 to 127 are a direct
match of the ASCII character set.
Example The following example returns 65, the ISO-Latin-1 codeset value for A.
"ABC".charCodeAt(0)
concat
Combines the text of two strings and returns a new string.
String 16-85
Applies to String
Syntax concat(string2)
Parameters string1
The first string.
string 2
The second string.
Description concat combines the text from two strings and returns a new string. Changes
to the text in one string do not affect the other string.
Example The following example combines two strings into a new string.
str1="The morning is upon us. "
str2="The sun is bright."
str3=str1.concat(str2)
Console.Write(str1)
Console.Write(str2)
Console.Write(str3)
This writes:
The morning is upon us.
The sun is bright.
The morning is upon us. The sun is bright.
fixed
Causes a string to be displayed in fixed-pitch font as if it were in a TT tag.
Applies to String
Syntax fixed()
Parameters None
Description Use the fixed method with the Write method to format and display a string
in a document.
Example The following example uses the fixed method to change the formatting of a
string:
var worldString="Hello, world"
The previous example produces the same output as the following HTML:
<TT>Hello, world</TT>
fontcolor
Causes a string to be displayed in the specified color as if it were in a <FONT
COLOR=color> tag.
Applies to String
Syntax fontcolor(color)
Parameters color
A string expressing the color as a hexadecimal RGB triplet or as a string literal.
String literals for color names are listed in Appendix B, "Color Values," in the
JavaScript Guide.
Description Use the fontcolor method with the Write method to format and display a
string in a document.
If you express color as a hexadecimal RGB triplet, you must use the format
rrggbb. For example, the hexadecimal RGB values for salmon are red=FA,
green=80, and blue=72, so the RGB triplet for salmon is "FA8072".
Examples The following example uses the fontcolor method to change the color of a
string:
var worldString="Hello, world"
Console.Write(worldString.fontcolor("maroon") +
" is maroon in this line")
Console.Write("<P>" + worldString.fontcolor("salmon") +
" is salmon in this line")
Console.Write("<P>" + worldString.fontcolor("red") +
" is red in this line")
Console.Write("<P>" + worldString.fontcolor("8000") +
" is maroon in hexadecimal in this line")
Console.Write("<P>" + worldString.fontcolor("FA8072") +
" is salmon in hexadecimal in this line")
Console.Write("<P>" + worldString.fontcolor("FF00") +
" is red in hexadecimal in this line")
The previous example produces the same output as the following HTML:
String 16-87
<FONT COLOR="maroon">Hello, world</FONT> is maroon in this line
<P><FONT COLOR="salmon">Hello, world</FONT> is salmon in this
line
<P><FONT COLOR="red">Hello, world</FONT> is red in this line
<FONT COLOR="8000">Hello, world</FONT>
is maroon in hexadecimal in this line
<P><FONT COLOR="FA8072">Hello, world</FONT>
is salmon in hexadecimal in this line
<P><FONT COLOR="FF00">Hello, world</FONT>
is red in hexadecimal in this line
fontsize
Causes a string to be displayed in the specified font size as if it were in a <FONT
SIZE=size> tag.
Applies to String
Syntax fontsize(size)
Parameters size
An integer between 1 and 7, a string representing a signed integer between 1
and 7.
Description Use the fontsize method with the Write method to format and display a
string in a document.
When you specify size as an integer, you set the size of stringName to one
of the 7 defined sizes. When you specify size as a string such as "-2", you
adjust the font size of stringName relative to the size set in the BASEFONT
tag.
Example The following example uses string methods to change the size of a string:
var worldString="Hello, world"
Console.Write(worldString.small())
Console.Write("<P>" + worldString.big())
Console.Write("<P>" + worldString.fontsize(7))
The previous example produces the same output as the following HTML:
<SMALL>Hello, world</SMALL>
<P><BIG>Hello, world</BIG>
<P><FONTSIZE=7>Hello, world</FONTSIZE>
fromCharCode
Returns a string created by using the specified sequence ISO-Latin-1 codeset
values.
Applies to String
Parameters num1...numN
A sequence of numbers that are ISO-Latin-1 codeset values.
indexOf
Returns the index within the calling String object of the first occurrence of
the specified value, starting the search at fromIndex, or -1 if the value is not
found.
Applies to String
Parameters searchValue
A string representing the value for which to search.
fromIndex
(Optional) The location within the calling string to start the search from. It
can be any integer between 0 and 1 less than the length of the string. The
default value is 0.
String 16-89
Description Characters in a string are indexed from left to right. The index of the first
character is 0, and the index of the last character of a string called
stringName is stringName.length - 1.
Examples The following example uses indexOf and lastIndexOf to locate values in
the string "Brave new world."
var anyString="Brave new world"
//Displays 8
Console.Write("<P>The index of the first w from the beginning is
" +
anyString.indexOf("w"))
//Displays 10
Console.Write("<P>The index of the first w from the end is " +
anyString.lastIndexOf("w"))
//Displays 6
Console.Write("<P>The index of 'new' from the beginning is " +
anyString.indexOf("new"))
//Displays 6
Console.Write("<P>The index of 'new' from the end is " +
anyString.lastIndexOf("new"))
The following example defines two string variables. The variables contain the
same string except that the second string contains uppercase letters. The first
writeln method displays 19. But because the indexOf method is case
sensitive, the string "cheddar" is not found in myCapString, so the second
writeln method displays -1.
myString="brie, pepper jack, cheddar"
myCapString="Brie, Pepper Jack, Cheddar"
Console.Write('myString.indexOf("cheddar") is ' +
myString.indexOf("cheddar"))
Console.Write('myCapString.indexOf("cheddar") is ' +
myCapString.indexOf("cheddar"))
The following example sets count to the number of occurrences of the letter x
in the string str:
count = 0;
pos = str.indexOf("x");
while ( pos != -1 ) {
count++;
pos = str.indexOf("x",pos+1);
}
16-90 Core Objects
See also String:charAt, String:lastIndexOf, String:split
italics
Causes a string to be italic, as if it were in an I tag.
Applies to String
Syntax italics()
Parameters None
Description Use the italics method with the Write method to format and display a
string in a document.
Example The following example uses string methods to change the formatting of a
string:
var worldString="Hello, world"
Console.Write(worldString.blink())
Console.Write(worldString.bold())
Console.Write(worldString.italics())
Console.Write(worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
lastIndexOf
Returns the index within the calling String object of the last occurrence of
the specified value. The calling string is searched backward, starting at
fromIndex, or -1 if not found.
String 16-91
Applies to String
Parameters searchValue
A string representing the value for which to search.
fromIndex
(Optional) The location within the calling string to start the search from. It
can be any integer between 0 and 1 less than the length of the string. The
default value is 1 less than the length of the string.
Description Characters in a string are indexed from left to right. The index of the first
character is 0, and the index of the last character is stringName.length -
1.
Example The following example uses indexOf and lastIndexOf to locate values in
the string "Brave new world."
var anyString="Brave new world"
//Displays 8
Console.Write("The index of the first w from the beginning is "
+
anyString.indexOf("w"))
//Displays 10
Console.Write("The index of the first w from the end is " +
anyString.lastIndexOf("w"))
//Displays 6
Console.Write("The index of 'new' from the beginning is " +
anyString.indexOf("new"))
//Displays 6
Console.Write("The index of 'new' from the end is "
anyString.lastIndexOf("new"))
link
Creates an HTML hypertext link that requests another URL.
Syntax link(hrefAttribute)
Parameters hrefAttribute
Any string that specifies the HREF attribute of the A tag; it should be a valid
URL (relative or absolute).
Description Use the link method to programmatically create a hypertext link, and then
call to display the link in a document.
Example The following example displays the word "Brio" as a hypertext link that returns
the user to Brio's Web site:
var hotText="Brio"
var URL="http://www.brio.com"
Console.Write("Click to return to " + hotText.link(URL))
The previous example produces the same output as the following HTML:
Click to return to <A HREF="http://www.brio.com">Brio</A>
match
Used to match a regular expression against a string.
Applies to String
Syntax match(regexp)
Parameters regexp
Name of the regular expression. It can be a variable name or literal.
Description If you want to execute a global match, or a case insensitive match, include the g
(for global) and i (for ignore case) flags in the regular expression. These can
be included separately or together. The following two examples below show
how to use these flags with match.
✰ Tip If you execute a match simply to find true or false, use String.search or the
regular expression test method.
String 16-93
Examples In the following example, match is used to find 'Chapter' followed by 1 or
more numeric characters followed by a decimal point and numeric character 0
or more times. The regular expression includes the i flag so that case will be
ignored.
str = "For more information, see Chapter 3.4.5.1";
re = /(chapter \d+(\.\d)*)/i;
found = str.match(re);
Console.Write(found);
replace
Used to find a match between a regular expression and a string, and to replace
the matched substring with a new substring.
Applies to String
Parameters regexp
The name of the regular expression. It can be a variable name or a literal.
newSubStr
The string to put in place of the string found with regexp. This string can
include the RegExp properties $1, ..., $9, lastMatch, lastParen,
leftContext, and rightContext.
Description This method does not change the String object it is called on; it simply
returns a new string.
Examples In the following example, the regular expression includes the global and ignore
case flags which permits replace to replace each occurrence of 'apples' in the
string with 'oranges.'
re = /apples/gi;
str = "Apples are round, and apples are juicy.";
newstr=str.replace(re, "oranges");
Console.Write(newstr)
search
Executes the search for a match between a regular expression and this String
object.
Applies to String
Syntax search(regexp)
Parameters regexp
Name of the regular expression. It can be a variable name or a literal.
String 16-95
Description If successful, search returns the index of the regular expression inside the
string. Otherwise, it returns -1.
When you want to know whether a pattern is found in a string use search
(similar to the regular expression test method); for more information (but
slower execution) use match (similar to the regular expression exec method).
Example The following example prints a message which depends on the success of the
test.
function testinput(re, str){
if (str.search(re) != -1)
midstring = " contains ";
else
midstring = " does not contain ";
Console.Write (str + midstring + re.source);
}
slice
Extracts a section of a string and returns a new string.
Applies to String
Syntax slice(beginslice,endSlice)
Parameters beginSlice
The zero-based index at which to begin extraction.
endSlice
(Optional) The zero-based index at which to end extraction. If omitted, slice
extracts to the end of the string.
Description slice extracts the text from one string and returns a new string. Changes to
the text in one string do not affect the other string.
slice extracts up to but not including endSlice. string.slice(1,4)
extracts the second character through the fourth character (characters indexed
1, 2, and 3).
As a negative index, endSlice indicates an offset from the end of the string.
string.slice(2,-1) extracts the third character through the second to
last character in the string.
This writes:
The morning is upon us
small
Causes a string to be displayed in a small font, as if it were in a SMALL tag.
Applies to String
Syntax small()
Parameters None
Description Use the small method with the Write method to format and display a string
in a document.
Example The following example uses string methods to change the size of a string:
var worldString="Hello, world"
Console.Write(worldString.small())
Console.Write("<P>" + worldString.big())
Console.Write("<P>" + worldString.fontsize(7))
The previous example produces the same output as the following HTML:
<SMALL>Hello, world</SMALL>
<P><BIG>Hello, world</BIG>
<P><FONTSIZE=7>Hello, world</FONTSIZE>
split
Splits a String object into an array of strings by separating the string into
substrings.
String 16-97
Applies to String
Parameters separator
(Optional) Specifies the character to use for separating the string. The
separator is treated as a string. If separator is omitted, the array returned
contains one element consisting of the entire string.
limit
(Optional) Integer specifying a limit on the number of splits to be found.
Examples The following example defines a function that splits a string into an array of
strings using the specified separator. After splitting the string, the function
displays messages indicating the original string (before the split), the separator
used, the number of elements in the array, and the individual array elements.
function splitString (stringToSplit,separator) {
arrayOfStrings = stringToSplit.split(separator)
Console.Write ('<P>The original string is: "' +
stringToSplit + '"')
Console.Write ('<BR>The separator is: "' + separator +
'"')
Console.Write ("<BR>The array has " +
arrayOfStrings.length + " elements: ")
for (var i=0; i < arrayOfStrings.length; i++) {
Console.Write (arrayOfStrings[i] + " / ")
}
}
var tempestString="Oh brave new world that has such people in
it."
splitString(tempestString,space)
splitString(tempestString)
splitString(monthString,comma)
String 16-99
In the following example, split looks for 0 or more spaces followed by a
semicolon followed by 0 or more spaces and, when found, removes the spaces
from the string. nameList is the array returned as a result of split.
names = "Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel
;Chris Hand ";
Console.Write (names , " ");
re = /\s*;\s*/;
nameList = names.split (re);
Console.Write(nameList);
This prints two lines; the first line prints the original string, and the second line
prints the resulting array.
Harry Trump ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand
Harry Trump,Fred Barney,Helen Rigby,Bill Abel,Chris Hand
In the following example, split looks for 0 or more spaces in a string and
returns the first 3 splits that it finds.
myVar = " Hello World. How are you doing? ";
splits = myVar.split(" ", 3);
Console.Write(splits)
strike
Causes a string to be displayed as struck-out text, as if it were in a STRIKE tag.
Applies to String
Syntax strike()
Parameters None
Description Use the strike method with the Write method to format and display a
string in a document.
Console.Write(worldString.blink())
Console.Write("<P>" + worldString.bold())
Console.Write("<P>" + worldString.italics())
Console.Write("<P>" + worldString.strike())
The previous example produces the same output as the following HTML:
<BLINK>Hello, world</BLINK>
<P><B>Hello, world</B>
<P><I>Hello, world</I>
<P><STRIKE>Hello, world</STRIKE>
sub
Causes a string to be displayed as a subscript, as if it were in a SUB tag.
Applies to String
Syntax sub()
Parameters None
Description Use the sub method with the Write method to format and display a string in
a document.
Example The following example uses the sub and sup methods to format a string:
var superText="superscript"
var subText="subscript"
The previous example produces the same output as the following HTML:
This is what a <SUP>superscript</SUP> looks like.
<P>This is what a <SUB>subscript</SUB> looks like.
String 16-101
See also String:sup
substr
Returns the characters in a string beginning at the specified location through
the specified number of characters.
Applies to String
Parameters start
Location at which to begin extracting characters.
length
(Optional) The number of characters to extract.
Description start is a character index. The index of the first character is 0, and the index
of the last character is 1 less than the length of the string. substr begins
extracting characters at start and collects length number of characters.
If start is positive and is the length of the string or longer, substr returns
no characters.
If start is negative, substr uses it as a character index from the end of the
string. If start is negative and abs(start) is larger than the length of the
string, substr uses 0 is the start index.
If length is 0 or negative, substr returns no characters. If length is
omitted, start extracts characters to the end of the string.
substring
Returns a subset of a String object.
Applies to String
Parameters indexA
An integer between 0 and 1 less than the length of the string.
indexB
An integer between 0 and 1 less than the length of the string.
Examples The following example uses substring to display characters from the string
"Netscape":
var anyString="Netscape"
//Displays "Net"
Console.Write(anyString.substring(0,3))
Console.Write(anyString.substring(3,0))
//Displays "cap"
Console.Write(anyString.substring(4,7))
Console.Write(anyString.substring(7,4))
//Displays "Netscap"
Console.Write(anyString.substring(0,7))
//Displays "Netscape"
String 16-103
Console.Write(anyString.substring(0,8))
Console.Write(anyString.substring(0,10))
The following example replaces a substring within a string. It will replace both
individual characters and substrings. The function call at the end of the
example changes the string "Brave New World" into "Brave New Web".
function replaceString(oldS,newS,fullS) {
// Replaces oldS with newS in the string fullS
for (var i=0; i<fullS.length; i++) {
if (fullS.substring(i,i+oldS.length) == oldS) {
fullS =
fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.l
ength)
}
}
return fullS
}
replaceString("World","Web","Brave New World")
sup
Causes a string to be displayed as a superscript, as if it were in a SUP tag.
Applies to String
Syntax sup()
Parameters None
Description Use the sup method with the Write method to format and display a string in
a document.
Examples The following example uses the sub and sup methods to format a string:
var superText="superscript"
var subText="subscript"
The previous example produces the same output as the following HTML:
This is what a <SUP>superscript</SUP> looks like.
<P>This is what a <SUB>subscript</SUB> looks like.
toLowerCase
Returns the calling string value converted to lowercase.
Applies to String
Syntax toLowerCase()
Parameters None
Description The toLowerCase method returns the value of the string converted to
lowercase. toLowerCase does not affect the value of the string itself.
toUpperCase
Returns the calling string value converted to uppercase.
Applies to String
Syntax toUpperCase()
Parameters None
Description The toUpperCase method returns the value of the string converted to
uppercase. toUpperCase does not affect the value of the string itself.
String 16-105
Regular Expression
Parameters pattern
The text of the regular expression
flags
(Optional) If specified, flags can have one of the following 3 values:
■ G – global match
■ i – ignore case
■ gi – both global match and ignore case
Notice that the parameters to the literal format do not use quotation marks to
indicate strings, while the parameters to the constructor function do use
quotation marks. So the following expressions create the same regular
expression:
/ab+c/i
new RegExp("ab+c", "i")
Table 16-20 provides a complete list and description of the special characters
that can be used in regular expressions.
Character Meaning
\ For characters that are usually treated literally, indicates that the next charac-
ter is special and not to be interpreted literally. For example, /b/ matches
the character 'b'. By placing a backslash in front of b, that is by using /\b/,
the character becomes special to mean match a word boundary
-or-
For characters that are usually treated specially, indicates that the next char-
acter is not special and should be interpreted literally. For example, * is a
special character that means 0 or more occurrences of the preceding charac-
ter should be matched; for example, /a*/ means match 0 or more a's. To
match * literally, precede the it with a backslash; for example, /a\*/
matches 'a*'.
^ Matches beginning of input or line. For example, /^A/ does not match the
'A' in "an A," but does match it in "An A."
$ Matches end of input or line.For example, /t$/ does not match the 't' in
"eater", but does match it in "eat"
. (The decimal point) matches any single character except the newline charac-
ter. For example, /.n/ matches 'an' and 'on' in "nay, an apple is on the
tree", but not 'nay'.
Character Meaning
(x) Matches 'x' and remembers the match. For example, /(foo)/ matches
and remembers 'foo' in "foo bar." The matched substring can be recalled
from the resulting array's elements [1], ..., [n], or from the predefined
RegExp object's properties $1, ..., $9.
{n,m} Where n and m are positive integers. Matches at least n and at most m occur-
rences of the preceding character. For example, /a{1,3}/ matches
nothing in "cndy", the 'a' in "candy," the first two a's in "caandy," and the first
three a's in "caaaaaaandy" Notice that when matching "caaaaaaandy", the
match is "aaa", even though the original string had more a's in it.
[xyz] A character set. Matches any one of the enclosed characters. You can specify
a range of characters by using a hyphen. For example, [abcd] is the same
as [a-c]. They match the 'b' in "brisket" and the 'c' in "ache".
[^xyz] A negated or complemented character set. That is, it matches anything that is
not enclosed in the brackets. You can specify a range of characters by using a
hyphen. For example, [^abc] is the same as [^a-c]. They initially match
'r' in "brisket" and 'h' in "chop."
Character Meaning
\cX Where X is a control character. Matches a control character in a string. For
example, /\cM/ matches control-M in a string.
\f Matches a form-feed.
\n Matches a linefeed.
\s Matches a single white space character, including space, tab, form feed, line
feed. Equivalent to [ \f\n\r\t\v]. For example, /\s\w*/ matches '
bar' in "foo bar."
\t Matches a tab.
Note: If the number of left parentheses is less than the number specified in
\n, the \n is taken as an octal escape as described in the next row.
Examples The following script uses the replace method to switch the words in the
string. For the replacement text, the script uses the values of the $1 and $2
properties of the global RegExp object. Note that the RegExp object name is
not be prepended to the $ properties when they are passed as the second
argument to the replace method.
re = /(\w+)\s(\w+)/;
str = "John Smith";
newstr=str.replace(re, "$2, $1");
(newstr)
$_ See input.
$* See multiline.
$+ See lastParen.
global Whether to test the regular expression against all possible matches in a
string, or only against the first.
$1, ..., $9
Properties that contain parenthesized substring matches, if any.
Property of RegEx
Example The following script uses the replace method to switch the words in the
string. For the replacement text, the script uses the values of the $1 and $2
properties of the global RegExp object. Note that the RegExp object name is
not be prepended to the $ properties when they are passed as the second
argument to the replace method.
re = /(\w+)\s(\w+)/;
str = "John Smith";
newstr=str.replace(re, "$2, $1");
Console.Write(newstr)
$*
See multiline.
$&
See lastMatch.
$+
See lastParen.
$'
See leftContext.
$'
See rightContext.
global
Whether the "g" flag is used with the regular expression. The global
property is read-only.
Property of RegEx
The value of global is true if the "g" flag is used; otherwise, it is false.
The "g" flag indicates that the regular expression should be tested against all
possible matches in a string.
You cannot change this property directly. However, calling the compile
method changes the value of this property.
ignoreCase
Whether or not the "i" flag is used with the regular expression. The
ignorecase property is read-only.
input
The string against which a regular expression is matched. $_ is another name
for the same property.
Property of RegEx
When an event handler is called for a TEXT form element, input is set to the
value of the contained text.
When an event handler is called for a TEXTAREA form element, input is set
to the value of the contained text. Note that multiline is also set to true
so that the match can be executed over the multiple lines of text.
When an event handler is called for a SELECT form element, input is set to
the value of the selected text.
When an event handler is called for a Link object, input is set to the value of
the text between <A HREF=...> and </A>.
The value of the input property is cleared after the event handler completes.
Property of RegEx
This property is set only if the regular expression used the "g" flag to indicate
a global search. The following rules apply:
■ If lastIndex is greater than the length of the string, regexp.test and
regexp.exec fail, and lastIndex is set to 0.
■ If lastIndex is equal to the length of the string and if the regular
expression matches the empty string, then the regular expression matches
input starting at lastIndex.
■ If lastIndex is equal to the length of the string and if the regular
expression does not match the empty string, then the regular expression
mismatches input, and lastIndex is reset to 0.
■ Otherwise, lastIndex is set to the next position following the most
recent match.
lastMatch
The last matched characters. $& is another name for the same property.
Property of RegEx
Property of RegEx
leftContext
The substring preceding the most recent match. $' is another name for the
same property.
Property of RegEx
multiline
Reflects whether or not to search in strings across multiple lines. $* is another
name for the same property.
Property of RegEx
rightContext
The substring following the most recent match. $' is another name for the
same property.
source
A read-only property that contains the text of the pattern, excluding the
forward slashes and "g" or "i" flags.
Property of RegEx
compile
Compiles a regular expression object during execution of a script.
Parameters regexp
The name of he regular expression. It can be a variable name or a literal.
pattern
A string containing the text of the regular expression.
flags
(Optional) If specified, flags can have one of the following 3 values:
■ g – global match
■ i – ignore case
■ gi – both global match and ignore case
Description Use the compile method to compile a regular expression created with the
RegExp constructor function. This forces compilation of the regular
expression once only which means the regular expression isn't compiled each
time it is encountered. Use the compile method when you know the regular
expression will remain constant (after getting its pattern) and will be used
repeatedly throughout the script.
Calling this method changes the value of the regular expression's source,
global, and ignoreCase properties.
exec
Executes the search for a match in a specified string. Returns a result array.
Syntax regexp.exec(str)
regexp(str)
Parameters regexp
The name of the regular expression. It can be a variable name or a literal.
str
(Optional) The string against which to match the regular expression. If
omitted, the value of RegExp.input is used.
Description As shown in the syntax description, a regular expression's exec method call be
called either directly, (with regexp.exec(str)) or indirectly (with
regexp(str)).
If you are executing a match simply to find true or false, use the test
method or the String search method.
If the match succeeds, the exec method returns an array and updates
properties of the regular expression object and the predefined regular
expression object, RegExp. If the match fails, the exec method returns null.
Consider the following example:
//Match one d followed by one or more b's followed by one d
//Remember matched b's and the following d
//Ignore case
myRe=/d(b+)(d)/ig;
myArray = myRe.exec("cdbBdbsbz");
Table 16-23 shows the results for this script:
Examples In the following example, the user enters a name and the script executes a
match against the input. It then cycles through the array to see if other names
match the user's name.
This script assumes that first names of registered party attendees are preloaded
into the array A, perhaps by gathering them from a party database.
A = ["Frank", "Emily", "Jane", "Harry", "Nick", "Beth", "Rick",
"Terrence", "Carol", "Ann", "Terry", "Frank",
"Alice", "Rick",
"Bill", "Tom", "Fiona", "Jane", "William", "Joan",
"Beth"]
function lookup() {
firstName = /\w+/i();
if (!firstName)
Alert (RegExp.input + " isn't a name!");
else {
count = 0;
for (i=0; i<A.length; i++)
if (firstName[0].toLowerCase() ==
A[i].toLowerCase()) count++;
if (count ==1)
midstring = " other has ";
else
midstring = " others have ";
window.alert ("Thanks, " + count + midstring + "the
same name!")
}
}
Enter your first name and then press Enter.
Syntax regexp.test(str)
Parameters regexp
The name of the regular expression. It can be a variable name or a literal.
str
(Optional) The string against which to match the regular expression. If
omitted, the value of RegExp.input is used.
Description When you want to know whether a pattern is found in a string use the test
method (similar to the String.search method); for more information
(but slower execution) use the exec method (similar to the String.match
method).
Example The following example prints a message which depends on the success of the
test:
function testinput(re, str){
if (re.test(str))
midstring = " contains ";
else
midstring = " does not contain ";
Console.Write (str + midstring + re.source);
}
/>=, 4-5
Symbols
<, 14-8
, 4-5 <=, 14-8
!, 14-9 -=, 4-4, 14-3
-, 4-4, 14-2 =, 4-4, 14-3
--, 4-4, 14-2 ==, 4-5, 14-8
!=, 4-5, 14-8 >, 14-8
$&, 16-113 >=, 14-8
$', 16-113 >>=, 14-4
$*, 16-113 >>>=, 14-4
$+, 16-113 ?:, 14-11
$_, 16-113 ^=, 14-3
$1, ..., $9, 16-112 |=, 14-4
%, 4-4, 14-3 ||, 14-9
%=, 4-4, 14-3
&&, 4-5, 14-9
&=, 14-3 A
*, 4-4, 14-3 abs, 16-49
*=, 4-4, 14-3 accessing
+, 4-4, 14-2, 14-10 cookies, 8-22
++, 4-4, 14-2 drop-down selections, 5-3
+=, 4-4, 14-3, 14-10 selected values, 7-7
,, 14-12 URL parameters, 8-23
., 14-11 acos, 16-50
. separator, 4-3 Activate (Method), 10-2
.bmp, 1-6 Active (Property), 11-2
/, 4-4 – 4-5, 14-3 active document level, 13-4
/=, 4-4, 14-3 AdaptiveState (Property), 11-3
/>, 4-5 Add (Method), 10-3
Index 1
AddAll (Method), 10-6 asin, 16-51
AddComputed (Method), 10-7 assigning
AddComputedItem (Method), 10-8 chart types, 4-6
AddExportSection (Method), 10-9 values, 4-15
AddFilterValue (Method), 10-12 assignment operators
adding definition, 4-4
concatenating versus, 4-10 description, 14-3
in JavaScript, 4-10 shorthand, 14-4
items to the request line, 12-8 versus comparison operators, 4-5, 8-27
joins, 12-7 associating scripts
objects to tab order, 1-15 with check boxes, 3-10
topics to a data model section, 12-6 with command buttons, 3-5
addition operator, 4-4, 14-2 with list boxes, 3-14
AddTotals (Method), 10-14 with radio buttons, 3-7
AggregateLimits (Collection), 9-2 asterisk, 4-4, 14-3
Alert (Method), 10-15 atan, 16-51
Alignment (Property), 11-4 atan2, 16-52
alignment properties, 1-8 – 1-9 AuditSQL (Method), 10-16
AllowNonJoinedQueries (Property), 11-5 AutoAlias (Property), 11-7
ampersand, 4-5 AutoCommit (Property), 11-8
anchor, 16-81 AutoFrequency (Property), 11-9
and operator, 4-5 AutoInterval (Property), 11-10
API (Property), 11-6 AutoJoin (Property), 11-11
AppendQueries (Collection), 9-3 automation controller, OLE, 8-25
Application (Object), 9-4 AutoProcess (Property), 11-12
application level, 13-3 AutoScale (Property), 11-13
applications, components of scripted, 8-2 AutoSizeHeight (Method), 10-18
AreaChart (Object), 9-5 AutoSizeWidth (Method), 10-19
arguments, 16-36 available values
drop-down item, 7-7 filling a drop down box with, 7-7
list box item, 7-8 filling a list box with, 7-4
arithmetic operators, 4-4, 14-2 AvailableValues (Property), 11-14
arity, 16-38 AxisItems (Collection), 9-6
Array object AxisLabels (Collection), 9-7
JavaScript, 16-2 AxisPlotValues (Property), 11-15
methods, 16-7 AxisType (Property), 11-16
properties, 16-5
2 Index
B C
background and border properties, 1-10 Call (Method), 10-20
BarChart (Object), 9-8 caller, 16-39
BarLineChart (Object), 9-9 calling functions, 8-4
big, 16-82 case-sensitive code, 8-27
bitwise operators Catalog pane
definition, 14-4 in Design and Run modes, 1-4
logical, 14-6 CategoryItems (Collection), 9-10
shift, 14-7 ceil, 16-53
blink, 16-83 changing
BMP files, 1-6 control object titles, 3-3
bold, 16-83 tab order sequence, 1-15
Boolean object characteristics, variable, 5-7
JavaScript, 16-19 characters, special, used in Regular Expressions,
methods, 16-21 16-107
properties, 16-20 charAt, 16-84
Boolean operators, 4-5 charCodeAt, 16-85
border and background properties, 1-9 chart facts
boxes, 1-6, 7-1 controlling with if...else, 6-12
break statements controlling with switch, 6-13
definition, 15-3 setting, 5-15
using, 8-16 Chart section, 13-7
BrioQuery ChartSection (Object), 9-12
methods, 10-1 ChartThisPivot (Method), 10-21
objects, 9-1 ChartType (Property), 11-17
properties, 11-1 check boxes
scripting applications in, 8-2 changing states with, 6-3
BrioQuery object model See object model definition, 1-6
browser cookies, using to pass parameters to ODS using, 3-10
documents, 8-21 Checked (Property), 11-18
browser, Object, 2-8 checking errors, Console window and, 2-12
buttons Close (Method), 10-22
command, 1-6, 3-5 Clusterby (Property), 11-19
radio, 1-6, 3-7 code entry, 8-33
bypassing code structure, in JavaScript, 4-2
errors, 8-33 code, case-sensitive, 8-27
user IDs and passwords, 8-21 collection, definition, 2-3
Color (Property), 11-20
Column (Object), 9-14
Index 3
Columns (Collection), 9-15 controls
ColumnType (Property), 11-21 enabling and disabling, 12-3
command buttons scripting EIS, 3-1
definition, 1-6 Controls (Collection), 9-20
using, 3-5 ControlsCheckBox (Object), 9-21
commands, EIS section, 1-19 ControlsCommandButton (Object), 9-22
comment statements, 15-5 ControlsDropDown (Object), 9-23
comparison operators, 4-5 ControlsListBox (Object), 9-24
list of, 14-8 ControlsRadioButton (Object), 9-25
versus assignment operators, 4-5 ControlsTextBox (Object), 9-26
compile, 16-118 converting data types, 4-16
components, of scripted applications, 8-2 Cookies (Collection), 9-27
concat, 16-7, 16-85 cookies, browser, using to pass parameters to ODS
concatenate operator, 4-4 documents, 8-21
concatenation, 4-10 Copy (Method), 10-24
conditional statements, 8-7 core objects
conditional tests, 8-28 Array, 16-2
Connect (Method), 10-23 Boolean, 16-19
Connected (Property), 11-22 Date, 16-22
Connection (Object), 9-16 Function, 16-35
connection files, scripting, 12-5 Math, 16-44
Console (Object), 9-18 Number, 16-62
Console window, using to check errors, 2-12 Object, 16-69
constant, definition, 2-3 Regular Expression, 16-106
constructor, 16-69 String, 16-78
continue statements CornerLabels (Object), 9-29
definition, 15-6 cos, 16-53
using, 8-15 Count (Property), 11-23
Control (Object), 9-19 CreateConnection (Method), 10-25
control events, 2-6 CreateDateGroup (Method), 10-26
control objects CreateLimit (Method), 10-27
changing titles, 3-3 creating
events associated with, 2-6 EIS sections, 1-3, 3-2
list of, 1-6 OCEs (connection files), 12-5
scripting, 3-2 Results limits, 7-12
control structures, 6-2 – 6-4, 6-8 variable limits, 12-9
controller, OLE automation, 8-25 CurrentDir (Property), 11-24
controlling graphics and controls visibility, example, CustomSQL (Property), 11-25
12-4 CustomSQLFrom (Method), 10-29
4 Index
CustomSQLWhere (Method), 10-30 delete statements, 15-8
CustomValues (Property), 11-26 deleting
EIS sections, 1-4
objects, 1-7
D Description (Property), 11-42
DashStyle (Property), 11-27 Description pane, 2-9
data models, downloading, 12-6 design guides, 1-17
Database (Property), 11-28 Design Guides command, 1-20
DatabaseList (Property), 11-30 Design mode, 1-4
DatabaseName (Property), 11-31 Design/Run Mode command, 1-20
DataFunction (Property), 11-32 designing scripts, 8-31
DataLabels (Object), 9-30 disabling controls, 12-3
DataModelSection (Object), 9-31 Disconnect (Method), 10-31
DataType (Property), 11-34 Display (Property), 11-43
Date object displaying
JavaScript, 16-22 connection login boxes, 12-5
methods, 16-23 rulers, 1-18
properties, 16-23 Table catalog, 12-6
DBLibAllowChangeDatabase (Property), 11-35 values in text boxes, 12-2
DBLibApiSeverity (Property), 11-36 DisplayName (Property), 11-44
DBLibDatabaseCancel (Property), 11-37 division operator, 4-4, 14-3
DBLibPacketSize (Property), 11-38 DMCatalog (Object), 9-36
DBLibServerSeverity (Property), 11-39 DMCatalogItem (Object), 9-37
DBLibUseQuotedIdentifiers (Property), 11-40 DMCatalogItems (Collection), 9-38
DBLibUseSQLTable (Property), 11-41 do...while statements
declaring variables definition, 15-9
dynamically, 4-15 using, 8-12
global, 4-14 Document (Object), 9-39
local, 4-14 document level
decrement operator, 4-4, 14-2 active, 13-4
default events, 2-6
mode, 1-5 Documents (Collection), 9-40
tab order, 1-15 documents, ODS, passing parameters to, 8-21
DefinedJoinPath (Object), 9-35 DoEvents (Method), 10-32
DefinedJoinPaths (Collection), 9-33 downloading data models, 12-6
defining functions, 8-3, 8-5 DrillInto (Method), 10-33
delete operator, 14-12
Index 5
drop-down boxes EnableTransActionMode (Property), 11-48
accessing selections, 5-3 enabling controls, 12-3
definition, 1-6 entering code, 8-33
filling with available values, 7-7 equal sign assignment operator, 4-4
filling with multiple values, 7-3 equal test operator, 4-5
in the Limits EIS section, 5-9 errors
typical use, 5-2 bypassing, 8-33
using for loops, 7-2 checking using the Console window, 2-12
drop-down item argument, 7-7 eval, 16-70
drop-down selections, modifying limits with, evaluations, short-circuit, 14-10
example, 5-9 events, 1-20, 2-4
Duplicate (Method), 10-34 example scripts, 12-4
dynamically declaring variables, 4-15 exec, 16-119
ExecuteBScript (Method), 10-35
Execution window, using to test scripts, 2-11
E Executive Information Systems, 1-1
E, 16-45 exercises
Effect (Property), 11-45 Adding Comparison and Assignment Buttons, 4-6
EIS controls, scripting, 3-1 Associating a Script with a List Box, 3-15
EIS section Concatenating Values, 4-11
control objects, 1-6 Declaring a Variable, 5-8
creating, 1-3 Summing Values, 4-12
default mode, 1-5 Using a for Loop to Fill a List Box with Limit
definition, 1-2 Values, 7-5
enabling and disabling controls, 12-3 Using a switch Statement to Change Chart Types,
events, 2-5 6-9
graphic objects, 1-6 Using an if...else Statement to Change Chart
Types, 6-5
layout tools in, 1-17
Using JavaScript to Clear and Assign New Results
menu commands, 1-19 – 1-20
Limits in Drop-Down Boxes, 7-13
object model map, 13-6
Using Loops to Access List Box Selections, 7-10
properties, 1-7
Using Operators as Characters, 4-8
renaming, 1-4
Using the Assignment Operator, 4-7
toolbar, 1-18
Using the Comparison Operator, 4-7
EISSection (Object), 9-41
exp, 16-54
elements, properties and, 16-3
Export (Method), 10-36
embedding objects, 1-7
exporting scripts, 8-25
EnableAsyncProcess (Property), 11-46
ExportWithoutQuotes (Property), 11-49
Enabled (Property), 11-47
6 Index
F G
Facts (Object), 9-42 general scripting reference, 8-1
Filename (Property), 11-50 GetCell (Method), 10-39
files getDate, 16-24
BMP, 1-6 getDay, 16-24
text, exporting scripts to, 8-25 getFullYear, 16-28
Fill (Object), 9-43 getHours, 16-25
filling boxes with values, 7-3 – 7-4, 7-7 getMinutes, 16-25
FillUnderRibbon (Property), 11-51 getMonth, 16-26
fixed, 16-86 getSeconds, 16-26
floor, 16-55 getTime, 16-27
Focus (Property), 11-52 getTimezoneOffset, 16-27
focus, object determining, 1-15 getting
FocusSelection (Method), 10-38 help with problem scripts, 8-34
Font (Object), 9-44 properties of object, example, 12-3
font properties, 1-11 global property, 16-113
fontcolor, 16-87 global variables, declaring, 4-14
fontsize, 16-88 graphic objects
for loops, using, 7-2 events associated with, 2-5
for statements list of, 1-6
definition, 15-10 graphics and controls, controlling the visibility of,
using, 8-12 12-4
for...in statements graphics, inserting, 1-20
definition, 15-11 greater than, 4-5
using, 8-17 greater than or equal to, 4-5
Form (Collection), 9-45 Grid command, 1-20
forward slash, 4-4, 14-3 grids, 1-17
fromCharCode, 16-89 Group (Property), 11-54
FullName (Property), 11-53 guides, design, 1-17
Function object
JavaScript, 16-35
methods, 16-41
H
properties, 16-36 headers, page, turning off, 12-10
function statements, 15-12 Height (Property), 11-55
functions help, online, 2-9
calling, 8-4 Hide (Method), 10-40
defining, 8-3 HideSelection (Method), 10-41
hiding toolbars, 5-17
Index 7
hierarchy, object model, 13-2 italics, 16-91
Home Dialog command, 1-20 Item (Method), 10-45
horizontal lines, 1-6 item argument and method, 7-7
Hostname (Property), 11-56
HTMLExportBreakCount (Property), 11-57
J
JavaScript
I basic syntax, 4-2
IDs, user, bypassing, 8-21 basics, 5-1
if statements, 6-2 case-sensitivity, 4-2, 8-27
if statements, inline, 8-9 code structure, 4-2
if...else statements concatenating versus adding, 4-10
control structure syntax, 6-2 control structures, 6-1 – 6-2
controlling chart facts with, 6-12 core objects, 16-1
definition, 15-13 entering syntax, 8-33
switch versus, 6-8 examples, 12-1
using, 6-4, 8-8 improving performance, 8-30
Ignore (Property), 11-58 keywords, 15-1
ignoreCase, 16-113 manipulating objects with, 8-17
IgnoreNulls (Property), 11-59 objects. See core objects.
II, 4-5 OLE automation controller within, 8-25
ImportDataFile (Method), 10-42 operators, 4-4, 14-1
ImportSQLFile (Method), 10-43 arithmetic, 14-2
IncludeNulls (Property), 11-60 logical, 14-9
including special, 14-11
limit values in URLs submitted to ODS, 12-10 string, 14-10
operators in strings, 4-8 reserved words, 4-17
increment operator, 4-4, 14-2 sample, 2-9
index, 16-5 statement elements, 4-3
Index (Property), 11-61 statements, 15-1 – 15-2
indexOf, 16-89 syntax, 4-1
inline if statements, 8-9 troubleshooting, 8-26
input, 16-5, 16-114 join, 16-8
Insert Control command, 1-20 Join (Object), 9-47
Insert Graphic command, 1-20 Joins (Collection), 9-48
inserting JoinsOptions (Collection), 9-49
EIS objects, 1-7 -jscriptcmd, 8-2
EIS sections, 1-3
IntervalFrequency (Property), 11-62
8 Index
list box
L
definition, 1-6
labeled statements, 8-14 filling with available values, 7-4
definition, 15-14 item argument, 7-8
using, 8-14 using, 3-14
LabelFrequency (Property), 11-63 LN10, 16-45
labels, text, 1-6 LN2, 16-46
LabelsAxis (Object), 9-50 LoadFromFile (Method), 10-47
LabelText (Property), 11-64 LoadSharedLibrary (Method), 10-48
LabelValues (Object), 9-51 local variables, declaring, 4-14
lastIndex, 16-115 LocalJoins (Collection), 9-63
lastIndexOf, 16-91 LocalJoins (Scripting), 9-63
lastMatch, 16-115 LocalResults (Collection), 9-64
lastParen, 16-116 LocalResults (Scripting), 9-64, 9-66
LastPrinted (Property), 11-65 LocalResultsTopicItems (Collection), 9-66
LastSaved (Property), 11-66 log, 16-55
LastSQLStatement (Property), 11-67 LOG10E, 16-46
layout tools, 1-17 LOG2E, 16-47
LeftAxis (Object), 9-54 logical operators, 4-5, 14-9
leftContext, 16-116 logical operators, bitwise, 14-6
legal names, for variables, 4-2 LogicalOperator (Property), 11-69
Legend (Collection), 9-53 loop statements, 8-11
Legend (Object), 9-52
length, 16-6, 16-79
less than or equal to, 4-5 M
Limit (Object), 9-55 manipulating objects with JavaScript, 8-17
limits map, object model, 13-1
modifying, 5-9 MarkerBorderColor (Property), 11-70
Query, modifying, 5-14 MarkerFillColor (Property), 11-71
Results, creating, 7-12 MarkerSize (Property), 11-72
Results, modifying, 5-10 MarkerStyle (Property), 11-73
Limits (Collection), 9-57 match, 16-93
LimitValues (Collection), 9-59 Math object
LimitValueType (Property), 11-68 JavaScript, 16-44
Line (Object), 9-62 methods, 16-49
LineChart (Object), 9-61 properties, 16-45
lines, 1-6 max, 16-56
link, 16-92 MAX_VALUE, 16-63
menu commands, EIS section, 1-19
Index 9
MetadataPassword (Property), 11-74
N
MetadataUser (Property), 11-75
MetaFileChoice (Property), 11-76 Name (Property), 11-78
method, valueOf, object types for, 16-76 naming
methods variables, 4-2
Array object, 16-7 naming EIS sections, 1-4
Boolean object, 16-21 NaN, 16-64
BrioQuery, 10-1 Navigation toolbar, 1-19
Date object, 16-23 navigation, object model, 13-1
definition, 2-3 Negate (Property), 11-79
Function object, 16-41 NEGATIVE_INFINITY, 16-65
Item object, 7-7 new, 14-13
Math object, 16-49 New (Method), 10-50
Number object, 16-67 not equal test operator, 4-5
Object object, 16-70 Number object
OpenURL(), 8-19 JavaScript, 16-62
Regular Expression object, 16-118 methods, 16-67
Shell(), 8-19 properties, 16-63
String object, 16-80 NumberFormat (Property), 11-80
Microsoft automation interfaces, 8-24
min, 16-56
MIN_VALUE, 16-64
O
minum sign, 14-2 Object browser, 2-8
minus sign, 4-4 object level events, 2-4 – 2-5
models, data, downloading, 12-6 object model
modes, switching between Design and Run, 1-4 description pane, 2-9
ModifyComputed (Method), 10-49 hierarchy, 13-2
modifying map, 13-1
limits, 5-9 Microsoft automation interfaces, 8-24
Query limits, 5-14 navigating, 13-1
Results limits, 5-10 online help, 2-9
modulus operator, 4-4, 14-3 terminology, 2-2 – 2-3
multiline, 16-116 Object object
multiple values, filling boxes with, 7-3 JavaScript, 16-69
multiplication operator, 4-4, 14-3 method, 16-70
MultiSelect(Property), 11-77 properties, 16-69
10 Index
object properties OnClick (Method), 10-54
list of, 1-13 OnDeactivate (Method), 10-55
setting, 1-12 OnDoubleClick (Method), 10-56
setting with JavaScript, 12-3 OnEnter, 10-57
object types, for valueOf method, 16-76 OnExit, 10-58
objects OnInterruptQueryProcess(Method), 10-59
associated events online help, 2-9
control, 2-6 OnPostProcess (Method), 10-59
graphic, 2-5 OnPreProcess (Method), 10-60
BrioQuery, 9-1 OnShutdown (Method), 10-61
control, 1-6 OnStartup (Method), 10-62
core, 16-1 Open (Method), 10-63
definition, 2-3 OpenURL (Method), 10-64
deleting, 1-7 OpenURL() Method, 8-19
embedding, 1-7 Operator (Property), 11-84
Function, 16-35 operators
graphic, 1-6 assignment, 14-3
in Catalog pane, 1-4 assignment vs comparison, 4-5
inserting, 1-7 bitwise, 14-4 – 14-7
manipulating with JavaScript, 8-17 comparison, 14-8
scripting control, 3-2 conditional, 14-11
section, 1-5 JavaScript, 4-4
using variables for, 5-13 logical, 14-9
ODBCDatabasePrompt (Property), 11-81 short-circuit evaluation, 14-10
ODBCEnableLargeBufferMode (Property), 11-82 shorthand assignment, 14-4
ODS documents, passing parameters to, 8-21 special, 14-11
ODSUsername (Property), 11-83 string, 4-8, 14-10
OLAPConnection (Object), 9-67 or operator, 4-5
OLAPLabel (Object), 9-68 order, default tab, 1-15
OLAPMeasure (Object), 9-71 ovals, 1-6
OLAPMeasures (Collection), 9-72 Owner (Property), 11-86
OLAPQuery section, object model map, 13-9
OLAPQuerySection (Object), 9-73
OLAPSlicer (Object), 9-74 P
OLAPSlicers (Collection), 9-75 page headers, turning off for first page in reports,
OLE automation controller, 8-25 12-10
OLPLabels (Collection), 9-69 parameters, passing to ODS documents, 8-21
OnActivate (Method), 10-51 parse, 16-28
OnChange (Method), 10-53 Password (Property), 11-87
Index 11
passwords, bypassing, 8-21 properties (continued)
Path (Property), 11-88 BrioQuery, 11-1
PathSeparator (Property), 11-89 Date object, 16-23
percent sign, 4-4, 14-3 definition, 2-3
periods, as separators, 4-3 font, 1-11
PhysicalName (Property), 11-90 Function object, 16-36
PI, 16-47 Math object, 16-45
picture properties, 1-14 Number object, 16-63
pictures, 1-6 object, 1-12
PieChart (Object), 9-76 Object object, 16-69
pipe, 4-5 picture, 1-14
Pivot section, object model map, 13-8 Regular Expression object, 16-111
PivotFact (Object), 9-77 retrieving object, 12-3
PivotFacts (Collection), 9-78 setting EIS, 1-7
PivotLabel (Object), 9-79 setting object, 12-3
PivotLabels (Collection), 9-80 String object, 16-79
PivotLabelTotals (Object), 9-81 tab order, 1-15
PivotSection (Object), 9-82 Properties command, 1-20
PivotThisChart (Method), 10-65 prototype
PivotTo (Method), 10-66 Array property, 16-6
plus sign, 4-4 Boolean property, 16-20
pop, 16-9 Date property, 16-23
POSITIVE_INFINITY, 16-65 Function property, 16-39
pow, 16-57 Number property, 16-66
PrintOut (Method), 10-67 Object property, 16-70
Process (Method), 10-68 String property, 16-79
ProcessEventOrigin (Property), 11-91 push, 16-9
processing queries
using “don’t prompt for database logon”, 12-11
using “prompt for database logon”, 12-12 Q
ProcessStoredProc (Method), 10-69 Query limits, modifying, 5-14
ProcessToTable (Method), 10-70 Query section, object model map, 13-5
Prompt (Property), 11-92 QueryInProcess (Property), 11-93
Prompt To Save dialog box, turning off, 12-10 QuerySection (Object), 9-83
properties QuerySize (Property), 11-94
alignment, 1-8 – 1-9 Quit (Method), 10-71
Array object, 16-5 quotation marks, strings and, 4-2
background and border, 1-10
Boolean object, 16-20
12 Index
ResizeToBestFit (Method), 10-81
R
Results (Collection), 9-89
radio buttons Results (Object), 9-88
definition, 1-6 Results limits
using, 3-7 creating, 7-12
random, 16-58 modifying, 5-10
Recalculate (Method), 10-72 Results section, object model map, 13-8
recalculating results, 8-30 results, recalculating, 8-30
RecentFiles (Collection), 9-85 retrieving object properties, 12-3
rectangles, 1-6 return statements, 15-15
references reverse, 16-10
general scripting, 8-1 RightAxis (Object), 9-90
syntax, 8-30 rightContext, 16-116
Refresh (Method), 10-73 Rotation (Property), 11-98
RefreshAvailableValues (Method), 10-74 round, 16-58
RefreshData (Property), 11-95 round rectangles, 1-6
RefreshDataNow (Method), 10-75 RowCount (Property), 11-99
Regular Expression object RowLimit (Property), 11-100
Javascript, 16-106 RowLimitActive (Property), 11-101
methods, 16-118 RowNumber (Property), 11-102
properties, 16-111 rulers, 1-18
regular expressions, special characters used in, Rulers command, 1-20
16-107 Run mode, switching to, 1-4
Remove (Method), 10-76
Remove Selected Items command, 1-20
RemoveAll (Method), 10-78 S
RemoveExportSection (Method), 10-79
sample scripts
removing objects from tab order, 1-15
Add a Computed Column to a Query Request
renaming, EIS sections, 1-4 line, 12-8
replace, 16-94 Add Items to The Request line, 12-8
Report section Add Joins, 12-7
object model map, 13-8 Add Topics to a Data Model Section, 12-6
toolbar, 1-18 Create an OCE, 12-5
reports, turning off page headers for first page in, Create and Set Variable Limits, 12-9
12-10
Display a Connection Login Box, 12-5
Request (Object), 9-86
Display a Table Catalog, 12-6
Requests (Collection), 9-87
Include Limit Values in the URL submitted to the
reserved words, 4-17 ODS, 12-10
ResetCustomerSQL (Method), 10-80 ODS User Name as a Limit, using, 12-9
ResetPrintProperties (Property), 11-97
Index 13
sample scripts (continued) sections
Process multiple queries against different Chart, 13-7
databases in the ODS using the, 12-11 EIS, 1-2, 13-6
Prompt for Database logon, 12-12 Query, 13-5
Setup Topic Objexts Variables, 12-7 Sections (Collection), 9-92
Turn off page headers for the first page in the Select (Method), 10-84
Reporter, 12-10 selected values, accessing, 7-7
Using a BrioQuery 5.5 Limit Dialog Box SelectedIndex (Property), 11-109
andStoring Selected Value in Text Box, 12-9
SelectedList (Object), 9-93
Save (Method), 10-82
selections
SaveAs (Method), 10-83
accessing with drop-down boxes, 5-3
SaveResults (Property), 11-103
using variables for, 5-7
SaveWithoutUsername (Property), 11-104
SendSQL (Method), 10-85
ScaleMax (Property), 11-105
separators, statement, 4-3
ScaleMin (Property), 11-106
Session (Object), 9-94
script commands, launching, 8-2
setDate, 16-29
Script Editor
setHours, 16-30
Description pane, 8-30
setMinutes, 16-30
using, 2-7
setMonth, 16-30
script results, 16-120
SetODSPassword (Method), 10-86
scripted applications, components of, 8-2
SetPassword (Method), 10-87
scripting
setSeconds, 16-31
applications, 8-2
SetStoredProcParam (Method), 10-88
control objects, 3-2
setTime, 16-31
EIS controls, 3-1
setting
reference, 8-1
chart facts, 5-15
Scripting pane, 2-9
EIS properties, 1-7
Scripts command, 1-20
object properties, 12-3
scripts, exporting to text files, 8-25
topic object variables, 12-6
scripts, testing, Execution window and, 2-11
setYear, 16-32
scripts, troubleshooting, 8-26
Shape (Object), 9-95
Scrollable (Property), 11-107
Shapes (Collection), 9-96
ScrollbarsAlwaysShown (Property), 11-108
SharedLibrary (Object), 9-97
search, 16-95
Shell (Method), 10-89
Section (Object), 9-91
Shell() Method, 8-19
section level events, 2-6
shift, 16-11
section objects, 1-5
14 Index
shift operators, bitwise, 14-7 SortByFact (Method), 10-90
ShiftPoints (Property), 11-110 SortByLabel (Method), 10-91
short-circuit evaluation operator, 14-10 SortFactName (Property), 11-142
shorthand assignment operators , 14-4 SortFunction (Property), 11-143
Show3DObjects (Property), 11-111 SortItems (Collection), 9-98
ShowAdvanced (Property), 11-112 SortNow (Method), 10-92
ShowAllPositive (Property), 11-113 SortOrder (Property), 11-144
ShowBackPlane (Property), 11-114 source, 16-117
ShowBarValues (Property), 11-115 space-saving variables, 8-26
ShowBorder (Property), 11-116 special characters, in regular expressions , 16-107
ShowBrioRepositoryTables (Property), 11-117 special operators, 14-11
ShowCatalog (Property), 11-118 SpecificMetadataLogin (Property), 11-145
ShowFullNames (Property), 11-119 splice, 16-13
ShowHorizontalPlane (Property), 11-120 split, 16-97
ShowIconJoins(Property), 11-121 SQLName (Property), 11-146
ShowIntervalTickmarks (Property), 11-122 SQLNetRetainDateFormats (Property), 11-147
ShowIntervalValues (Property), 11-123 sqrt, 16-60
ShowLabel (Property), 11-124 SQRT1_2, 16-47
ShowLabels (Property), 11-125 SQRT2, 16-48
ShowLegend (Property), 11-126 StackClusterType (Property), 11-148
ShowLocalResults (Property), 11-127 statement separators, 4-3
ShowMenuBar (Property), 11-128 statements
ShowMetadata (Property), 11-129 break, 8-16, 15-3
ShowOutliner (Property), 11-130 comment, 15-5
ShowPercentages (Property), 11-131 conditional, 8-7
ShowRowNumbers (Property), 11-132 continue, 8-15, 15-6
ShowSectionTitleBar (Property), 11-133 delete, 15-8
ShowStatusBar (Property), 11-134 do...while, 8-12, 15-9
ShowSubtitle (Property), 11-135 eturn, 15-15
ShowTickmarks (Property), 11-136 for, 8-12, 15-10
ShowTitle (Property), 11-137 for...in, 8-17, 15-11
ShowValues (Property), 11-138 function, 15-12
ShowValuesAtRight (Property), 11-139 if...else, 6-2, 6-4, 8-8, 15-13
ShowVerticalPlane (Property), 11-140 inline if, 8-9
sin, 16-59 JavaScript, 15-1
Size (Property), 11-141 label, 8-14
slice, 16-11, 16-96 labeled, 15-14
small, 16-97 loop, 8-11
sort, 16-15 switch, 6-3, 6-8, 8-10, 15-16
Index 15
statements (continued) tab order properties, 1-15
var, 15-18 Table section, object model map, 13-9
while, 8-13, 15-19 TableSection (Object), 9-100
with, 8-18, 15-20 tan, 16-60
strike, 16-100 test, 16-122
String object test if operators, 4-5
JavaScript, 16-78 testing scripts, Execution window and, 2-11
methods, 16-80 tests, conditional, 8-28
properties, 16-79 Text (Property), 11-155
string operators, 14-10 text box, 1-6
StringRetrieval (Property), 11-149 text files, exporting scripts to, 8-25
strings, concatenation and addition of, 4-10 text labels, 1-6
Style (Property), 11-150 TextWrap (Property), 11-156
sub, 16-101 this, 14-11, 14-15
substr, 16-102 TickmarkFrequency (Property), 11-157
substring, 16-103 TimeLimit (Property), 11-158
SubTitle (Property), 11-151 TimeLimitActive (Property), 11-159
subtraction operator, 4-4, 14-2 Title (Property), 11-160
sup, 16-104 toGMTString, 16-32
SuppressDuplicates (Property), 11-152 toLocaleString, 16-33
SurfaceValues (Property), 11-153 toLowerCase, 16-105
SuspendRecalculation (Property), 11-154 Toolbar (Object), 9-101
switch statements toolbar, Navigation, 1-19
control structures, 6-3 Toolbars (Collection), 9-102
controlling chart facts with, 6-13 toolbars, hiding, 5-17
controlling statement execution, 6-8 tools, layout, 1-17
definition, 6-8, 15-16 Topic (Object), 9-103
using, 8-10 TopicItem (Object), 9-104
versus if...else, 6-8 TopicItems (Collection), 9-105
switching between Design and Run modes, 1-4 TopicName (Property), 11-161
SyncWithDatabase (Method), 10-93 Topics (Collection), 9-106
syntax, 4-2, 15-1 toString, 16-17, 16-21, 16-41, 16-67, 16-72
syntax reference, 8-30 ToString() (Function), 16-35
ToString() (Method), 16-62
toUpperCase, 16-105
T troubleshooting scripts, 8-26
tab order turning off
default, 1-15 page headers, 12-10
setting, 1-15 Prompt To Save dialog box, 12-10
16 Index
Type (Property), 11-162 using (continued)
typeof, 14-11, 14-15 ODS user name as limit, 12-9
types, object, for valueOf method, 16-76 Script Editor, 2-7
variables
for objects, 5-13
U for selections, 5-7
unary negation operator, 14-2 UTC, 16-34
understanding
BrioQuery events, 2-4
BrioQuery object model, 2-2 V
control structure syntax, 6-2 valueOf, 16-75
functions, 8-3 valueOf method, object types for, 16-76
UnhideAll (Method), 10-94 values, 7-3 – 7-4, 7-7
UnionController (Property), 11-165 Values properties, 1-16
UniqueRows (Property), 11-166 ValuesAxis (Object), 9-108
Unselect (Method), 10-95 ValueSource (Property), 11-169
unshift, 16-18 var statements, 15-18
unwatch, 16-74 variable characteristics, 5-7
URL (Collection), 9-107 VariableLimit (Property), 11-170
URL (Property), 11-167 variables
URL parameters, using to pass parameters to ODS assigning values, 4-15
documents, 8-21 characteristics, 5-7
UseAlternateMetadataLocation (Method), 10-96 declaring global, 4-14
user IDs, bypassing, 8-21 declaring local, 4-14
Username (Property), 11-168 definition, 4-13
using dynamically declaring, 4-15
loops, 7-2 naming, 4-2
assignment versus comparison operators, 4-5 space-saving, 8-26
BrioQuery 5.5 Limit dialog box, 12-9 using for a drop down selection, 5-7
browser cookies to pass parameters to ODS using for objects, 5-13
documents, 8-21 Version (Property), 11-171
Console window, to check errors, 2-12 vertical lines, 1-6
design tools, 1-17 VerticalAlignment (Property), 11-172
drop-down boxes, 5-2 View (Property), 11-173
Execution window, to test scripts, 2-11 Visible (Property), 11-174
JavaScript statements, 8-7 Visual Basic, 8-24
JavaScript to open Web and ODS documents, void, 14-11, 14-16
8-18
Index 17
Write (Method), 10-97
W
Writeln (Method), 10-98
watch, 16-76
WebClientDocument (Object), 9-109
while statements X
definition, 15-19 XAxisLabel (Object), 9-111
using, 8-13 XCategory (Object), 9-112
Width (Property), 11-175 XLabels (Object), 9-113
windows
Console, 2-12
Execution, 2-11 Y
WindowState (Property), 11-176 YLabels (Object), 9-114
with statements
definition, 15-20
using, 8-18 Z
words, reserved, 4-17
ZAxisLabel (Object), 9-115
working
ZCategory (Object), 9-116
with EIS objects, 1-5
ZLabels (Object), 9-117
with EIS sections, 1-3
18 Index