with: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
m (Text replacement - "\{\{cc\|([^} ]*)\}\}" to "// $1")
Line 35: Line 35:
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
];
];
{{cc|result [true, false]}}
// result [true, false]
[[sleep]] 0.05; {{cc|<-- small suspension}}
[[sleep]] 0.05; // <-- small suspension
[[systemChat]] [[str]] [
[[systemChat]] [[str]] [
[[currentNamespace]] [[isEqualTo]] [[uiNamespace]],  
[[currentNamespace]] [[isEqualTo]] [[uiNamespace]],  
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
];
];
{{cc|result [false, true] <-- switching}}
// result [false, true] <-- switching
};
};
};
};
Line 56: Line 56:
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
];
];
{{cc|result [true, false]}}
// result [true, false]
[[sleep]] 0.05; {{cc|<-- small suspension}}
[[sleep]] 0.05; // <-- small suspension
[[systemChat]] [[str]] [
[[systemChat]] [[str]] [
[[currentNamespace]] [[isEqualTo]] [[uiNamespace]],  
[[currentNamespace]] [[isEqualTo]] [[uiNamespace]],  
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
[[currentNamespace]] [[isEqualTo]] [[missionNamespace]]
];
];
{{cc|result [true, false] <-- NO switching}}
// result [true, false] <-- NO switching
};
};
};
};

Revision as of 11:26, 12 May 2022

Hover & click on the images for description

Description

Description:
Creates a With Type that is used inside a do construct in order to execute code inside a given namespace.
To avoid the below-mentioned issue error (whether in scheduled or unscheduled environment) use setVariable/getVariable with the desired Namespace.
Problems:
When used in a do-construct in scripts with allowed suspension, a namespace switching might unexpectedly occur inside some scopes (for, if, try, call) started in a scheduled environment after small suspension if with was not the main scope; however, the issue does not arise if with is used in the parent scope:
namespace switch risk namespace switch safe

[] spawn { with uiNamespace do { for "_i" from 1 to 1 do { systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] sleep 0.05; // <-- small suspension systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [false, true] <-- switching }; }; };

with uiNamespace do { [] spawn { for "_i" from 1 to 1 do { systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] sleep 0.05; // <-- small suspension systemChat str [ currentNamespace isEqualTo uiNamespace, currentNamespace isEqualTo missionNamespace ]; // result [true, false] <-- NO switching }; }; };

Groups:
Program FlowNamespaces

Syntax

Syntax:
with namespace
Parameters:
namespace: Namespace
Return Value:
With Type

Examples

Example 1:
_myWithType = with uiNamespace;
Example 2:
with missionNamespace do {global = global + 1};

Additional Information

See also:
missionNamespace uiNamespace parsingNamespace currentNamespace

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note