Procedures

<< Click to Display Table of Contents >>

 

Procedures

1.Insert a Formula object in the application.

2.Configure a Database and a table. Use an existing Database on this project, and name this table as "Production".

Configuring a Database and a table

Configuring a Database and a table

3.Create three Templates in this Formula:

External Diameter: With an absolute value restriction between 50 and 80

Internal Diameter: With a difference value restriction of 10 and 10

Height: With a restricted limit

Templates

Templates

4.The next step defines Units relative to this Formula. Before creating these Units, however, users must create Tags for this Formula. To do so, insert a Folder named "Formula" on a Data Server, and inside it two other Folders named "Engine1" and "Engine2". Inside these Folders, create three Internal Tags for each one.

Creating Tags

Creating Tags

Create two Units in this Formula, named "Engine1" and "Engine2". Link each field on these Units to the previously created Tags.

Linking Tags to Formula Units

Linking Tags to Formula Units

6.Define all Value Sets to load later into Tags. Create four Value Sets, named from "Model1" to "Model4", and type their values as on the next figure.

Configuring Value Sets

Configuring Value Sets

7.Create a new Screen named "Formulas".

8.Create six SetPoint objects on this Screen, which must be linked to each Tag in this Formula, and adjust this Screen's size to the size of these objects. This Screen should look like the next figure.

Formula screen

Formula screen

 

NOTE

Sometimes an error may occur on a Screen that makes images disappear. To solve this issue, disable the Hide MS-DOS extensions for registered files option. This option is available on Windows Explorer.

 

9.Create a button on this Screen with a "Load values" caption. This button displays a dialog box with existing values and Units to which these values can be loaded, and users can select any option. To do so, create the following script in this button.

Sub CommandButton1_Click()
  Application.LoadFormulaDlg_
    "Formula1", "Machine1, "Machine2",_
    "Model1, Model2, Model3, Model4"
End Sub

 

Where Formula1 is Formula's name and LoadFormulaDlg is a Viewer method. When executing this method, the dialog box on the next figure is displayed.

LoadFormulaDlg method's dialog box

LoadFormulaDlg method's dialog box

10.On the window to the right, there are two Units created in this Formula, as well as Value Sets. The Silent Mode option prevents users from overriding values saved on disk, which are loaded to Tags.

11.Using this button, users can check the application working with Formulas and Tags receiving values from disk. This is one method for loading values from a Formula, but there are also methods in which users do not need to select values or Units on a dialog box.

12.Now create a SetPoint on this Screen and a button with an "OK" caption. Along with this SetPoint, place a Label with a "Model:" caption. On this button, users must create the next script.

Sub CommandButton2_Click()
  Application.LoadFormulaValues_
    "Formula1", "Engine1", "Model1"
  Screen.Item("Text16").Value
End Sub

 

Where Text16 is the name of the last SetPoint inserted on this Screen. This command loads a Value Set specified in this SetPoint to Engine1 Unit. When executed, this method then searches for a Value Set on disk. If found, this method loads it according to restriction patterns defined in Formula's Template. Fields with open restrictions may have their values changed by users. If users do not want to be warned about changed values in loaded fields, they must use the silent mode.

Value change

Value change

However, there is an alternative, Viewer's LoadFormulaValuesQuiet method. Users opt by the Silent mode on a Screen, by using a Check Box for this.

1.Create a Check Box on this Screen.

2.Place a Label on it, with a "Silent" caption.

3.Return to the OK button script, and change it to the following code.

Sub CommandButton2_Click()
  If Screen.Item("CheckBox1").Value = True Then
    Application.LoadFormulaValuesQuiet_
      "Formula1", "Engine1", "Model1"
    Application.LoadFormulaValuesQuiet_
      "Formula1", "Engine1", "Model2"
    Application.LoadFormulaValuesQuiet_
      "Formula1", "Engine1", "Model3"
    Application.LoadFormulaValuesQuiet_
      "Formula1", "Engine1", "Model4"
  Else
    Application.LoadFormulaValues_
      "Formula1", "Engine1", "Model1"
    Application.LoadFormulaValues_
      "Formula1", "Engine1", "Model2"
    Application.LoadFormulaValues
      "Formula1", "Engine1", "Model3"
    Application.LoadFormulaValues_
      "Formula1", "Engine1", "Model4"
  End If
End Sub

 

Where CheckBox1 is Check Box's name. This uses the LoadFormulaValuesQuiet method if this object is enabled. Otherwise, the LoadFormulaValues method is used.

4.Repeat the previous procedures, from creating a SetPoint for items of Engine2, by modifying all required scripts. After finishing these changes, this Screen should look like the next figure.

Final Screen for this Formula

Final Screen for this Formula

5.Execute this application and check its results.

Was this page useful?