Visual Basic Integration

The industry standard Statistica Visual Basic language (integrated into Statistica) offers incomparably more than just a "supplementary application programming language" that can be used to write custom extensions. Taking full advantage of the object model architecture of Statistica, with Statistica Visual Basic (SVB) you can access programmatically every aspect and virtually every detail of the functionality of the program. Even the most complex analyses and graphs can be recorded into Visual Basic (SVB) macro programs and later be run repeatedly or edited and used as building blocks of other applications. Statistica Visual Basic adds an arsenal of more than 13,000 new functions to the standard comprehensive syntax of Microsoft Visual Basic, thus comprising one of the largest and richest development environments available.

Creating Statistica Visual Basic Programs

There are several methods in which Statistica Visual Basic programs can be created:

  1. Recording a macro. When you run an analytic procedure or create a graph, the Visual Basic code corresponding to all design specifications as well as output options are recorded in the background. Entire interactive Statistica analysis sessions involving different types of analyses can be recorded via the Master Macro facility. That code can then be executed repeatedly or edited by changing options, variables, or data files, optionally adding a user interface, etc.
  2. SVB development environment. Programs can be written from scratch using the Statistica Visual Basic professional development environment featuring a convenient program editor with a powerful debugger (with breakpoints, etc.), intuitive dialog painter, and many facilities that aid in efficient code building.
  3. Visual Basic from other applications. SVB programs can also be developed by enhancing Visual Basic programs created in other applications (e.g., Microsoft Excel), by calling Statistica functions and procedures.

Statistica, Visual Basic, Program, Macro

Executing Statistica Visual Basic Programs

Statistica Visual Basic (SVB) programs can be run from within Statistica; because of the industry standard compatibility of Statistica Visual Basic and the various libraries of the Statistica system (accessible to Visual Basic), you can also access Statistica Visual Basic functions from any other compatible environment (e.g., Microsoft Excel, Word, or a stand-alone Visual Basic language). The large library of Statistica functions (more than 13,000 procedures) is transparently accessible not only to Visual Basic (either the one that is built in or a different one), but also to calls from any other compatible programming language or environment such as C/C++, Java, or Delphi.

Applications for Statistica Visual Basic Programs

Statistica Visual Basic programs can be used for a wide variety of applications from simple macro (SVB) programs recorded to automate a specific (repeatedly used) sequence of tasks, to elaborate custom analytic systems combining the power of optimized procedures of Statistica with custom developed extensions featuring their own user interface. Scripts for analyses developed this way can be integrated into larger computing environments or executed from within proprietary corporate software systems or intranet or Internet portals. Statistica Visual Basic programs can also be attached to virtually all important "events" in a Statistica analysis such as opening or closing files, clicking on cells in spreadsheets, etc.; in this manner, the basic user interface of Statistica can be highly customized for specific applications (e.g., for data entry operations, etc.).

Structure of Statistica Visual Basic

Statistica Visual Basic consists of two major components: (1) The general Visual Basic programming environment with facilities and extensions for designing user interfaces (dialogs) and file handling, and (2) the Statistica libraries with thousands of functions that provide access to practically all functionality of Statistica.

The Visual Basic programming environment follows the industry standard syntax conventions of the Visual Basic language; the few differences pertain mostly to the manner in which dialogs are created, and they are designed to offer programmers and developers more flexibility in the way user interfaces are handled in complex programs. In the Statistica Visual Basic programming environment, dialogs can be entirely handled inside separate subroutines, which can be flexibly combined into larger multiple-dialog programs; Visual Basic is form based, where the forms or dialogs, and all events that occur in the dialogs, are handled in separate program units.

Recording SVB Macros (Programs):Macros, Master (Log) Macros, and Keyboard Macros

Statistica provides a comprehensive selection of facilities for recording macros (SVB programs) to automate repetitive work or to be used as a means to automatically generate programs for further editing and modification. The macro (Statistica Visual Basic) programs recorded by these facilities can be saved to be run "as is," or they can be used as the "building blocks" for more complex and highly customized Visual Basic application programs.

There are three general categories of macros that can be automatically created as you run Statistica.All three follow the identical syntax and can be modified, but because of the different ways in which each of them is created, they offer distinctive advantages and disadvantages for specific applications.

  1. Statistica Analysis Macros. First, you can record a simple Analysis Macro from an analysis, i.e., record the settings, selections, and chosen options for that specific analysis. [Note that the term "analysis" in Statistica denotes one task selected either from the Statistics or Graphs menu that can be very small and simple (e.g., one scatterplot requested from the Graphs menu), or very elaborate (e.g., a complex structural equation modeling analysis selected by choosing that command from the Statistics menu, and involving hundreds of output documents]. After selecting any of the Statistical commands from the Statistics menu or graphics commands from the Graphs menu, all actions such as variable selections, option settings, etc., are recorded "behind the scenes"; at any time you can transfer this recording (i.e., the Visual Basic code for that macro) to the Visual Basic Editor window. Note that the Create Macro command is available from every analysis via the Options menu or the shortcut menu (accessed by right-clicking the analysis button) when the respective analysis is minimized.
  2. Master Macros (Logs). Second, you can record a Master Macro or Master Log of your entire session that can consist of several or many analyses; this recording will "connect" analyses performed with various analysis options from the Statistics or Graphs menu. However, unlike simple Analysis Macros, you can turn the recording of Master Macros on or off. The Master Macro recording will begin when you turn on the recording, and it will end when you stop the recording. In between these actions, all file selections and most data management operations are recorded, as are the analyses and option selections for the analyses, in the sequence in which they were chosen.
  3. Keyboard macros. When you select Start Recording Keyboard Macro from the Tools – Macro submenu, Statistica will record the actual keystrokes you enter via the keyboard. When you stop the recording, a Statistica Visual Basic editor window will open with typically a very simple program containing a single SendKeys command with symbols that represent all the different keystrokes you performed during the recording session. Note that this type of macro is very simple in the sense that it will not record any context in which the recorded keystrokes are pressed and will not record their meaning (i.e., commands that these keystrokes will trigger), but this feature makes them particularly useful for some specific applications.

A Visual Basic Editor and Debugger

The Statistica Visual Basic environment includes a flexible program editor and powerful debugging tools.

Visual Basic, VB, type ahead, syntax

When editing macro programs by typing in general Visual Basic commands or program commands specific to Statistica Visual Basic, the editor displays type-ahead help to illustrate the appropriate syntax.

Visual Basic, VB, help, syntax Help on the members and functions for each class (object) is also provided in-line.
Visual Basic, VB, Breakpoints, programming When executing a program, you can set breakpoints in the program, step through line by line, and observe and change the values of variables in the macro program as it is running.
Visual Baisc, VB, Development Environment, Syntax, Programming Programs can be written from scratch using the Statistica Visual Basic professional development environment featuring an intuitive dialog editor.

To summarize, Statistica Visual Basic is not only a powerful programming language, but it represents a very dynamic, professional programming environment for developing simple macros as well as complex custom applications.

ActiveX Objects and Documents (A Technical Note)

The term ActiveX is used in different contexts, and its definitions stress different aspects of that concept. Its use within Statistica, however, can be grouped into two general categories: ActiveX objects and ActiveX documents.

ActiveX Objects

An ActiveX object is what was once referred to as an OLE (Object Linking and Embedding) object. At its heart is the Microsoft COM (Component Object Model) technology that enables objects to be accessed in a uniform manner. Through the use of standard protocols, objects created in one application can be stored and edited in a different application. To support this functionality, the containing object needs to be an object client, and the application that initially created the object needs to be an object server. Statistica is both. As an object client, Statistica can be used to embed objects in, and link objects from other applications to the spreadsheet, graph, and report windows. As an ActiveX object server, Statistica can be used to embed and link spreadsheets and graphs into other applications.

ActiveX Documents

ActiveX documents take the ActiveX controls one step further, in that entire documents can be embedded into other applications. An ActiveX document container allows other application documents to be used within it, and an ActiveX document server allows its documents to be used within any ActiveX document container. Again, Statistica does both. Statistica Workbooks are ActiveX document containers, and documents from other ActiveX servers can be displayed within the workbook. Examples of this are Microsoft Word and Excel; these documents can be used directly from within a Statistica Workbook. Similarly, Statistica Spreadsheets, Graphs, and Reports are ActiveX document servers, and they also can be placed within any ActiveX document container such as Microsoft Internet Explorer and Microsoft Binder.

OLE Support

Statistica supports the Object Linking and Embedding (OLE) conventions that are used to link values, text, graphs, or other objects in Statistica documents (e.g., spreadsheets, reports) to documents in other (Windows) applications. Technically speaking, you can establish OLE links between a "source" (or server) file (e.g., a Microsoft Word document) and a Statistica document (the "client" file), so that when changes are made to the data in the source file, the data are automatically updated in the respective part of the Statistica document (client file). Additionally, Statistica can serve as a "source" (or server) file for other OLE compatible documents. In this way, you can link the values in a Statistica Spreadsheet to a table in a Microsoft Word document, so that the Word document updates when data in the spreadsheet are changed.

DDE Support

Statistica also supports the Dynamic Data Exchange (DDE) conventions. You can establish DDE links between a "source" (or server) file (e.g., a Microsoft Excel spreadsheet) and a Statistica data file (the "client" file), so that when changes are made to the data in the source file, the data are automatically updated in the respective part of the Statistica Spreadsheet (client file). Thus, you can dynamically link a range of data in its spreadsheet to a subset of data in other (Windows) applications.

A common application for dynamically linking two files would be in industrial settings, where the Statistica data file is dynamically linked with a measurement device connected to the serial port (e.g., in order to automatically update specific measurements hourly). Just as with OLE, the procedure is in fact much simpler than it might appear and can be easily employed without technical knowledge about the mechanics of DDE.

Programming Statistica from .NET

Virtually every aspect of Statistica is exposed as a set of COM interfaces that are registered on a machine when Statistica is installed. Since .NET-based languages cannot communicate with COM directly, a wrapper class called the COM Interop can be utilized to integrate the Statistica libraries into your .NET project. The COM Interop layer is created automatically by the Visual Studio .NET IDE when you import a COM interface. The COM Interop layer handles all of the details regarding interacting with the COM libraries in .NET. With the COM Interop layer in place, the Statistica COM interfaces behave like any other .NET object.

Also see: