call: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 117: Line 117:
};
};
</code>
</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on February 17, 2015 - 11:02 (UTC)</dd>
<dt class="note">[[User:Patriot821|Patriot821]]</dt>
<dd class="note">
If the code is in non-scheduled scope and contains while-do statement, the code runs only 10000 times at the maximum, even if the statement makes infinite loop.
<code>// *** non-scheduled origin ***
[] call {
// *** non-scheduled scope***
[] call {
// *** non-scheduled scope ***
_a<nowiki>=</nowiki>0;
while{_a<15000} do{
_a<nowiki>=</nowiki>_a+1;
};
hint str(_a);//10000
};
};</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 12:02, 17 February 2015

Hover & click on the images for description

Description

Description:
Executes the function string. The argument(s) (if any) are passed as _this. (argument(s) are passed in an array). To execute a sleep function in the called code, execute it with spawn instead.
Groups:
Uncategorised

Syntax

Syntax:
argument(s) call body
Parameters:
argument(s): Any Value - Optional. Argument that is passed to the function in the "_this" variable.
body: Code - A function body provided directly 'inline' or the String returned from the commands loadFile or preprocessFile.
Return Value:
Anything - The last value given in the function is returned. See the topic Function for more information.

Examples

Example 1:
call {"x = 3"}
Example 2:
Operation Flashpoint syntax: _n = 3;
call format [{var%1 = 0},_n];
Armed Assault syntax: _n = 3;
call compile format ["var%1 = 0",_n];
result of both syntaxes is var3 = 0
Example 3:
Operation Flashpoint syntax: _fAdd = loadFile "add.sqf" [1,2] call _fAdd Armed Assault syntax: _fAdd = compile loadFile "add.sqf" _result = [1,2] call _fAdd

Additional Information

See also:
spawncompilepreprocessFile

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

Notes

Bottom Section

Posted on July 5, 2014 - 16:00 (UTC)
MattAka Horner

A called function may only use suspension (sleep, uiSleep, waitUntil) if it originates in a scheduled environment. If the called function originates in a non-scheduled environment it will return a generic error.
// *** non-scheduled origin *** [] spawn { // *** scheduled scope *** [] call { // *** scheduled scope *** sleep 3; // <- OK hintSilent "Hello World!"; }; }; // *** non-scheduled origin *** [] call { // *** non-scheduled scope*** [] call { // *** non-scheduled scope *** sleep 3; // <- NOT OK hintSilent "Hello World!"; }; }; // *** scheduled origin *** [] spawn { // *** scheduled scope *** [] call { // *** scheduled scope *** sleep 3; // <- OK hintSilent "Hello World!"; }; }; // *** scheduled origin *** [] call { // *** scheduled scope*** [] call { // *** scheduled scope *** sleep 3; // <- OK hintSilent "Hello World!"; }; };
Posted on February 17, 2015 - 11:02 (UTC)
Patriot821
If the code is in non-scheduled scope and contains while-do statement, the code runs only 10000 times at the maximum, even if the statement makes infinite loop. // *** non-scheduled origin *** [] call { // *** non-scheduled scope*** [] call { // *** non-scheduled scope *** _a=0; while{_a<15000} do{ _a=_a+1; }; hint str(_a);//10000 }; };