Functionality

Functionality is an esoteric programming language written by User:Dominicentek with the goal being having the most functionality as possible.
== Instructions ==
 Variable Management 
Instruction	Syntax 	Description
var 	<varname> <value>	Creates a new variable (if not created) and sets a value to it
del 	<varname> 	Removes a variable
tonum 	<varname> 	Converts a string to a number
tostr 	<varname> 	Converts a number to a string
 Control Flow
Instruction	Syntax 	Description
if 	<value> <operator> <value>	Executes a code block if the condition is met
else 	 	If an IF statement fails, it executes this code block instead
loop 	<value> 	Loops code block n times
function 	<function name> 	Creates a new function
call 	<function name> 	Calls a function
while 	<value> <operator> <value>	Loops code block if the condition is met
exit 	 	Exits the program
 Console IO
Instruction	Syntax 	Description
output 	<value> 	Outputs value to a console
input 	<varname>	Stores console input to a variable
 Graphical Output
Instruction 	Syntax 	Description
initializegfx	<width> <height> 	Initializes graphical output
closegfx 	 	Closes graphical output
drawarc 	<x> <y> <width> <height> <start angle> <arc angle> [thickness]	Draws an arc
drawstring 	<x> <y> <value> [fontname] [fontsize] 	Draws a string/number
drawline 	<x1> <y1> <x2> <y2> [thickness] 	Draws a line
drawoval 	<x> <y> <width> <height> [thickness] 	Draws an oval
drawrect 	<x> <y> <width> <height> [thickness] 	Draws a rectangle
drawroundrect	<x> <y> <width> <height> <roundness> [thickness] 	Draws a round rectangle
fillarc 	<x> <y> <width> <height> <start angle> <arc angle> 	Fills an arc
filloval 	<x> <y> <width> <height> 	Fills an oval
fillrect 	<x> <y> <width> <height> 	Fills an rectangle
fillroundrect	<x> <y> <width> <height> <roundness> 	Fills a round rectangle
setbg 	<r> <g> 	Sets background color
setfg 	<r> <g> [a] 	Sets foreground color
 String Management (these all begin with string instruction)
Instruction	Syntax 	Description
substring 	<varname> <value> <begin> <end> 	Gets a substring of a value and stores it to a variable
charat 	<varname> <value> <index> 	Gets the character at an index of a value and stores it to a variable
length 	<varname> <value> 	Stores length of a value into a variable
insert 	<varname> <value> <index> <insertion>	Inserts a string into another string to an index and stores it to a variable
replace 	<varname> <value> <index> <char> 	Replaces a character in a string and stores it to a variable
combine 	<varname> <value> <value> 	Combines two values together as a string and stores it to a variable
remove 	<varname> <value> <begin> <end> 	Removes a section of a string and stores it into a variable
indexof 	<varname> <value> <char> 	Stores the index of a character in a string to a variable
tocode 	<varname> <char> 	Converts a char into an ASCII code and stores it to a variable
fromcode 	<varname> <value> 	Converts a number to a char based on its ASCII code and stores it to a variable
 Array Management (these all begin with array instruction)
Instruction	Syntax 	Description
create 	<array> [capacity] 	Creates a new array
delete 	<array> 	Deletes an array
subarray 	<dest> <source> <begin> <end>	Gets a subarray of an array
get 	<array> <varname> <index> 	Stores a value from an array into a variable
set 	<array> <value> <index> 	Stores a value from a variable into an array
length 	<array> <varname> 	Stores the length of an array into a variable
insert 	<array> <value> <index> 	Adds a value into an array at specific index
add 	<array> <value> 	Adds a value to an array
remove 	<array> <index> 	Removes an element at an index
indexof 	<array> <varname> <value> 	Stores an index of an element to a variable
 Filesystem IO
Instruction 	Syntax 	Description
fscreatefile	<path> 	Creates a new file
fscreatedir 	<path> 	Creates a new directory
fsdelete 	<path> 	Removes a file/directory
fscopy 	<source> <dest folder>	Copies a file/directory
fsmove 	<source> <destination>	Moves a file/directory
fsread 	<varname> <path> 	Reads from a file and stores it into a variable
fswrite 	<path> <value> 	Writes a string into a file
Values support:
* Math expressions (cannot contain space)
:* x+y Addition
:* x-y Subtraction
:* x*y Multiplication
:* x/y Division
:* x%y Modulo
:* x^y Power
:* x&y Bitwise AND
:* x|y Bitwise OR
:* x~y Bitwise XOR
:* ~x Bitwise REVERSE
:* !x Bitwise NOT
:* x<y Bitshift to left
:* x>y Bitshift to right
:* Brackets are also supported
* Number constants
* Variables (getting values from them)
* String constants (have to be in "")
Comparsion operators can be:
* == Equal to
* != Not equal to
* < Less than
* > Greater than
* <= Less than or equal to
* >= Greater than or equal to
=== Notes ===
* Code blocks are opened with [ and closed with ]
* Numbers are 64-bit signed integers
* If a string or array indexof fails, it stores a -1
== Examples ==
=== Hello World ===
output "Hello, World"
=== Truth Machine ===
input inp
tonum inp
if inp == 0 [
 output 0
]
else [
 while 0 == 0 [
 output 1
 ]
]
=== Brainfuck Interpreter ===
This proves that this programming language is Turing complete
input code
string length len code
var index 0
array create cells 256
var pointer 0
while index < len [
 string charat char code index
 if char == "<" [
 var pointer pointer-1
 if pointer == -1 [
 var pointer pointer+1
 ]
 ]
 if char == ">" [
 var pointer pointer+1
 if pointer == 256 [
 var pointer pointer-1
 ]
 ]
 if char == "+" [
 array get cells value pointer
 var value value+1
 if value == 256 [
 var value value-1
 ]
 array set cells value pointer
 ]
 if char == "-" [
 array get cells value pointer
 var value value-1
 if value == -1 [
 var value value+1
 ]
 array set cells value pointer
 ]
 if char == "." [
 array get cells value pointer
 string fromcode value value
 output value
 ]
 if char == "," [
 input charinput
 if charinput == "" [
 var value 10
 ]
 else [
 string charat charinput character 0
 string tocode value character
 ]
 array set cells value pointer
 ]
 if char == "[" [
 array get cells value pointer
 if value == 0 [
 var i index
 var layer 0
 while i < len [
 string charat code character i
 if code == "[" [
 var layer layer+1
 ]
 if code == "]" [
 var layer layer-1
 ]
 if layer == -1 [
 var index i
 ]
 var i i+1
 ] 
 ]
 ]
 if char == "]" [
 array get cells value pointer
 if value != 0 [
 var i index
 var layer 0
 while i >= len [
 string charat code character i
 if code == "]" [
 var layer layer+1
 ]
 if code == "[" [
 var layer layer-1
 ]
 if layer == -1 [
 var index i
 ]
 var i i-1
 ] 
 ]
 ]
 var index index+1
]
== Interpreter ==
* Cancelled
"Maybe one day I will make interpreter for it." Dominicentek (talk) 20:11, 22 August 2021 (UTC)
Category:Unimplemented
Category:Turing complete
Category:2021
Category:Languages