Exercises

<< Click to Display Table of Contents >>

 

Exercises

1.Insert on the EventScreen two SetPoints, named "spInitialDate" and "spFinalDate", and two Text-type objects, according to the next figure.

SetPoints

SetPoints

2.In this exercise, let's use a Viewer method to display a calendar, so that users can select a date. Create a new script on the Click event of the SetPoints.

'Executes the Calendar function
If Application.ShowDatePicker(DateTime, 0, 0) Then
  'Assigns the selected date to the SetPoint
  Value = DateTime
End If

 

3.To create the previous script, select, using AppBrowser, the Viewer's ShowDatePicker method and click Paste.

Application.ShowDatePicker(DateValue, Left, Top, [DefaultDate])

 

4.The DefaultDate parameter is optional and informs the selected date on the calendar. Delete it because the default is going to be used, which corresponds to the current date.

5.Replace the Left and Top parameters by 0 (zero) or by the desired coordinates where to open the calendar.

6.The DateValue parameter must be replaced by a script's internal variable. This variable must be created with the name "DateTime".

7.The ShowDatePicker method returns True if users click OK and False if they click Cancel. Only if users click OK the calendar value must be assigned to the SetPoint. Type "If" at the beginning of the line of the ShowDatePicker command and "Then" at the end of it.

If Application.ShowDatePicker(DateTime, 0, 0) Then

 

8.To assign the calendar's date to the SetPoint, type on the next line the next text.

Value = DateTime

 

9.As this script is typed in the Setpoint, and its Value property must be referenced, users can directly type the name of the property without specifying its full path.

10.Finish the script by typing "End If".

11.Open the configuration window of the E3Browser's Query object. This can be performed by right-clicking the object and selecting the Configure item or using the Query tab of E3Browser's Properties Window.

Configure a Query

Configure a Query

12.On the Filter column of the E3TimeStamp field, click Configure Filter Configure Filter.

13.For users to select the initial and final date, query variables must be created. Configure the filter according to the next figure.

Filter configuration

Filter configuration

14.Type an initial value for these variables on the Variables tab.

Initial values for the filter

Initial values for the filter

15.Select the View tab and click Run query Run query to check Query results. Make sure the filter was applied and click OK.

16.On the EventScreen, next to the SetPoints, create a "Query" Command Button and insert a new script on its Click event with the next code.

'References the SetPoints
IniDate = Screen.Item("spInitialDate").Value
EndDate = Screen.Item("spFinalDate").Value
Set query = Screen.Item("E3Browser1").Item("Query1")
'Configures Query variables
query.SetVariableValue "InitialDate", IniDate
query.SetVariableValue "FinalDate", EndDate

 

17.To create the previous script, type the script's internal variable "IniDate = ".

18.Select, using AppBrowser, the SetPoint spInitialDate and, on the right, its Value property.

IniDate = Screen.Item("spInitialDate").Value

 

19.Repeat the previous step to create the internal variable EndDate, referencing the spFinalDate SetPoint's value.

EndDate = Screen.Item("spFinalDate").Value

 

20.Select, using AppBrowser, the Query1 inside E3Browser1. On the right, select its SetVariableValue method.

Screen.Item("E3Browser1").Item("Query1").SetVariableValue(VarName, Value)

 

21.Insert a line break right after the text "Item('Query1')".

Screen.Item("E3Browser1").Item("Query1")_
  .SetVariableValue(VarName, Value)

 

22.Type at the beginning of the line the text "Set query = ". This code creates a script's internal variable that references the Query object.

Set query = Screen.Item("E3Browser1").Item("Query1")

 

23.At the beginning of the line containing the SetVariableValue method, type "query.".

query.SetVariableValue(VarName, Value)

 

24.The VarName parameter references the name of the variable created in the Query. Type "InitialDate".

25.In the Value parameter, inform the value to assign to the variable. In this case, this is the value of the SetPoint that was referenced using the internal variable IniDate.

query.SetVariableValue "InitialDate", IniDate

 

26.Remove the parentheses from the SetVariableValue method.

27.Copy the previous line to implement the same logic for the variable FinalDate.

query.SetVariableValue "FinalDate", EndDate

 

28.Compile this script and execute the application.

Was this page useful?