call: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Page (little) lifting)
Line 1: Line 1:
{{Command|= Comments
{{Command|Comments=
____________________________________________________________________________________________
____________________________________________________________________________________________


| ofpr |= Game name
| ofpr |Game name=


|1.85|= Game version
|1.85|Game version=
____________________________________________________________________________________________
____________________________________________________________________________________________


| Executes given set of compiled instructions with an option to pass arguments to the executed [[Code]]. In [[OFP]] this command used to accept [[String]] for the code. |= Description
| Executes given set of compiled instructions with an option to pass arguments to the executed [[Code]].
{{Important|In [[:Category:{{ofp}}|{{ofp}}]] this command used to accept [[String]] as well as [[Code]]. This does not apply to {{arma}} and later titles (see [[compile]]).}}|Description=
____________________________________________________________________________________________
____________________________________________________________________________________________


| '''call''' code |= Syntax
| [[call]] code |Syntax=


|p1= code: [[Code]] - [[compile]]d instructions
|p1= code: [[Code]] - [[compile]]d instructions|Parameter 1=


| [[Anything]] - The last value given in the function is returned. See the topic [[Function#Return_Values|Function]] for more information. |= Return value
| [[Anything]] - The last value given in the function is returned. See the topic [[Function#Return_Values|Function]] for more information. |Return value=


| s2= args '''call''' code |= Syntax
|s2= args [[call]] code |Alt Syntax=


|p21= args: [[Anything]] -  Arguments that are passed to the function in the [[_this]] variable. |= Parameter 1
|p21= args: [[Anything]] -  Arguments that are passed to the function in the [[_this]] variable |Alt Parameter 1=


|p22= code: [[Code]] - [[compile]]d instructions
|p22= code: [[Code]] - [[compile|compiled]] instructions|Alt Parameter 2=


|r2= [[Anything]] - The last value given in the function is returned. See the topic [[Function#Return_Values|Function]] for more information. |= Return value
|r2= [[Anything]] - The last value given in the function is returned. See the topic [[Function#Return_Values|Function]] for more information. |Return value 2=
____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>[[call]] {[[hint]] [[str]] 123};</code> |= Example 1
|x1= <code>[[call]] { [[hint]] [[str]] 123; };</code> |Example 1=


|x2= <code>123 [[call]] {[[hint]] [[str]] _this};</code>|= Example 2
|x2= <code>123 [[call]] { [[hint]] [[str]] _this; };</code> |Example 2=


|x3= <code>_sum = [1, 2] [[call]] {(_this [[select]] 0) + (_this [[select]] 1)};
|x3= <code>_sum = [1, 2] [[call]] { ([[_this]] [[select]] 0) + ([[_this]] [[select]] 1); };
[[hint]] [[str]] _sum; //3</code> |= Example 3
[[hint]] [[str]] _sum; {{codecomment|// displays 3}}</code> |Example 3=


|x4= <code>123 [[call]] [[compile]] "[[hint]] [[str]] _this";</code>|= Example 4
|x4= <code>123 [[call]] [[compile]] "[[hint]] [[str]] _this;";</code> |Example 4=


|x5= <code>_result = 123 [[call]] [[compile]] [[preprocessFileLineNumbers]] "myfile.sqf";</code>|= Example 5
|x5= <code>_result = 123 [[call]] [[compile]] [[preprocessFileLineNumbers]] "myFile.sqf";</code> |Example 5=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[spawn]], [[execVM]], [[canSuspend]], [[compile]], [[preprocessFile]] |= See also
| [[spawn]], [[execVM]], [[canSuspend]], [[compile]], [[preprocessFile]], [[remoteExec]], [[remoteExecCall]] |See also=
 
}}
}}


Line 50: Line 50:
<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>


 
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|CALL]]
[[Category:Scripting Commands OFP 1.96|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.99|CALL]]
[[Category:Scripting Commands OFP 1.99|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands OFP 1.96|CALL]]
[[Category:Scripting Commands ArmA|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA|CALL]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Program Flow|{{uc:{{PAGENAME}}}}]]
[[Category:Command Group: Program Flow|CALL]]


<!-- CONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dl class="command_description">
<dd class="notedate">Posted on July 5, 2014 - 16:00 (UTC)</dd>
<dd class="notedate">Posted on July 5, 2014 - 16:00 (UTC)</dd>
<dt class="note">'''[[User:MattAka Horner|MattAka Horner]]'''</dt>
<dt class="note">[[User:MattAka Horner|MattAka Horner]]</dt>
<dd class="note">
<dd class="note">A called function may only use suspension ([[sleep]], [[uiSleep]], [[waitUntil]]) if it originates in a [[Scheduler#Scheduled_Environment|scheduled environment]]. If the called function originates in a [[Scheduler#Unscheduled_Environment|non-scheduled environment]] it will return a generic error:
<br>
<code>{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***}}
A called function may only use suspension ([[sleep]], [[uiSleep]], [[waitUntil]]) if it originates in a [[Scheduler#Scheduled_Environment|scheduled environment]]. If the called function originates in a [[Scheduler#Unscheduled_Environment|non-scheduled environment]] it will return a generic error.
<br>
<code>// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***
[] [[spawn]] {
[] [[spawn]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[[sleep]] 3; // <- OK
[[sleep]] 3; {{codecomment|// <- OK}}
[[hintSilent]] "Hello World!";
[[hintSilent]] "Hello World!";
};
};
};
};</code>
</code>


<code>// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***
<code>{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope***
{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope ***}}
[[sleep]] 3; // <- NOT OK
[[sleep]] 3; {{codecomment|// <- NOT OK}}
[[hintSilent]] "Hello World!";
[[hintSilent]] "Hello World!";
};
};
};
};</code>
</code>


<code>// *** [[Scheduler#Scheduled_Environment|scheduled]] origin ***
<code>{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] origin ***}}
[] [[spawn]] {
[] [[spawn]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[[sleep]] 3; // <- OK
[[sleep]] 3; {{codecomment|// <- OK}}
[[hintSilent]] "Hello World!";
[[hintSilent]] "Hello World!";
};
};
};
};</code>
</code>


<code>// *** [[Scheduler#Scheduled_Environment|scheduled]] origin ***
<code>{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] origin ***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[] [[call]] {
[] [[call]] {
// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***
{{codecomment|// *** [[Scheduler#Scheduled_Environment|scheduled]] scope ***}}
[[sleep]] 3; // <- OK
[[sleep]] 3; {{codecomment|// <- OK}}
[[hintSilent]] "Hello World!";
[[hintSilent]] "Hello World!";
};
};
};
};</code>
</code>
</dd>
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on February 17, 2015 - 11:02 (UTC)</dd>
<dd class="notedate">Posted on February 17, 2015 - 11:02 (UTC)</dd>
<dt class="note">[[User:Patriot821|Patriot821]]</dt>
<dt class="note">[[User:Patriot821|Patriot821]]</dt>
<dd class="note">
<dd class="note">If the code is in [[Scheduler#Unscheduled_Environment|non-scheduled]] scope and contains while-do statement, the code runs only 10,000 times at the maximum, even if the statement makes infinite loop. (ARMA3 Ver. 1.38.128937)
If the code is in [[Scheduler#Unscheduled_Environment|non-scheduled]] scope and contains while-do statement, the code runs only 10,000 times at the maximum, even if the statement makes infinite loop. (ARMA3 Ver. 1.38.128937)
<code>{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***}}
<code>// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] origin ***
[] [[call]] {
[] call {
{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope ***}}
// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope***
[] [[call]] {
[] call {
{{codecomment|// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope ***}}
// *** [[Scheduler#Unscheduled_Environment|non-scheduled]] scope ***
_a = 0;
_a<nowiki>=</nowiki>0;
[[while]] { _a < 15000 } [[do]] {
while{_a<15000} do{
_a = _a + 1;
_a<nowiki>=</nowiki>_a+1;
};
};
hint str(_a);//10000
[[hint]] [[str]] _a; {{codecomment|// displays 10000}}
};
};
};</code>
};</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 01:34, 3 July 2018

Hover & click on the images for description

Description

Description:
Executes given set of compiled instructions with an option to pass arguments to the executed Code.
In Operation Flashpoint this command used to accept String as well as Code. This does not apply to Arma and later titles (see compile).
Groups:
Uncategorised

Syntax

Syntax:
call code
Parameters:
code: Code - compiled instructions
Return Value:
Anything - The last value given in the function is returned. See the topic Function for more information.

Alternative Syntax

Syntax:
args call code
Parameters:
args: Anything - Arguments that are passed to the function in the _this variable
code: Code - compiled instructions
Return Value:
Anything - The last value given in the function is returned. See the topic Function for more information.

Examples

Example 1:
call { hint str 123; };
Example 2:
123 call { hint str _this; };
Example 3:
_sum = [1, 2] call { (_this select 0) + (_this select 1); }; hint str _sum; // displays 3
Example 4:
123 call compile "hint str _this;";
Example 5:
_result = 123 call compile preprocessFileLineNumbers "myFile.sqf";

Additional Information

See also:
spawnexecVMcanSuspendcompilepreprocessFileremoteExecremoteExecCall

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 10,000 times at the maximum, even if the statement makes infinite loop. (ARMA3 Ver. 1.38.128937) // *** non-scheduled origin *** [] call { // *** non-scheduled scope *** [] call { // *** non-scheduled scope *** _a = 0; while { _a < 15000 } do { _a = _a + 1; }; hint str _a; // displays 10000 }; };