Jump to content
Sign in to follow this  
Ilias38rus

How to store a code.

Recommended Posts

_la = [{sleep 1}];

hint "t";
_la select 0;
hint "t1";

or

_la = [{sleep 1}];

hint "t";
_lsr = spawn (_la select 0);     //_lsr = spawn {_la select 0}; | _lsr = spawn {(_la select 0)}; 
waituntil {skriptdone _lsr}
hint "t1";

Do not working, how to do it?

Share this post


Link to post
Share on other sites


_la = [{sleep 1}];

hint "t";

_lsr = [] spawn (_la select 0);

waituntil {scriptdone _lsr}

hint "t1";

Share this post


Link to post
Share on other sites

Unlike call and execVM, spawn doesn't have a unary (right hand side argument only) version. You need to pass something (usually an empty array, which can later be extended to include arguments).

Also you don't need to put code blocks into arrays. The execution of code in blocks is always delayed until some command (like call, spawn, waitUntil, etc) executes it.

Share this post


Link to post
Share on other sites
_la = [{sleep 1}];

hint "t";
_lsr = [] spawn (_la select 0);
waituntil {scriptdone _lsr}
hint "t1";

 

Unlike call and execVM, spawn doesn't have a unary (right hand side argument only) version. You need to pass something (usually an empty array, which can later be extended to include arguments).

Also you don't need to put code blocks into arrays. The execution of code in blocks is always delayed until some command (like call, spawn, waitUntil, etc) executes it.

Array is just example.

 

Thank you both.

Share this post


Link to post
Share on other sites

spawn makes it run in a different thread. call makes it run in the same thread.

Share this post


Link to post
Share on other sites

If this is just an example of how to store and call/execute code in a variable then:

_la = {sleep 1};

hint "t";

call _la;

hint "t1";

Otherwise:
hint "t";

sleep 1

hint "t1";

  • Like 1

Share this post


Link to post
Share on other sites

spawn makes it run in a different thread. call makes it run in the same thread.

Thank you, i should read it.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×