Well, I've made some changes after I've posted the last message (including a new attached file), so you've probably downloaded the old one.
Nvm. as for the "AuxLight()" it should be "S_AuxLight()". It's one of the functions at the bottom of the code:
Sub S_AuxLight()
S_AuxLight1()
S_AuxLight2()
End Sub
As for the "C_IsActiveComponent(...)" error, it should be "C_IsActive(...)". My mistake when I was replacing it.
So, I've corrected it and I'm sending you the updated rule in attachment.
Note:
I've enclosed some parts of your code (right in the first change I've made to your code) into Sub-Functions like this one:
Sub S_TG_Lock()
's = TG_Lock
C_IsActive("Bottom Tailgate Lock:1", Parameter("TAIL-GATE-ASSY:1", "Bottom_Locks"))
C_IsActive("Bottom Tailgate Lock:2", Parameter("TAIL-GATE-ASSY:1", "Bottom_Locks"))
Select Case TG_Lock
Case "Barndoor"
Parameter("AD Floor Complete-CP:1", "Tailgate_Option") = "Barn Door"
C_IsActive("Bottom Tailgate Lock:1", False)
C_IsActive("Bottom Tailgate Lock:2", False)
Case "Air Lock": Parameter("AD Floor Complete-CP:1", "Tailgate_Option") = "Standard Airlock"
Case "Manual Lock": Parameter("AD Floor Complete-CP:1", "Tailgate_Option") = "Standard Manual"
End Select
iLogicVb.UpdateWhenDone = True
End Sub
The main part of your code is enclosed in subfunction called "Sub Main()". This is the part that will execute when the rule starts.
If we want to execute any of the other "Subs" we have to call them from the Main Sub (this is the case with the "S_AuxLight()".
There are two basic types of functions:
Sub <name> - will execute where used, the parent sub will wait for the sub-function to finish before continuing
Function <name> As String - same as in Sub, except it can return a value, in this case text (string).
You can look at the way I've used these two in the code and let me know if you'll need further info.
Blue highlighted is the name of the sub-function. We can use this name anywhere in the Main Sub (or in any called Sub or Function).
Red highlighted (and commented out) is an auto-execution for a parameter (in this case "TG_Lock").
This is a little bit of code I'd like you to use to improve the speed of your rule, while keeping it all in one place.
So, if we place the "s = TG_Lock" (or "s = <any-other-paramter>" at the start of any Sub, it'll self-execute every time this parameter changes.
There can be more parameters present at once, like:
s = TG_Lock
s = Liner
I've commented them all out because I don't know how you're calling the rule (my guess would be the OK button in the user-form).
You can uncomment them and play with them to execute individual Subs (without the starting the "Sub Main").
This way will execute only the parts of the code that really need to be executed, so the executing speed will improve.
I hope I've explained this atleast a bit understandably, so let me know if you need any further info about this as well.
Also, it's just an idea, so you can keep these commented out (or even remove them) and don't use them at all, it's your call.
There're some other programming "wonders" we could use to speed this up a little bit, but I believe this code is not as complex for them to be used. They might however come handy if you'll be creating something a little bit more complex in the future, so we can go back to them once we're done with this one, or you can simply summon me here on forum once you'll need me.
I can still do some further sorting of the code once we have a function version, so it looks a little more human-readable, clean, easy to maintain, reuse, expand and execute.
I'm sorry for the wall of text, I hope it'll be of some use.
EDIT: This time I've edited only some typos and colors. (As a non-native speaker I always have something to improve and fix.)
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
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