What are the major "components" in a typical SVB macro program?

When you record a macro program from an interactive analysis, as illustrated in How can I record my analysis in an SVB program?, you will notice several common components of the programs. Statistica Visual Basic is organized around analysis objects; for example, to run an analysis with the Statistica Basic Statistics module, you would first create an analysis object, with the constant scBasicStatistics and (optionally) with a data file name (location of the file containing the input spreadsheet). For a complete list of modules (reference libraries) see Statistica Libraries and Modules. To make access to the thousands of Statistical functions and options available in the Statistica system as convenient as possible, Statistica Visual Basic maintains a very close correspondence between the dialogs as they are presented during interactive analyses, and the flow of the program. In a sense, once an analysis has been created, such as an analysis via the Basic Statistics module, you simply "program the dialogs" for the respective Statistical analysis.

Here is a brief breakdown of the components of a (typical) Analysis Macro program, recorded via Basic Statistics Descriptive Statistics.

First, there is the statement:

Set newanalysis = Analysis (scBasicStatistics, ActiveDataSet)

Here the new analysis object is created of type Analysis with the constant scBasicStatistics, and with the current ActiveDataSet as the input datafile; this statement will display the Descriptive Statistics Startup Panel. Note that scBasicStatistics is actually a predefined (in SVB) numeric constant. If you have recorded a Master Macro, the SVB syntax would look slightly different; specifically, the input datafile would be explicitly assigned to a variable of type Spreadsheet (e.g., Set S1 = ActiveSpreadsheet), and consecutive analyses would be numbered, and initialized using that variable (e.g., Set newanalysis1 = Analysis (scBasicStatistics,S1)).

Next, there is the block:

With newanalysis.Dialog

.Statistics = scBasDescriptives

End With

newanalysis.Run

The With newanalysis.Dialog block is a shortcut method for setting the various properties available on the startup dialog; in this case the only property is the Statistics property, which selects the Descriptive statistics option on the startup dialog. The newanalysis.Run statement "clicks" OK, i.e., causes the program to proceed to the next dialog. The next dialog block sets the many properties of the Descriptive Statistics dialog.

With newanalysis.Dialog

.Variables = "1 2 3 4 5 6 7 8"

       ...

       ...

.CompressedStemAndLeaf = False

End With

Finally, at the end of the macro you have:

newanalysis.RouteOutput(newanalysis.Dialog.Summary).Visible = True

newanalysis.RouteOutput(newanalysis.Dialog.Histograms).Visible = True

These two lines select the Summary results spreadsheet and the Histograms button on the Normality tab (in a sense these commands "click" those buttons). The RouteOutput method takes as an argument the Summary or Histograms collection (of spreadsheets, graphs, or both) and places it into the workbook, report, etc. depending on the current selections on the Analysis/Graph Output Manager dialog. The RouteOutput method actually returns an object of type AnalysisOutput, which itself has a number of methods and properties to make it fully "programmable."