- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
By the code below I wanted to show you an example of bad and good variables' names:
'Wrong:
Afstand_tot_center_Ruit = 0.5
'Right
Dim dToCenter As Double = 0.5
If you calculate the angle every time the parameter "Distance_to_center" changes, you'll better to so by triggering the rule by the parameter change.
Put this line at the start of your rule and every time this parameter changes, this rule will trigger.
s = Distance_to_center
Now if you want to run the rule only if the "Distance_to_center" is less than 5 you can do it like this:
s = Distance_to_center Dim dCenter As Double = Distance_to_center If dCenter > 5 Then Exit Sub 'If the value is greater then 5, quit
Now if you want to trigger the rule again, all you need to do is change the the "Distance_to_center" parameter.
BUT, the change have to be the last line of the code.
Here's an example of mid-code self triggering:
(1) - this is the instance of the rule, aka the order in which it did run
Rule (1) starts
Rule (1) changes the parameter "Distance_to_center"
Rule (2) starts
Rule (2) finishes (if it doesn't trigger the rule again)
Rule (1) finishes
It works the same as calling any sub-functions, so keep that ALWAYS in mind.
- - - - - - - - - - - - - - -
Regards,
Mike
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods