# MPI Functions Macros

### A few Definitions and Common Conventions

**MPI** - stands for Message Parsing Interpreter and has it's own wikipedia page **[1]**.

**Prop or prop** - stands for property, a definable, well property of an object. Object properties may be viewed by typing ex $object name = /

**Propdir or propdir** - a "directory" of properties, kind of like a computer file folder

**Code** - the use of the code tag to indicate commands or MPI code

**$** - indicates a placeholder that you should replace with your value

### Functions

Functions are what comprises the "commands" that are available and also the ability to extend that using user defined functions (Macros). As mentioned briefly mentioned elsewhere, user functions follow this form:

_msgmacs/$function name:$function code that uses other mpi functions

_msgmacs/ is a propdir where user defined functions may be placed. When placed there, the functions may be used by or in the object/thing that contains them like this {$function name:$arguments} rather than simply using {eval:$prop name, $prop location} when code is placed in other properties. This is good for creating softcoded systems like weather and message boards among other To illustrate i've provided an example of a function below that I created to do exponents, or powers, of a number.

/_msgmacs/exp:{if:{and:{isnum:{:1}},{isnum:{:2}}},{if:{eq:{sign:{:2}},-1},{&how} {lit:{EXP}}: negative exponent,{if:{eq:{:1},},{&how} {lit:{EXP}}: Too few arguments,{if:{or:{eq:{:2},},{eq:{:2},0}},1,{with:i,{div:{:1},{:1}},{with:n,{:2},{for:x,0,{subt:{&n},1},1,{set:i,{mult:{:1},{&i}}}}}}}}},{&how} {lit:{EXP}}: Invalid number\, arg1/arg2}

Now, we'll analyze how this works. This one happens to be stored in _msgmacs/ on my character, so I can actually type @mpi {exp:10,3} and get 1000 back. That is to say that the function did the mathematics of 10^3 or raising 10 to the third power (10 x 10 x 10) and got 1000. It only takes two variable, the first is the number to be raised and the second is the power to raise it by. This is accomplished by using the standard MPI multiplication and division functions {mult} and {div} and some other math functions as well as a {with} loop. Their input parameters, or values, while beyond the scope herein are noted in the MPI Documentation in these help pages. Still, they are important to this code. While this function has some limits where it becomes inaccurate beyond them, ie 10^9 works and 10^10 doesn't, it provides an example of how MPI functions work. It also utilizes variable and returns error messages that are formatted like those MPI usually returns.