Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers, Unverified Users Joined: 10/28/2004(UTC) Posts: 3,111 Location: Perth, Western Australia
Was thanked: 16 time(s) in 16 post(s)
|
underground, Patrick and all,
Programming in MS can be made a little easier if we remember a little 'trick'. In the code:
If(Roc(FML('Name"),1,$)>0,1,0) we ask MS to return a figure of 1 if the statement is true and 0 if it is false. The VERY SAME can be achieved with the simpler, shorter code:
Roc(FML('Name"),1,$)>0
If the statement above is true then a figure of 1 is returned, 0 otherwise.
This means that we can create 'binary' waves and the like without using any If() statements:
If(Roc(FML('Name"),1,$)>0,1,
If(Roc(FML('Name"),1,$)<0,-1,0))
AND
If(Roc(FML('Name2"),1,$)>0,1,
If(Roc(FML('Name2"),1,$)<0,-1,0))
returns values of 1 iff (if and only if) BOTH conditions Roc(FML('Name"),1,$)>0 and Roc(FML('Name2"),1,$)>0 are true, 0 otherwise, can be written to return the same:
Roc(FML('Name"),1,$)>0
AND
Roc(FML('Name2"),1,$)>0
Code extensions
Lets take this a little further....
To see when one condition or both conditions are true try adding them:
Roc(FML('Name"),1,$)>0
+
Roc(FML('Name2"),1,$)>0
wil return 2 when both conditions are true, 1 when either condition is true and 0 when neither condition is true.
You could also tell which is condition is true by taking the difference (this is exceptionally powerful when the conditions need to be defined as mutually exclusive):
Roc(FML('Name"),1,$)>0
-
Roc(FML('Name2"),1,$)>0
will return 1 when only the first condition is true, -1 when only the second condition is true, 0 when neither condition is true, (and here's the powerful part) 0 when BOTH conditions are true!
Hope this helps
wabbit :D
|