Tuto WEBDEV 25

Part 5: Let’s continue the development 193 ▶ The control that was just created is an advanced control that includes the slider and two controls displaying the bounds. The programming required to display the bounds is already performed in the control. We are going to initialize the Slider control so that it proposes the bounds corresponding to the data found in the Orders data file. 1. Select the Slider control and display its events (F2). 2.  Insert the following code (before the existing code lines) into the "Initializing" event of the control: // The lower value is the least expensive amount HReadFirst(Orders,TotalIOT) MySelf..MinValue = Orders.TotalIOT MySelf..LowerValue = MySelf..MinValue // The upper value is the most expensive amount HReadLast(Orders,TotalIOT) MySelf..MaxValue = Orders.TotalIOT MySelf..UpperValue = MySelf..MaxValue Let’s study this code: • HReadFirst is used to read the first record of the "Orders" data file according to the browse key, TotalIOT in this case. Therefore, this function will be used to read the record corresponding to the lowest amount. • Then, the amount read in the record is associated with the lower bound of Slider control as well as its lower value. • The lower bound is used to specify the minimum value that can be selected by the user. • The lower value is used to specify the minimum value currently selected. • The same principle will be used to find the greatest amount. The only difference is the name of the function used: HReadLast . This function will allow you to read the last record of the Orders data file according to the amount, i.e. the record with the highest amount. 3. Close the code window. ▶ We are now going to pass the selected amounts in parameter to the query: 1. Display the events associated with theTable control: select the Table control and press the F2 key. 2.  In the "Initializing" event of the Table control, replace the lines: //MySource.ParamMinPrice = "1500" //MySource.ParamMaxPrice = "3000" by: MySource.ParamMinPrice = SLIDER_Price..LowerValue MySource.ParamMaxPrice = SLIDER_Price..UpperValue In this code, the parameters corresponding to the prices are equal to the lower value and upper value of the slider. 3. Close the code editor. 4. Save the page ( or Ctrl + S).

RkJQdWJsaXNoZXIy NDQ0OA==