ifndef
- Last UpdatedAug 21, 2023
- 2 minute read
The ifndef command creates a sort of pre-processing behavior. The code inside the if node is parsed at scripting loading time only if the referenced define doesn't exist.
A typical usage is to create script files that can be referenced by multiple other files.
Platform support
This element is fully supported on XR-Windows, XR-Portable Windows, XR-Portable iOS, XR-Portable Android, and XR-P WASM platforms.
|
XR-WIN |
XR-P-WIN |
XR-P-IOS |
XR-P-AND |
XR-P-WASM |
|---|---|---|---|---|
|
Full support |
Full support |
Full support |
Full support |
Full support |
|
|
|
|
|
|
To configure an Ifndef
-
Create an ifndef that references the define created in the first row.
-
Put all the scripts inside the ifndef element.
-
Create a define in the last script row inside ifndef.
In this way, the script nodes are read only during the first inclusion of the file.
Code example
This is a code example for the ifndef node.
<ifndef name="template">
<deftemplate name="aTemplate" >
<!--...-->
</deftemplate>
<define name="template" />
</ifndef>
Position
The ifndef element must be inside a context node, such as Context or Global.
Fields
These are the fields for ifndef command.
|
Fields |
Type |
Use |
Default value |
Description |
|---|---|---|---|---|
|
name |
sstring |
Mandatory |
Not set |
The define to check existence. |