This reference documents version 2.62 of the C API. <->
mpsl_argv - Fills the ARGV global array.
void mpsl_argv(int argc, char *argv[]);
argc | number of arguments |
argv | array of string values |
Fills the ARGV global MPSL array with an array of arguments. These
are usually the ones sent to main()
.
mpsl_compile - Compiles a string of MPSL code.
mpdm_t mpsl_compile(mpdm_t code, mpdm_t source);
code | A value containing a string of MPSL code |
Compiles a string of MPSL code and returns an mpdm value executable
by mpdm_exec()
. If there is a syntax (or other type) error, NULL
is returned instead.
mpsl_compile_file - Compiles a file of MPSL code.
mpdm_t mpsl_compile_file(mpdm_t file, mpdm_t inc);
file | File stream or file name. |
inc | search path for source files. |
Compiles a source file of MPSL code and returns an mpdm value
executable by mpdm_exec()
. If file is an MPSL file descriptor,
it's read and compiled; otherwise, it's assumed to be a
file name, that will be searched for in any of the paths defined
in the inc array. If the file cannot be found
or there is any other error, NULL is returned instead.
mpsl_error - Generates an error.
mpdm_t mpsl_error(mpdm_t err);
err | the error message |
Generates an error. The err error message is stored in the ERROR mpsl variable and the mpsl_abort global flag is set, so no further mpsl code can be executed until reset.
mpsl_eval - Evaluates MSPL code.
mpdm_t mpsl_eval(mpdm_t code, mpdm_t args, mpdm_t ctxt);
code | A value containing a string of MPSL code, or executable code |
args | optional arguments for @code |
ctxt | context for @code |
Evaluates a piece of code. The code can be a string containing MPSL source code (that will be compiled) or a direct executable value. If the compilation or the execution gives an error, the ERROR variable will be set to a printable value and NULL returned. Otherwise, the exit value from the code is returned and ERROR set to NULL. The abort flag is reset on exit.
mpsl_get_symbol - Gets the value of a symbol.
mpdm_t mpsl_get_symbol(mpdm_t s, mpdm_t l);
s | symbol name in array form |
l | local symbol table |
Gets the value of a symbol. The symbol can be local or global (if the symbol exists in both tables, the local value will be returned).
mpsl_set_symbol - Sets value to a symbol.
mpdm_t mpsl_set_symbol(mpdm_t s, mpdm_t v, mpdm_t l);
s | symbol name in array form |
v | value |
l | local symbol table |
Assigns the value v to the s symbol. If the value exists as a local symbol, it's assigned to it; otherwise, it's set as a global symbol (and created if it does not exist).
mpsl_shutdown - Shuts down MPSL.
void mpsl_shutdown(void);
Shuts down MPSL. No MPSL functions should be used from now on.
mpsl_startup - Initializes MPSL.
int mpsl_startup(void);
Initializes the Minimum Profit Scripting Language. Returns 0 if everything went OK.
mpsl_trap - Install a trapping function.
mpdm_t mpsl_trap(mpdm_t trap_func);
trap_func | The trapping MPSL code |
Installs a trapping function. The function is an MPSL executable value receiving 3 arguments: the code stream, the arguments and the return value of the executed code.
Returns NULL (previous versions returned the previous trapping function).