Skip to content

Native Functions

Frederik Tobner edited this page Jan 15, 2023 · 14 revisions

I/O

append_to_file

Appends the content of the second argument to the file located at the path specified with the first argument

append_to_file("D:/docs/test.txt", "Hello File!");

read_file

Reads the content of a file and stores it in a cellox string

var file = read_file("D:/docs/test.txt");

read_line

Reads the next line of characters from the standard input stream

var input = read_line();

printf

Prints the value to the standard output

printf(5);

Can also be used with placeholders

printf("The first:{} The second:{}\n", 5, 10);

write_to_file

Writes the content of the second argument to the file located at the path specified with the first argument

write_to_file("D:/docs/test.txt", "Hello File!");

Miscellaneous

exit

Terminates the process immidiatly and returns the specified exit code

exit(64);

random

Returns a random number

var number = random();

strlen

Returns the length of a string

var length = strlen("Cellox");

system

Envokes a system call

system("pwd");

System Info

on_linux

Returns true if the interpreter is executed under linux

if(on_linux()) // doing something

on_macOS

Returns true if the interpreter is executed under macOS

if(on_macOS()) // doing something

on_windows

Returns true if the interpreter is executed under windows

if(on_windows()) // doing something

Time

clock

Returns the amount of seconds that have passed since the program execution has started

var expiredTime = clock();

Threads

wait

Suspends the current thread for the specified number of seconds

wait(5);

Type conversions

asci_to_num

Converts a single character string to a numerical value

asci_to_num("F"); // 70

num_to_asci

Converts a numerical value to a asci character

num_to_asci(70); // "F"
Clone this wiki locally