【中文版】

Introduction

MFP language introduction

MFP functions

all functions

integer operation

logic functions

statistic and stochastic

trigononmetric functions

exponential functions

complex number

system functions

array or matrix

graphic functions

expression and calculus

string functions

hyperbolic trigononmetric

sorting functions

polynomial

signal processing

file operation

time and date

graphic display

multimedia functions

data structure

data interchange format

platform and hardware

parallel computing

RTC multimedia

reflection

MFP compiling

others

deploy user functions

call MFP in your app

build Android APK

game programming

chart plotting

MFP math analysis

MFP file procession

number string and array

time date and system

Introduction of SCP

Scientific Calculator Plus Help : system functions

Function name Function info
input

::mfp::io::console::input(3) :

input(prompt,input_type,default_value) prints string prompt on the console and waiting for user to input. The second parameter, input_type, and the third parameter default_value, are optional. At this stage if the second parameter exists and it is string "s" or "S", user's input is looked on as a string and this function returns the string. If the second and third parameter exist and the second one is "default" or "DEFAULT", then the third parameter will be the default value. And the default value is used when user just press ENTER or blanks in input. Otherwise, input is treated as an expression and this function returns the value of the expression. If input is not a valid expression, this functions will reprint the prompt and wait for user to input again. An input is finished by press ENTER key. If multiple lines are input, only the first line is read. For example, user runs input("$", "S"), then types 4 + 3 after prompt, presses ENTER, this function returns a string "4 + 3". If user runs input("%"), then type 4 + 3 after prompt, presses ENTER, this function returns 7. If user runs input("#", "default", "e"), then type space after prompt, presses ENTER, this function returns "e".

pause

::mfp::system::pause(1) :

pause(message) suspends current running program waiting for an enter input by user. Message, which is a string and is optional, will be printed on screen as a prompt if provided.

print

::mfp::io::console::print(1) :

print(x) prints the value of x to output, x can be any value type.

print_line

::mfp::io::console::print_line(1) :

print_line(x) prints the value of x to output and then start a new line, x can be any value type and is optional. By default its value is "".

printf

::mfp::io::console::printf(1...) :

printf(format_string, ...), sprintf(format_string, ...) and fprintf(fd, format_string, ...) work like corresponding C/C++ functions. Function printf prints formatted string constructed from format_string and other parameter values to output console, sprintf constructs a new string from format_string and other parameters, and returns the new string, fprintf prints the formated string from format_string and other parameter values to the text file whose id is fd. The format_string parameter supports integer (%d, %i, %x, etc), float (%e, %f, etc), character(%c), string(%s) etc. User can find detailed information for construction of a format string by reading C language manual for these functions. For example, printf("Hello world!%f", 3.14) will output "Hello world!3.140000" on the screen, sprintf("%c%d", "A", 9) returns "A9" (MFP does not support single character type, so single character is stored as a one-char string).

scanf

::mfp::io::console::scanf(1) :

scanf(format_string), sscanf(input_from, format_string) and fscanf(fd, format_string) work like corresponding C/C++ functions. Function scanf reads one line input from user, sscanf reads string based parameter input_from, and fscanf reads content from a file whose id is fd. The format_string parameter supports integer (%d, %i, %x, etc), float (%e, %f, etc), character(%c), string(%s) etc. User can find detailed information for construction of a format string by reading C language manual for these functions. Different from C language, these functions do not accept additional parameters to store read values. These functions simply return all the read values in an array. For example, sscanf("3Hello world!", "%d%c%c%s") will returns [3, "H", "e", "llo"] (MFP does not support single character type, so single character is stored as a one-char string).

sleep

::mfp::system::sleep(1) :

sleep(x) suspends processing for positive real value x milliseconds. It returns nothing.

system

::mfp::system::system(1) :

system(str_or_array) has one parameter which is either a string or an array with string elements. If the parameter is a string, it runs the string based OS command and returns the value that the OS command returns. Note that the command should be an executable file with its parameters. Like system("dir") in windows cannot be executed because dir is an internal function of cmd.exe. User should use system("cmd /c dir") instead. If the parameter is an array, then each element in the array should be a part of a OS command and system function will run the OS command. For example, in Linux if user wants to rename file1 to file2, the full OS command should be "sh -c mv file1 file2", where "sh -c" cannot be omitted because we are not in a shell. So to call system function in the right way, user should write system(["sh", "-c", "mv file1 file2"]) because "mv file1 file2" is an internal command for sh which cannot be seperated into several parts. Also note that at this stage, user can only see any output from the running command but cannot input after the OS command starts. If the command does not exist, throws an exception.