LoadOnce Element (Data): Difference between revisions

From HLKitWiki
Jump to navigationJump to search
Created page with "{{context|Kit Reference|Data File Reference}} ==The "loadonce" Element== The loadonce element has the following attributes: :{| class="infotable" |class="leftnormal"|key |K..."
 
No edit summary
Line 14: Line 14:


If two or more files have the same loadonce element, exactly one of them will be loaded, with no guarantee of which one it will be. Don't assume anything about which file of a pair will be loaded - for example, on one computer, file A might be loaded and file B skipped, while on another computer file B might be loaded and file A skipped.
If two or more files have the same loadonce element, exactly one of them will be loaded, with no guarantee of which one it will be. Don't assume anything about which file of a pair will be loaded - for example, on one computer, file A might be loaded and file B skipped, while on another computer file B might be loaded and file A skipped.
**Please note**: When choosing your key, make sure to choose something unique that won't be picked by anyone else! If you and someone else both use the same key, only one of your files will be loaded, which would cause problems that would be very hard to debug.


==Example==
==Example==
Line 20: Line 22:


<pre>
<pre>
File A: <loadonce key="Source Definition File"/>
File A: <loadonce key="John Smith's Source Definition File"/>


File B: <loadonce key="Source Definition File"/>
File B: <loadonce key="John Smith's Source Definition File"/>
</pre>
</pre>


Line 28: Line 30:


<pre>
<pre>
File A: <loadonce key="Source Definition File"/>
File A: <loadonce key="John Smith's Source Definition File"/>


File B: <loadonce key="Other Definition File"/>
File B: <loadonce key="John Smith's Other Definition File"/>


File C: <loadonce key="Other Definition File"/>
File C: <loadonce key="John Smith's Other Definition File"/>


File D: <loadonce key="Other Definition File"/>
File D: <loadonce key="John Smith's Other Definition File"/>
</pre>
</pre>

Revision as of 06:44, 8 December 2014

Context: HL Kit &#133; Kit Reference &#133; Data File Reference 

The "loadonce" Element

The loadonce element has the following attributes:

key Key – Specifies a unique text key for the file. Only one file will ever be loaded for any given key.

If a "loadonce" element is found at the top of a file, the file is only parsed if another file with the same key has NOT been loaded. If a file with that key has already been loaded, the contents of the file are totally ignored.

If two or more files have the same loadonce element, exactly one of them will be loaded, with no guarantee of which one it will be. Don't assume anything about which file of a pair will be loaded - for example, on one computer, file A might be loaded and file B skipped, while on another computer file B might be loaded and file A skipped.

    • Please note**: When choosing your key, make sure to choose something unique that won't be picked by anyone else! If you and someone else both use the same key, only one of your files will be loaded, which would cause problems that would be very hard to debug.

Example

If two files had the following loadonce elements, only a single one of them would be loaded:

File A: <loadonce key="John Smith's Source Definition File"/>

File B: <loadonce key="John Smith's Source Definition File"/>

If four files had the following loadonce elements, file A would be loaded and only one of file B, C or D would also be loaded:

File A: <loadonce key="John Smith's Source Definition File"/>

File B: <loadonce key="John Smith's Other Definition File"/>

File C: <loadonce key="John Smith's Other Definition File"/>

File D: <loadonce key="John Smith's Other Definition File"/>