you can define functions by "@functionname" within a file and call dem by "functionname" in the same file. There is no need to compile them. This usage is explained in the tutorial section by Shakey (Share/Tutorials/Beginner Tutorial Variables and Functions). I think that is easy to understand.
I will try to explain what it is with the compiled functions by way of example:
Suppose you miss a few functions in the Mathstudio commands. Suppose these are the functions "Convert number to a list of digits" and "Reverse the order of digits in a number". You want to use these function in many cases without having to reprogram them every time. In this case, you have to proceed as follows:
1) Create a new file with e.g. the name "MyTools". This file
contains the two functions:
L = char(string(n))-48
In both cases, the input value is a number ("
Number n"). In the first case, the output value is a list ("
Return (L)") and in the second case the output value is a Number ("
Return (r)"). The second function uses the first function. Both functions can be tested within the file "MyTools" e.g. by enter:
You can also do more complex functions with multiple inputs and outputs by writing:
@AnyFunction (a, b, c, d, e)
... do anything with a, b, c, d, e
... and compute x, y, z
Return (x, y, z)
In the concrete example, the story goes on as follows:
1) Save the file "MyTools" with the two tested functions. This
is the source code and the file is called "MyTools.math".
2) This source code is compiled as follows:
Mathstudio Menu / File / Evaluate all
Mathstudio Menu / File / Export scripts to include folder
File Icon / Compile scripts
3) In both cases, a so-called compiled file with name "MyTools.script" is generated (located in the "include folder" in case of Mac and in the same directory as MyTools.math in case of iOS).
4) Close the file "MyTools.math" and you are ready!
If you want to use the new functions in another file, then you proceed as follows:
a) Create any file, e.g. "Testfile"
b) At the beginning of this file you write:
c) After pressing "return" the function names "
d) These functions you can now use in "Testfile" like normal
e) For example:
NumToList (1234) or
So this is a elegant way, to expand Mathstudio to your own needs.
If you want to change the functions "NumToList" or "NumReverse" or want to add more features / other functions, then you have to make these changes in the source code "MyTools.math" and after that
- Save MyTools.math
- recompile again
Hope this helps …