Notifications
Clear all

We had a major storm through here recently and we suffered damage to the house roof and ceilings. I just received the quote to repair. I’m hoping that a small fraction of the 80,000 odd people that download SDIO and/or Desktop Info every month won’t mind chipping in a few dollars to help out. Click on the big blue button at the bottom of the page to help us keep a roof over our heads, literally!

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

ONLOAD

1 Posts
1 Users
0 Reactions
70 Views
Glenn
(@glenn)
Member Admin
Joined: 7 years ago
Posts: 1591
Topic starter  

ONLOAD
Onload is used to indicate an item should be evaluated before anything else. There are two onloads. The onload common option and the BEGIN-ONLOAD block. 

Prior to v3.20 they both behaved differently. As of v3.20 Desktop Info will evaluate all onload items at once after the config has finished loading and before anything else. Whether you use BEGIN-ONLOAD or the common option onload, they'll behave the same.

common option:
  onload:1 evaluate first cycle and never again
  onload:2 evaluate first cycle and then normally
  This is distinct from a normal item with interval:0 which will be evaluated once on the second cycle and never again.

BEGIN-ONLOAD=onload:n, if-value1:x, if-comp:x, if-value2:x

...

END-ONLOAD
   sets the onload value for all enclosed items

The BEGIN-ONLOAD has it's own IF evaluation to make things even simpler.  If the IF options are not present the enclosed items are set according to onload value. If the IF options are present then the items are set only if the IF evaluates to true. Only the onload option is set for each item, the items themselves are not yet evaluated. Onload items are evaluated during the first cycle after config load and before normal operation. Once the BEGIN-ONLOAD block has been processed it is discarded and not used again. The enclosed items remain.

When Do I Need This?

So what's the problem this is trying to solve? When Desktop Info has finished loading the configuration, two things start happening: 1) The display begins displaying the items and 2) the collector starts evaluating. These happen asynchronously, that is to say they are independent of each other.  So it's entirely probable that some items will be displayed before they've been evaluated. This is not really a problem except in the case of controls such as buttons and images that are controlled by IF items. They may be displayed before their IF item has evaluated and we end up with phantom or duplicated controls or controls that just shouldn't be there. The onload tool forces these items to be evaluated before anything is displayed and so eliminates the premature display.

 

This topic was modified 4 days ago by Glenn

   
Quote
Topic Tags
Glenn's Page