4D v16セットと命名セレクション |
|||||||||||||||||||||||||||||
|
4D v16
セットと命名セレクション
セットと命名セレクション
ビデオ中で説明されている操作に加え、以下の点にも留意してください。 メモリの観点からみると:
以下の表はセットと命名セレクションの違いをまとめたものです:
セット間の演算は同じテーブルのセットでのみ可能です。 警告: セットはレコードの削除などが行われると有効ではなくなります。限定した時間内でのみ利用すべきです。またセマフォーなどの使用も考慮すべきです。 セットのビットは各テーブルレコードの位置に対応します。レコードの削除と追加が行われると、削除されたレコードが新しいレコードに置き換えられるかもしれません。このときセットは期待したレコードを含んでいない状態となります。 しかしながら依然としてセットは二つのセレクションを比較する素早い方法です。 セレクションを保持する方法としてはほかにSELECTION TO ARRAYコマンドを使用して、レコード番号配列を取得することもできます。 メモリ中に保持したセレクションのコピーが必要なくなった時は、それを削除してメモリ領域を開放すべきです。 CLEAR SET("SetName") In this video, we're going to learn how to keep a selection and perform functions (union, intersection, and difference). Sets are a simple way to intersect lists of records from a single table. They are one of the ways you can use to put a selection on hold so that it can be used again later on. We're going to apply these principles right away to the list of interventions in the navigation form. We can create a set from the current selection. We're going to create a button that searches for all the interventions that were started before 9:00 a.m. Here is the method of the button: QUERY([Interventions];[Interventions]Intervention_Time and we're going to create a 2nd button that will give us all the interventions that are not yet 100% completed. We can program this button as follows: QUERY([Interventions];[Interventions]Progress<100) For the moment, in the file we imported, the progress % is not filled in. So first we're going to apply a formula on all the interventions. Here we have a selection of 11,732 interventions where we're going to apply a formula and specify that:
If we now produce a report to check what progress % values have been filled in, we see that they range from 0 to 100. Of course, if we click on the 1st button and then on the 2nd, we will have lost the selection created during the 1st click. CREATE SET([Interventions];"Morning_Interventions") Similarly, here, after retrieving the set of interventions that have not yet been completed, we can call this set "Interventions_in_progress". CREATE SET([Interventions];"Interventions_in_progress") Then we can compare the sets:
We can test these different possibilities by executing the navigation form. Why is that? Remember that in the previous video, in the Navigation_Function we added, at the very bottom, this line that gives us the number of records found after a new selection is created. vNumRecords:=Records in selection([Interventions]) We're going to copy this code and apply it to the 2 query buttons. Then we can copy this line of code for 4 other buttons:
Now, if we go back to the navigation form, we have:
Interventions before 9:00 a.m. + those at 100%, 9:00 a.m. interventions still in progress or 9:00 a.m. interventions that are finished, don't seem to change the number that is here. Why is that? It's because simply creating a set does not imply its use. So we're going to modify the code and:
And that way we can test:
To complete this approach, we're going to close the form and launch the Navigation method again to check its operation. We can see, in the list on the left, the "Sets" theme that shows the list of existing sets in the process being traced. Currently, there are none. When the method is executed:
And then we'll see, because the set already exists, it's only the quantity that changes. You need to keep in mind that a set is only a list of records that is not necessarily the current selection since right now the current selection of the Interventions table contains 601 records. When we switch to the USE SET command, the selection now contains a number of records matching the number indicated in the set and the vNumRecords variable is also adapted accordingly. Another use of sets that is very convenient consists in selecting a certain number of records and then indicating that we want to make them the current selection; in other words, when we click the button, there are now only these X records. To do this, we must:
The code looks like this: $SetName:="Userset_"+String(Milliseconds) In other words, we're going to:
We can test:
At this level, we have:
In our array, we now have the list of records that we selected. A set is made up of one bit per record and therefore does not preserve the sort order. When you need to keep this information, you must use commands related to named selections: Here we're going to add a button that allows us to:
It's now possible to store 2 selections that will take the sorting order into account. They exist in memory but will not be used. Then we're going to:
If we take all the interventions:
Now:
|
プロパティ
プロダクト: 4D
履歴
ARTICLE USAGE
セルフトレーニング ( 4D v16) |
|||||||||||||||||||||||||||