Graphic 3 for SigmaPlot

Adding a Dialog to a Macro

If you add a dialog to the macro then the user can easily interact with it. Lets create a dialog that allows user entry of the number of data sets to be fitted. There are two basic steps to do this: 1) creating the dialog visually and 2) writing the code that characterizes the behavior of the dialog. 

First create the dialog visually. Open the Exponential Fit macro Edit window, place your cursor after the Sub Main statement as shown below and click on the User Dialog button.

Enzyme Kinetics Module 1 1 gr1

The UserDialog Editor window appears. Click on the AddText button and create a text label by dragging the mouse.

Enzyme Kinetics Module 1 1 gr2

Repeat this procedure to add a textbox next to the text label and OK and Cancel buttons. Move these objects around to obtain a rough placement on the dialog. Then adjust the width and height of the dialog.

Enzyme Kinetics Module 1 1 gr3

Double click the text label. The Edit Text Properties dialog box that is shown on the left below is displayed. Enter the caption "Number of Data Sets."  Interactively edit the position parameters of all objects to achieve precise vertical and horizontal alignment. For example, the Top parameters for the text label (left) and the textbox (right) are both set to be 7.

As a final touch, double click on the dialog design window and enter the dialog caption "Fit Multiple Data Sets." This results in the final dialog on the left below and the macro code for it on the right.

Begin Dialog UserDialog 270,70, "Fit Multiple Data Sets"

                      Text 10,7,90,28,"Number of DatSets,".Text1

                      TextBox 100,7,70,14,.TextBox1

                      OKButton 190,7,78,21

                      CancelButton 190,35,78,21

            End Dialog

            Dim dlg As UserDialog

            Dialog dlg

This is the code which displays the dialog. To give the dialog function we add the additional argument DialogFunc to the end of the Begin Dialog statement.

Begin Dialog UserDialog 270,70,"Fit Multiple Data Sets,".DialogFunc ' %GRID:10,7,1,1

This is the name of the function that determines the behavior of the dialog. We will copy a sample dialog function from Help and paste it into our macro . Highlight "DialogFunc" in the Begin Dialog statement and press F1. Select the DialogFunc Prototype topic. Copy the syntax directly from Help and delete Cases 3, 4, and 5 (we won't be needing them) and paste it to the bottom of your macro. The following code is added to your macro

Function DialogFunc(DlgItem$, Action%, SuppValue%) As Boolean

    Select Case Action%

    Case 1 ' Dialog box initialization

    ...

    Case 2 ' Value changing or button pressed

    ...

    End Select

End Function

Modify the statements above to create the following

See DialogFunc help topic for more information

Function DialogFunc(DlgItem$, Action%, SuppValue&) As Boolean

      Select Case Action%

      Case 1 'Dialog box initialization

                  DlgText "OK", "Fit"

      Case 2 'Value changing or button pressed

                  Select Case DlgItem$

                  Case "OK"  'OK button pressed

                              NumFits = CInt(DlgText("TextBox1"))

                  End Select

      End Select

End Function

The first statement (below the comment) initializes the dialog by changing the label in the OK button to "Fit." Highlight DlgText and press F1 to learn more about this instruction. The second group of statements detects when the OK button has been pressed and then gets the value from the textbox and assigns it to the global variable NumFits. There is no error checking in this simple example so if the user leaves the textbox blank or enters a non-numeric value an error will occur.

There are three additional programming details that need to be addressed. We need to dimension the global variable NumFits so, at the top of the macro after Option Explicit, add the line

Option Explicit
Dim NumFits As Integer

Next the Cancel button is a special case and must be dealt with separately from the DialogFunc function. The statement "Dialog dlg," which appears after the End Dialog statement, activates the dialog and returns a zero if the Cancel button has been pushed. So change this line as shown below. 

If Dialog(dlg) = 0 Then GoTo Finish
Dim i As Integer
For I = 1 To NumFits

and add the "Finish" label at the end of the main subroutine

Finish:
End Sub

Pressing the Cancel button will now exit the dialog and jump to the Finish label thus terminating the macro.

Last, change the "2" in the for-loop to "NumFits" as shown above.

Save the macro and close the macro Edit window. Open Exponential Data Set 3.jnb that contains eight data sets. Double click on Graph Page 1 in the notebook to open the graph.  Open the macro dialog from the menu item Macros, Exponential Fit and enter "8" in the dialog.

Click OK to run the macro and obtain the eight fit lines displayed with the data in the graph.

The Exponential Data Set 3. jnb notebook also contains the completed macro named "Exponential Fit Example." With the graph window in focus, double click on this macro and click Run to run it.

 

Back to SigmaPlot Product Uses Page.

 

SigmaPlot gr 1

 

 

 

Buy Sigma Plot!

Sigma Plot
Product Details

21 CFR 11
Sigma Plot Capabilities
Sigma Plot Requirements
Use Within SPSS
New in Sigma Plot 8.0
New in SigmaPlot 9.0
New in SigmaPlot 10.0

Sigma Plot
Resources

Sigma Plot Add-on Modules
Sigma Plot FAQ
Graph Showcase
Sigma Plot Quotes
Sigma Plot Product Uses
Technical Support

SPSS Base
Add-on Modules

SPSS Advanced Models
SPSS Categories
SPSS Complex Samples
SPSS Conjoint
SPSS Exact Tests
SPSS Maps
SPSS Missing Value
   Analysis
SPSS Regression
   Models
SPSS Tables
SPSS Trends

SPSS Other Products
SPSS Amos
SPSS AnswerTree
SPSS Data Entry Builder
SPSS Data Entry Station
SPSS Data Entry System
SPSS DecisionTime
SPSS SamplePower
SPSS SmartViewer
SPSS TextSmart

SPSS Training
SPSS Web-based Training

Other Products
AutoSignal
PeakFit
SigmaPlot
SigmaScan
SigmaStat
SYSTAT
TableCurve 2D
TableCurve 3D

 

 

 

bottombar221

Gold Jewelry