ヘルプ日本語訳/OR operators

Last-modified: 2011-01-07 (金) 17:54:44

ヘルプ日本語訳 > Understanding the events > Understanding the conditions > OR operators

 

The OR operators

OR 演算子
Multimedia Fusion 2 Developer build 244 から、新機能の OR 演算子があります。OR 演算子を使うと同じアクションのイベントを一行にまとめることができ、イベントのプログラムを簡略化できます。

 

OR 演算子は以下のようにイベントの条件のグループに挿入して使います。

 

+条件1
+条件2
OR
+条件3
OR
+条件4
+条件5

 

アプリケーション実行時、「条件1と条件2」が真になった時、または、「条件3」が真になった時、または、「条件4と条件5」が真になった時に、このイベントは真になります。どの条件のグループ(あるいはこれらの内のいくつか)が真になっても、アクションが実行されます。このように、OR 演算子を使うと、数行に複製せざるおえなかったアクションのグループを、ひとつの行にまとめることができます。

 

2種類の OR
Multimedia Fusion 2 Developer には OR 演算子(フィルタ)と OR 演算子(論理)の2種類の OR 演算子があります。これらは別の働きをするので、複雑なプログラミングをする前に2つの OR 演算子ついてよく知っておきましょう。違いは、オブジェクトの選択の仕方に現れます。

 

OR 演算子(フィルタ)
大抵の場合はこの演算子を使います。次の条件とアクションについて考えます。

 

+マウスポインタがオブジェクト1上にある
OR(フィルタ)
+マウスポインタがオブジェクト2上にある
-オブジェクト1を破壊
-オブジェクト2を破壊

 

マウスポインタがオブジェクト1上にある場合、オブジェクト1は破壊されますが、オブジェクト2は残ります。マウスポインタがオブジェクト2上にある場合、オブジェクト2は破壊されますが、オブジェクト1は残ります。OR 演算子(フィルタ)はイベントの全ての条件を検査し、検査時に全てのオブジェクトを選択します。偽の条件に含まれるオブジェクトも選択されますが、関連付けられたアクションは実行されません。これは、OR 演算子(フィルタ)のあるイベントのアクションが真の条件に選択されたオブジェクトのみに作用するためです。

 

OR 演算子(論理)
この演算子は偽の条件のオブジェクトを選択しません。オブジェクトが選択されていないとき、選択されていないオブジェクトに関連するアクションに出くわした際のMultimedia Fusion 2 Developer の通常のふるまいをします。つまり、与えられたオブジェクトすべてに作用するということです。上記の例のOR(フィルタ)をOR(論理)に置き換えたものを考えてみましょう。
マウスポインタがオブジェクト1上にある場合、両方のオブジェクトが破壊され、マウスポインタがオブジェクト2上にある場合も両方のオブジェクトが破壊されます。マウスポインタがオブジェクト1上にある場合について考えます。まず、オブジェクト1が選択されます。アクションが呼ばれます。「オブジェクト1を破壊」アクションは選択されたオブジェクト(マウスの下のもの)を見つけ、それを削除します。「オブジェクト2を破壊」アクションは選択されたオブジェクトを見つけられませんので、アクションはすべてのオブジェクト2を破壊します。

 

どちらのOR 演算子を使うかはあなた方次第であり、そしてそれはあなた方の作るプログラムに依存します。

(原文)The OR operators

A new feature has appeared in Multimedia Fusion 2 Developer since build 244 : the OR operators. The OR operators can simplify a lot your program of events by allowing you to group actions on a single line of events.

 

The OR operator must be inserted in the group of conditions of an event, like this :

 

+ Condition 1
+ Condition 2
OR
+ Condition 3
OR
+ Condition 4
+ Condition 5

 

Upon runtime, this group of events will be true when (Condition 1 and Condition 2) is true, OR Condition 3 is true OR (Condition 4 and Condition 5) is true. If any (or several of them) of these groups of conditions is true, the actions are executed. As you can see, the OR operator allows you to group actions in one line of event instead of being obliged to duplicate them on several lines.

 

Two kinds of OR
Multimedia Fusion 2 Developer provides two kinds of OR operators, the filtered OR and the logical OR. They work differently and you should understand them before doing complex programming. The difference lays in the way the objects are selected by the conditions.

 

The Filtered OR operator
This is the operator you should use in most of the cases. Imagine the following conditions and actions :

 

+ Mouse is over object 1
OR (filtered)
+ Mouse is over object 2
- Destroy object 1
- Destroy object 2

 

If the mouse is over object 1, then object 1 is destroyed, but object 2 remains there. If the mouse is over object 2, object 2 is destroyed but object 1 remains there. The filtered OR operator explores all the conditions of the event, and marks all the objects as inspected. The objects contained in false condition are marked as well, but the action related to them will not occur. This is the reason why actions in a event with the filtered OR operator will only affect the objects selected in the conditions that are true.

 

The Logical OR operator
This operator does not mark the objects in false conditions. As the objects are not marked, the default behavior of Multimedia Fusion 2 Developer when it encounters an action dealing with non-marked objects, is to affect ALL the occurences of the given objects. In our example, if we replace the filtered OR by a logical OR, you will have as a result :
If the mouse is over object 1, then both objects are destroyed, if the object is over object 2, then both objects are destroyed. Imagine mouse is over object 1, object 1 is selected. The actions are called. The Destroy object 1 action finds a selected object (the one under the mouse) and deletes it. The Destroy object 2 action find NO selected object: it destroys all the occurences of object 2.

 

Using either one of the OR operator is up to you, and it depends on the program you are making.