"trigname" here is a trigger variable. It is null, it has no value. It's not yet a 'trigger'.
What InitTrig functions do is 'set trigname=CreateTrigger()' which turns your trigger variable from null to a trigger. Once a trigger variable is a trigger and not null, it can have events, conditions and actions attached to it.
That is what InitTrig does ("InitiateTrigger")
Code: Select all
trigger trigname = CreateTrigger()
"trigname" here is still a trigger variable. However, instead of being declared as a null trigger variable, it is declared as already a trigger. Hence, we skipped a step.
What this means is that we don't need to "set trigname=CreateTrigger()" because it's already created. InitTrig still serves the purpose of attaching the events, conditions and actions to the trigger so we still need it. You CAN get rid of InitTrig if you move the functions which attach events, conditions and actions to function main or function InitCustomTriggers.
This is what a lot of trigger optimizers do to get rid of useless InitTrig functions to save space and speed up map a bit.