Node:Introduction, Previous:Top, Up:Top



1 Introduction

This document provides the API reference for X Language users.

1.1 What is X Language ?

This document describes the X Language program, a new multi-syntax programming including a portable set of APIs to create console or graphical applications runnable on many platforms (UNIX/X11, Win32, ...). X Language comes with an interpreter, a compiler and a debugger.

1.2 Copying

Copyright © 2001 Patrick Deschenes

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Patrick Deschenes.

2 Low-level API

2.1 Language

2.1.1 Conversion

string cvt_itos (int data) Function
Convert an integer to a string.

return Variable
Resulting string.

data Variable
Integer to be converted.

string cvt_ftos (float data, uint precision) Function
Convert a float to a string.

return Variable
Resulting string.

data Variable
Float to be converted.

precision Variable
Number of decimal to keep.

string cvt_dtos (double data, uint precision) Function
Convert a double to a string.

return Variable
Resulting string.

data Variable
Double to be converted.

precision Variable
Number of decimal to keep.

int cvt_stoi (string data) Function
Convert a string to an integer.

return Variable
Resulting integer.

data Variable
String to be converted.

float cvt_stof (string data) Function
Convert a string to a float.

return Variable
Resulting float.

data Variable
String to be converted.

double cvt_stof (string data) Function
Convert a string to a double.

return Variable
Resulting double.

data Variable
String to be converted.

2.1.2 Mathematic

double math_log (double v) Function
This function compute the natural logarithm of v.

return Variable
The result.

v Variable
The value to be computed.

double math_exp (double v) Function
This function compute e (the base of natural logarithms) raised to the power v.

return Variable
The result.

v Variable
Power value.

double math_pow (double v, double power) Function
Raise v to the power of power.

return Variable
The result.

v Variable
Value to be powered.

power Variable
Power value.

double math_sqrt (double v) Function
This function compute the square root of v.

return Variable
The result.

v Variable
Value to be squared root.

double math_sin (double v) Function
This function return the sinus of v.

return Variable
The result.

v Variable
Value to be compute.

double math_asin (double v) Function
This function return the arc sinus of v.

return Variable
The result.

v Variable
Value to be compute.

double math_cos (double v) Function
This function return the cosinus of v.

return Variable
The result.

v Variable
Value to be compute.

double math_acos (double v) Function
This function return the arc cosinus of v.

return Variable
The result.

v Variable
Value to be compute.

double math_tan (double v) Function
This function return the tagent of v.

return Variable
The result.

v Variable
Value to be compute.

double math_atan (double v) Function
This function return the arc tagent of v.

return Variable
The result.

v Variable
Value to be compute.

double math_atan2 (double y, double x) Function
This function computes the arc tangent of y/x.

return Variable
The result.

v Variable
Value to be compute.

2.2 System

2.2.1 Basic

void sys_exit (uint retcode) Function
This function terminates the process and return the specified code.

retcode Variable
Code to be returned.

void sys_setenv (string variable, string value) Function
Set the environment variable to a specific value.

variable Variable
Name of the variable.

value Variable
Value to be set.

string sys_getenv (string variable) Function
Get the environment variable value.

return Variable
Value of the environment variable.

variable Variable
Name of the variable.

2.3 I/O

2.3.1 Basic

void io_write (string text) Function
Write a string on the output stream.

text Variable
Text to be output.

void io_err_write (string text) Function
Write a string on the error stream.

text Variable
Text to be output.

void io_read (string text, uint size) Function
Read a text line from the input stream with a maximum of 'size' characters.

text Variable
Variable to receive the text.

size Variable
Number of maximum characters to read.

2.3.2 File

pointer io_file_open (string filename, uint mode) Function
Open a file.

return Variable
Pointer of the file being opened (== null if unable to open the file).

filename Variable
Name of the file to be opened.

mode Variable
  • IO_FILE_READ : Enable the file to be read.
  • IO_FILE_WRITE : Enable the file to be written.
  • IO_FILE_CREATE : Create the file if it does not exists.

void io_file_close (pointer fileid) Function
Close an opened file handle.

fileid Variable
A valid file handle.

void io_file_write (pointer fileid, string text) Function
Write a string to a file.

fileid Variable
A valid file handle.

text Variable
Text to write.

void io_file_read (pointer fileid, string text, uint size) Function
Read a string from a file.

return Variable
Number of characters really read.

fileid Variable
A valid file handle.

text Variable
A string variable to receive the text.

size Variable
Number of characters to be read.

bool io_file_is_eof (pointer fileid) Function
Check if the cursor is at the end of the file.

return Variable
True if at the end of the file.

fileid Variable
A valid file handle.

uint io_file_get_pos (pointer fileid) Function
Get the cursor position on the file.

return Variable
Position of the cursor.

fileid Variable
A valid file handle.

uint io_file_set_pos (pointer fileid, uint pos) Function
Set the cursor position on the file.

return Variable
The new poosition of the cursor.

fileid Variable
A valid file handle.

pos Variable
The desired position of the cursor.

uint io_file_get_size (pointer fileid) Function
Get the size of the file.

return Variable
Size of the file.

fileid Variable
A valid file handle.

2.3.3 Directory

string io_dir_get_current () Function
Get the current directory.

return Variable
Current directory.

void io_dir_set_current (string directory) Function
Set the current directory.

directory Variable
The new current directory.

void io_dir_create (string directory) Function
Create a directory.

directory Variable
The name of the directory to be created.

void io_dir_delete (string directory) Function
Delete a directory.

directory Variable
The name of the directory to be deleted.

pointer io_dir_open (string directory) Function
Open a directory to be read.

return Variable
The directory handle.

directory Variable
The name of the directory to be opened.

void io_dir_close (pointer dir_id) Function
Close a directory.

dir_id Variable
The directory handle.

string io_dir_get_next (pointer dir_id) Function
Get the next file/directory of a directory.

return Variable
The name of the file/directory. Return an empty string at the end.

dir_id Variable
The directory handle.

2.4 Networking

2.4.1 Basic

pointer net_open () Function
Create a new socket.

return Variable
Handle of the new socket.

void net_close (pointer socket) Function
Close a socket.

socket Variable
Handle of the socket being closed.

bool net_connect (pointer socket, string host, uint port) Function
Connect a new socket to an host at a specific port.

return Variable
True on success.

socket Variable
Handle of the socket.

host Variable
Address of the host (DNS or IP).

port Variable
To port to which to connect.

bool net_listen (pointer socket, uint port) Function
Listen a connection at a specific port.

return Variable
True on success.

socket Variable
Handle of the socket.

port Variable
Port to listen.

bool net_accept (pointer socket) Function
Listen a connection at a specific port.

return Variable
True on success.

socket Variable
Handle of the socket.

void net_write (pointer socket, string data) Function
Send data throught a socket.

socket Variable
Handle of the socket.

data Variable
Data to be sent.

void net_read (pointer socket, string data, uint size) Function
Read data from a socket.

socket Variable
Handle of the socket.

data Variable
Variable to receive the data being read.

size Variable
Size of the data to be read.

2.5 Screen

void scr_clear () Function
Clear the screen.

void scr_gotoxy (uint x, uint y) Function
Move the cursor at a specific position.

x Variable
X-coordinate position.

y Variable
Y-coordinate position.

uint scr_get_width () Function
Get the width of the screen.

return Variable
Width of the screen.

uint scr_get_height () Function
Get the height of the screen.

return Variable
Height of the screen.

void scr_set_fgcolor (uint color) Function
Set a specific foreground color.

color Variable
Foreground color.

void scr_set_bgcolor (uint color) Function
Set a specific background color.

color Variable
Background color.

2.6 Windowing