YoYo Games Wiki

execute_file(fname,arg0,arg1,...)

From YoYoGames Wiki

Description

Execute the piece of code in the file with name fname with the indicated arguments.

Arguments

  • fname (string): file name with a piece of code to be executed.
  • arg0-arg14 (reals or strings): values of arguments within a piece of code.

Returns

(reals or strings): a result of a piece of code, e.g., a value used in return statement within piece of code.

Explanation

This function is used to execute a piece of code that is not known at design time. It executes the piece of code in the text file with given name fname with the indicated arguments.

Arguments

While executing file, values of global variables argument0-argument14 are set to corresponding values arg0-arg14. There can be up to 15 arguments to a piece of code due to Game Maker Restrictions to have 16 arguments on function calls.

Variable Scope

Temporary variables defined in outer piece of code are undefined while executing a file. Only variables, declared in str with var statement can be accessed. Of course, global and local variables are accessible.

Return and Exit

If there are a return statement in piece of code, then function execute_file returns a value indicated in it. If piece of code is terminated with exit statement or just by reaching its end, the function returns 0.

See also