with: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "\|x([0-9])= *<code>([^<]*)<\/code>" to "|x$1= <sqf>$2</sqf>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 25: | Line 25: | ||
{{!}}- | {{!}}- | ||
{{!}} | {{!}} | ||
< | <sqf>] spawn | ||
{ | { | ||
with uiNamespace do | |||
{ | { | ||
for "_i" from 1 to 1 do | |||
{ | { | ||
systemChat str [ | |||
currentNamespace isEqualTo uiNamespace, | |||
currentNamespace isEqualTo missionNamespace | |||
]; | ]; | ||
// result [true, false] | // result [true, false] | ||
sleep 0.05; // <-- small suspension | |||
systemChat str [ | |||
currentNamespace isEqualTo uiNamespace, | |||
currentNamespace isEqualTo missionNamespace | |||
]; | ]; | ||
// result [false, true] <-- switching | // result [false, true] <-- switching | ||
}; | }; | ||
}; | }; | ||
};</ | }; | ||
</sqf> | |||
{{!}} | {{!}} | ||
< | <sqf> | ||
with uiNamespace do | |||
{ | { | ||
[] | [] spawn | ||
{ | { | ||
for "_i" from 1 to 1 do | |||
{ | { | ||
systemChat str [ | |||
currentNamespace isEqualTo uiNamespace, | |||
currentNamespace isEqualTo missionNamespace | |||
]; | ]; | ||
// result [true, false] | // result [true, false] | ||
sleep 0.05; // <-- small suspension | |||
systemChat str [ | |||
currentNamespace isEqualTo uiNamespace, | |||
currentNamespace isEqualTo missionNamespace | |||
]; | ]; | ||
// result [true, false] <-- NO switching | // result [true, false] <-- NO switching | ||
}; | }; | ||
}; | }; | ||
};</ | }; | ||
</sqf> | |||
{{!}}} | {{!}}} | ||
Line 76: | Line 79: | ||
|x1= <sqf>_myWithType = with uiNamespace;</sqf> | |x1= <sqf>_myWithType = with uiNamespace;</sqf> | ||
|x2= <sqf>with missionNamespace do {global = global + 1};</sqf> | |x2= <sqf>with missionNamespace do { global = global + 1 };</sqf> | ||
|seealso= [[missionNamespace]] [[uiNamespace]] [[parsingNamespace]] [[currentNamespace]] | |seealso= [[missionNamespace]] [[uiNamespace]] [[parsingNamespace]] [[currentNamespace]] | ||
}} | }} |
Revision as of 15:34, 13 May 2022
Description
- Description:
- Creates a With Type that is used inside a do construct in order to execute code inside a given 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
Examples
- Example 1:
- Example 2:
Additional Information
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