.. _reports_functions: Functions --------- These functions allow you to perform a whole series of operations, including: - string or list of strings processing, - text replacement, - object counting, - text file processing, - etc. These functions are executed within a report line and the result of the function is printed in the report output. They can be chained (e.g. `@upper(@ttitle(T1))` returns the title of the table named *T1* in uppercase). The general syntax of these functions is:: @function_name(arg1, arg2, ...) String management ~~~~~~~~~~~~~~~~~ - :ref:`@upper(text) `: converts text to uppercase - :ref:`@lower(text) `: converts text to lowercase - :ref:`@replace(string, from, to) `: substitutes one text for another - :ref:`@fmt(val, fmt) `: formats an integer - :ref:`@take(n, string) `: extracts the first n characters of string. If n is negative, extracts the last n characters. - :ref:`@drop(n, string) `: removes the first n characters of string. If n is negative, removes the last n characters. - :ref:`@count(string) `: returns the number of elements in string (separated by commas) - :ref:`@index(n, list) `: returns the nth element of list - :ref:`@sqz(string) `: removes spaces from string - :ref:`@strip(string) `: removes trailing spaces from string - :ref:`@ansi(text) `: converts an Ascii text to Ansi - :ref:`@equal(t1, t2) `: compares t1 and t2: returns 1 if equal, 0 otherwise - :ref:`@void(t1, ...) `: returns no text, whatever the arguments List of strings management ~~~~~~~~~~~~~~~~~~~~~~~~~~ - :ref:`@vtake(n, list) `: take the first n elements of the list (or last n elements if n is negative) - :ref:`@vdrop(n, list) `: drop the first n elements of the list (or last n elements if n is negative) - :ref:`@vcount(list) `: return the number of elements in the list File management ~~~~~~~~~~~~~~~ - :ref:`@fdelete(filename) `: deletes the file filename - :ref:`@fappend(filename, string|NL, ...) `: writes the text to a file Directory management ~~~~~~~~~~~~~~~~~~~~ - :ref:`@getdir() `: returns the current directory - :ref:`@chdir(dirname) `: changes the current directory to dirname and returns the new current directory - :ref:`@mkdir(dirname) `: creates a new directory dirname - :ref:`@rmdir(dirname) `: deletes the directory dirname Dates and times ~~~~~~~~~~~~~~~ - :ref:`@date([format]) `: returns the date - :ref:`@time([format])