This reference documents version 1.0.8-dev 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_boolean - Returns 'true' or 'false' MPSL stock values.
mpdm_t mpsl_boolean(int b);
b | boolean selector |
Returns MPSL's 'false' or 'true' values depending on the value in b.
mpsl_compile - Compiles a string of MPSL code.
mpdm_t mpsl_compile(mpdm_t code);
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);
file | File stream or file name. |
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 as is 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 MPSL global array (take note that the current
directory is NOT searched by default). 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);
code | A value containing a string of MPSL code, or executable code |
args | optional arguments 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);
s | symbol name |
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).
This function is only meant to be executed from inside an MPSL
program; from outside, it's exactly the same as calling mpdm_sget()
(as the local symbol table won't exist).
mpsl_is_true - Tests if a value is true.
int mpsl_is_true(mpdm_t v);
v | the value |
If v is a valid MPSL 'false' value (NULL, "" or the "0" string), returns zero, or nonzero otherwise.
mpsl_set_symbol - Sets value to a symbol.
mpdm_t mpsl_set_symbol(mpdm_t s, mpdm_t v);
s | symbol name |
v | value |
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).
This function is only meant to be executed from inside an MPSL
program; from outside, it's exactly the same as calling mpdm_sset()
(as the local symbol table won't 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.