Difference between revisions of "Malical"
(→2. Variable, the expression) |
(→Variable, the expression) |
||
Line 92: | Line 92: | ||
a = a^2 | a = a^2 | ||
a = {} (A is an array, but there is not any element, use the array manipulation functions (such as the push) before such assignment). | a = {} (A is an array, but there is not any element, use the array manipulation functions (such as the push) before such assignment). | ||
+ | |||
+ | ==The control structure== | ||
+ | Malical offers two control structures: | ||
+ | ===IF statement=== | ||
+ | <pre>if con | ||
+ | stmt | ||
+ | [else | ||
+ | stmt] | ||
+ | end | ||
+ | </pre> | ||
+ | |||
+ | Which else part is optional, the type of con must be a number (0 for false, non-zero is true) | ||
+ | |||
+ | ===WHILE statements=== | ||
+ | <pre>while con | ||
+ | stmt | ||
+ | end | ||
+ | com | ||
+ | </pre> | ||
+ | |||
+ | The requirements of the if statement | ||
+ | |||
+ | ===Functions=== | ||
+ | Defined functions in the following ways in Malical | ||
+ | <pre>:: <Function name> <parameter list> | ||
+ | <Statement> | ||
+ | :: End </pre> | ||
+ | |||
+ | Such as: | ||
+ | <pre>:: double [x] | ||
+ | return x*2 | ||
+ | :: End</pre> | ||
+ | |||
+ | Return which return a value, if not followed by the expression, then do not return any value, but will end the execution of the function. |
Revision as of 17:46, June 6, 2012
This page needs your knowledge
|
Contents
What is Malical?
Malical is a powerful language for casio fx9860 series that combines the facility of the Casio Basic with the speed and robustness of C/Asm.
The currently malical version is 2.5, but the developers, Diameter and Wudy.F89 are working in a new update (3.0) with more functions!
Vantages of using Malical
This language is more faster than LuaFx, and you can program OnCalc. Other vantage face to LuaFX is that the malical program files do not need to be compiled!
Furthermore this language has the speed and robustness of C/Asm but is more easy to learn! You can use some tipical SDK functions like print mini, overclock, rtc, ... using this language!
Getting Started
You can download the latest malical build here, and you can discuss about this project in this forum topic.
Install Malical on Calc
Please connect the calculator to the computer, and drag and drop the the file MALICAL2.G1A, to the FA-124 like the image below:
Then copy MALICAL2.G1A to your 9860 calculator.
In order to edit Malical Source files(*.mcl) on your fx9860 calc, you need download EDIT.G1A. Of course, you can edit the source files on the computer, it is plain text.
After the installation is complete, you should see the following interface:
Making a Hello world!
Please open the EDIT to create a new document in Storage Mem with the extension .MCL (Warning: You should not create this file in Main Mem).
And write this code in the file:
::main locate[1][1] print ["Hello world!"] waitkey[30004] ::end
(PS: the edit can adjust the font size, and small print on the screen for you can see more code, it is recommended to use small print, set the font size optn other Word the wrap also recommended the election off, as shown below)
Input as follows
Exit Edit and open Malical:
Run the program and calc will display the following screen:
Press the exe to exit!
First in TEST.MCL we define the main function (each Malical are the main function as a starting point), use the locate function (used for positioning the string output location), the print function (output string) and waitkey function ( of which 30004 exe key code). If you do not waitkey, the program will flash off (can be removed to try). waitkey the role, the program waits until the user presses the 30004 on behalf of the keys.
Variable, the expression
Malical, var <variable table ...> (for example: var [a] [b] [c]) to declare a variable. (Some language) Malical variable type, the only type of the value of the variable. During operation variable can be assigned to any type of value. Variables declared outside the function is a global variable can be shared, global declared within the function can only be used during the function call. The value of the type:NIL, STRING, NUMBER, ARRAY.
NIL type
Malical using nil represents a null value nil is the unique value of NIL type
STRING type
String.
Example: "Hello World!", "12332132adasd
Supported operators: + ==
NUMBER type
Floating-point number Example: 0.1321、3.1415926 Supported operators:+ - * / ^ %(Modulo) == > >= < <= and、or、not
ARRAY type
Data collection (array), in which each element value can be any type.
Array using the subscript ("[" "]") access. {Value table...} construct.
Example:
var [a] a = {[1][2][{}][ "mailcal"]} print [a[0]] # Output 1.000000
Malical in the assignment operator "=" Example: a = 1 a = a+1 a = a^2 a = {} (A is an array, but there is not any element, use the array manipulation functions (such as the push) before such assignment).
The control structure
Malical offers two control structures:
IF statement
if con stmt [else stmt] end
Which else part is optional, the type of con must be a number (0 for false, non-zero is true)
WHILE statements
while con stmt end com
The requirements of the if statement
Functions
Defined functions in the following ways in Malical
:: <Function name> <parameter list> <Statement> :: End
Such as:
:: double [x] return x*2 :: End
Return which return a value, if not followed by the expression, then do not return any value, but will end the execution of the function.