4D v16計算とフォーミュラ |
||
|
4D v16
計算とフォーミュラ
計算とフォーミュラ
In this video, we're going to learn to use variables and do some simple programming. In addition to saving "raw" information, our database must also provide us with:
Certain data must be kept and so they are saved in a database field; this is the case, for instance, of the total (including tax) for an estimate or the date of an intervention. Other data that is less permanent may only be needed during the work-session (and is lost at the end of the session when we exit 4D). In this second case, we'll use "variable" type objects. One common example is the number of records in the list following a query. When we display all the interventions, how can we find out how many we have or how many records were found after performing a query on the object ="Training"? To begin, we're going to indicate, in a variable, the number of records found in the INTERVENTIONS table after a query. The question to keep in mind while programming is: "When should the calculation be triggered?". In our case, we think that it should be when the user clicks on one of the following buttons:
In all other cases (like sorting, printing, reports, or labels), the number of records doesn't vary so there's no reason to recalculate it. We're going to place this variable in the navigation form on page 0 since we ultimately want to use this variable to display the number of records regardless of the table concerned. So, once we're on page 0:
This will be a variable:
Next we're going to set up the calculation method in the "All" button as follows. After the ALL RECORDS command has executed, we're going to request that vNumRecords be equal to the number of Records in selection for the Interventions table. Clearly, this number of records will be calculated when we are working on the list of interventions. And we'll do the same calculation, which will be optimized later on, when we are working on the Technicians table. We can also copy this programming for the Query button since, after our queries on the Technicians or Interventions tables, we'll need to recalculate this number. For the moment, we're leaving the methods in the objects for educational purposes. Later on, we'll call another method by passing parameters. Now we can test Navigation and check that:
|
プロパティ
プロダクト: 4D
履歴
ARTICLE USAGE
セルフトレーニング ( 4D v16) |