4D v14ビデオの内容 |
||
|
4D v14
ビデオの内容
ビデオの内容
Today we're going to learn to create and program arrays as well as objects we can use to represent them in forms. Like a simple variable, an array must be:
To help us understand this, we're going to create a first array in the DETAIL form of the INTERVENTIONS table. This array will concern the objects.
To make things simple, we're going to put all the programming in the object. This will also let us review the concept of an event.
$evt:=Form event The object method will be made up of a certain number of elements:
We're going to trace the operation of this method by carrying out an initial test. We see that when we double-click on an intervention, we go to On Load. We'll be able to display the array that contains 5 elements and these 5 elements are gradually assigned values. When we choose a value in the menu, we see here the line number indicated in a variable, which is a variable that has the same name as the array, but which is a longint type variable. And here we see the 5 elements of the array, the elements 1 to 5 and then the zero element which we will come back to later. When this method is executed:
We can replace these 3 lines by a single one as follows: [Interventions]Object:=PopObjects{PopObjects} Why? Because this value here is the longint variable that contained the 3 earlier ones, so it indicates the line number of the array concerned (which has the same name). [Interventions]Object:=Self->{Self->} which uses a pointer to the object. Since programming is carried out on the object itself, Self refers to the object and when we write Self->{Self->}, we indicate the array {at the row chosen in the array} and we transfer the contents directly into the object. We're going to trace this to check that we get the same result.
This breakdown helps us understand in detail. Now we're going to create a new array where we can enter a date to within plus or minus 10 days.
This is a date array of 21 elements: today + 10 days - 10 days So, how do we fill in these elements? We're going to make a loop where we assign a value to the array as follows: (Current date + $i-11). Of course, the array will have the correct name and now we can test it: Now that you know how to program arrays, you can represent them in different 4D objects, such as list boxes. A list box is an object made up of one or more columns with headers and it is precisely the column that interests us, where we'll just write the name of the array that we managed in memory. If we now return to an intervention, the list box contains the different values of the array and we see the direct synchronization between the choice in the list box and the corresponding one in the array here. We're going to program the list box in the same way so that when we click on it or when we make a new selection in it, the value of the object is modified automatically. So in the list box we check the On Clicked and On Selection Change events. You just need to copy the following line into the object method of the list box: [Interventions]Object:=PopObjects{PopObjects} During use, when we select a value in the list box with the mouse or using the arrow keys, the values are transferred automatically. Of course, it is also possible to use drag and drop as long as the areas were set as draggable and droppable. |
プロパティ
プロダクト: 4D ARTICLE USAGE
セルフトレーニング ( 4D v13) |