4D v16Current selection |
||
|
4D v16
Current selection
Current selection
In addition to the manipulations explained in the video, you should also note that: The following diagram illustrates how 4D works, in other words the SELECTION-ACTION mode: The concept of the Current selection is one of the fundamentals of 4D that is a little different than the usual ones, especially SQL. A current selection is a list of records obtained by querying the table (equivalent to the WHERE clause in SQL) In 4D, we continually have a current selection per table. This selection can contain anywhere from 0 to X records. The current selection consists of the list of records on which we’ll perform processes. You can change the current selection between two processes. The code below corresponds to the exercise carried out in this video (2 lines for declaring simple variables are added at the top): C_DATE($StartYear;$EndYear) To avoid setting the size of arrays before performing the loop and assigning a value to the $Index variable during the process (which lets us discover the Selected record number function), you can use the APPEND TO ARRAY command. Today, we're going to learn what the current selection consists of and what kinds of interactions occur between selections and arrays. We’re going to get started by creating a statistical array presented in a List box. It will obtain the number of services per technician for a given period. For this purpose, we've created a STATS form containing a list box with 2 columns and a button used to perform the calculation. In the button's method, we're initially going to select all the technicians. So we have:
We just got the names of these arrays in the list box:
Once these initializations are done, we position ourselves on the 1st technician; then as long as there are still technicians, we're going to search for the interventions by these technicians. So we'll be searching in the interventions for:
At this point, we have the list of interventions for the technician loaded in memory. In order to determine the row of the arrays to fill in, we're going to ask 4D to provide the number of the technician being processed. Once we have this information, we can fill in:
At this point, we've finished the statistical part except for one small detail, we just need to remember to change records when we finish processing the first one. We can test the form and check whether we actually get a certain number of interventions for each technician. To limit this to a given period, we're going to modify the method here and indicate, for instance, that we want to set the period to a single year, for example 2011.
Once we have indicated these 3 items of information, we can now complete the search by a search in the selection of interventions and we're looking for all the interventions where:
We can test the form again and see what has changed.
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
Self-training ( 4D v16) |