This is the portable version of the TeaScript (Standard) Host Application for 64 bit Linux (Ubuntu 22.04). 
The purpose is to run and execute script files written in the TeaScript language.

Please, read also the LICENSE.TXT for usage conditions and permissions.

You don't need to install the software before usage. 
But for convenience reasons an installation instruction is provided below.


Table of Contents
==================================
- Usage without installation
- Manual installation
- TeaScript programming
- Contact / Support
- Core Library
- Known Issues



=== Usage without installation ===
----------------------------------

Note: On Ubuntu 22.04. everything on the system for use TeaScript should be present already.
      If not and for other Linux distributions: The TeaScript binary needs libstdc++.so.6.0.30 or newer.

First you must unpack all files (the complete package) to any destination. Then

a) execute <package root>/bin/TeaScript for launch the interactive shell.
   Ctrl+C will quit the applicaton, or when type :q and pressing enter.
   
   :help <enter> will show a list of internal commands, e.g., use :ls vars for list all 
   variables and functions available in the toplevel scope.
   
   Entered text without a starting colon will be interpreted as TeaScript syntax and will be parsed + evaluated.
   
b) Invoke <package root>/bin/TeaScript with a filename which shall be executed, e.g.:
   ./bin/TeaScript examples/corelibrary_test01.tea
   


=== Manual installation ===
---------------------------

When doing a manual installation you are able to run and execute TeaScript files (*.tea) 
as well as to pass arbitrary parameters to TeaScript files.

1. Copy the complete unpacked TeaScript folder to a destination of your choice, e.g.
   /opt/TeaAgeSolutions/
2. All your TeaScript files must start with the following line (shebang):
   #!/opt/TeaAgeSolutions/TeaScript/bin/TeaScript

After that you can invoke TeaScript files like the following example (passing 2 parameters to the script):

examples\gcd.tea 42 18

If you see the output 6 everything is working correctly.


=== TeaScript programming === 
-----------------------------

Information about how to program TeaScript can be found on the webpage:
https://tea-age.solutions

Also you may have a look at the provided example script files.


=== Contact / Support ===
-------------------------

This software is a pre-release.
The behavior, API/ABI, command line arguments, contents of the package,
usage conditions + permissions and any other aspects of the software and the package may change 
in a non backwards compatible or a non upgradeable way without prior notice with any new (pre-)release.

If you encounter bugs or problems, have feature wishes or any other question you may try to contact:

support@tea-age.solutions


=== Core Library ===
--------------------

Some (incomplete and probably outdated) documentation about the provided standard Core Library.
(On https://tea-age.solutions you will find published source code of the Core Library part written in TeaScript)

HINT: in interactive shell use command ':ls vars' for get a complete list of all present toplevel 
      variables and functions.

Variable Name           : Type              --> docu
-------------------------------------------------------------------------------------------
_version_major          :  i64              --> major version of TeaScript
_version_minor          :  i64              --> minor version of TeaScript
_version_patch          :  i64              --> patch version of TeaScript
_version_combined_number:  i64              --> combined version number for easily compare versions.
_version_build_date_time:  String           --> build date and time as string
_api_version            :  i64              --> version of Core Library API.
_init_core_stamp        :  f64              --> time stamp in fractional seconds from an unspecified time point during program start.
_exit_success           :  i64              --> exit code for indicating success (used especially for exit/_exit)
_exit_failure           :  i64              --> exit code for indicating failure (used especially for exit/_exit)
void                    : NaV (Not a Value) --> Convenience for can write 'return void' if function shall return nothing.
PI                      :  f64              --> The constant number PI


Func Name               : Signature         --> docu
-------------------------------------------------------------------------------------------
_out                    : void ( String )   --> prints param1 (String) to stdout
_err                    : void ( String )   --> prints param1 (String) to stderr
print                   : void ( Any )      --> prints param to stdout, will do to-string conversion of the parameter.
println                 : void ( Any )      --> prints param + line feed to stdout, will do to-string conversion of the parameter.
readline                : String ( void )   --> read line from stdin (and blocks until line finished), 
                                                returns the read line without line feed.
_exit                   : void ( i64 )      --> exits the script (with stack unwinding/scope cleanup) with param1 exit code. 
                                                (this function never returns!)
exit                    : void ( Any )      --> same as _exit but will do to-number conversion on the parameter.
_strtonum               : i64|Bool ( String ) --> converts a String to i64. Returns Bool(false) on error. 
                                                This works only with real String parameters. alternative for '+str'.
_strtonumex             : i64|f64|Bool (String) --> converts a String to i64 or f64, Bool(false) on error. 
                                                This works only with real String objects.
_numtostr               : String ( i64 )    --> converts a i64 to String. this works only with real i64 parameters. 
                                                Alternative for 'num % ""'
_f64toi64               : i64 (f64)         --> converts a f64 to i64. same effect as trunc() but yields a i64.
to_string               : String (val: Any) --> converts val to string (note: if val is an integer _numtostr is an alternative)
to_number               : i64|f64|Bool (Any)--> converts val to a Number. returns Bool(false) on error. 
                                                (note: if val is a String _strtonum / _strtonumex is an alternative)
_eval                   : Any ( String )    --> parses and evaluates the string as TeaScript code and returns its result.
eval_file               : Any ( String )    --> parses and evaluates the content of the file and returns its result. 
                                                All defined functions and variables in the top level scope will stay available.
fail_with_message       : void ( String, i64 )  --> prints String to stderr, exits the script (with stack unwinding/scope cleanup) 
                                                with the i64 error_code. (this function never returns!)
clock                   : f64 ( void )      --> gets the local wall clock time of the current day in (fractional) seconds as f64.
clock_utc               : f64 ( void )      --> gets the UTC time of the current day in (fractional) seconds as f64. 
                                                (note: This UTC time is with leap seconds!)
_timestamp              : f64 ( void )      --> gets the elapsed time in (fractional) seconds as f64 from an unspecified 
                                                time point during program start. Time is monotonic increasing.
sleep                   : void ( i64 )      --> sleeps (at least) for given amount of seconds.
random                  : i64 ( i64, i64 )  --> creates a random number in between [start,end]. start, end must be >= 0 and <= UINT_MAX.

min                     : Any ( Any, Any )  --> returns the minimum of a and b
max                     : Any ( Any, Any )  --> returns the maximum of a and b
clamp                   : Any ( val: Any, low: Any, high: Any ) --> returns low if val is less than low, high if val is greater
                                                than high, otherwise val. garbage in, garbage out.
swap                    : Any ( Any, Any )  --> swaps the values of a and b (a and b are passed via shared assign)
abs                     : Number ( Number ) --> returns the absolute value of n (as same type as n). n must be a Number.
trunc                   : f64 ( Number )    --> rounds the given Number towards zero as f64. 
                                                e.g. 1.9 will yield 1.0, -2.9 will yield -2.0.
floor                   : f64 ( Number )    --> rounds down the given Number to next smaller integer as f64. 
                                                e.g. 1.9 will yield 1.0, -2.1 will yield -3.0
ceil                    : f64 ( Number )    --> rounds up the given Number to next greater integer as f64. 
                                                e.g. 1.1 will yield 2.0, -1.9 will yield -1.0
round                   : f64 ( Number )    --> rounds up or down the given Number to nearest integer as f64.
                                                e.g. 1.1 will yield 1.0, 1.6 as well as 1.5 will yield 2.0
pow                     : f64 ( Any, i64 )  --> computes power of input with integer exponent. if exp is a float it will get truncated. 
                                                returns a f64. (will do to-number conversion on input)
sqrt                    : f64 ( Any )       --> computes the square root of given input (will do to-number conversion on input).
timevals                : Bool ( t: f64, HH: i64, MM: i64, S: i64, ms: i64 ) --> computes the hour, minute, second 
                                                and (optionally) millisecond part of given time in seconds (e.g. from clock())
                                                note: hours can be greater than 23/24, it will not be cut at day boundary!
timetostr               : Bool|String ( t, with_ms: Bool ) --> builds a 24 hour wall clock string with the 
                                                format HH:MM:SS.mmm (milliseconds are optional)
                                                note: if t is greater than 24 hours it will not be cut.
rolldice                : i64 ( eyes: i64 ) --> randomly rolls the dice and returns the result.                                                   

"minimalistic string support"
_strlen                 : i64 ( String )    --> returns the length of the string in bytes (excluding the ending 0).
_strglyphs              : i64 ( String )    --> returns the utf-8 (Unicode) glyph count of the string (excluding the ending 0).
_strat                  : String ( String, i64 ) --> returns a substring of one character at given position. 
                                                empty string if out of range.
_substr                 : String ( String, from: i64, count: i64 ) --> returns a substring [from, from+count). 
                                                count -1 means untl end of string. returns empty string on invalid arguments.
_strfind                : i64 ( String, substring: String, offset: i64 ) --> searches for substring from offset and 
                                                returns found pos of first occurence. -1 if not found.
_strfindreverse         : i64 ( String, substring: String, offset: i64 ) --> searches for substring from behind from offset and 
                                                returns found pos of first occurence. -1 if not found.
_strreplacepos          : Bool ( str: String, start: i64, count: i64, new: String ) --> replaces the section [start, start+count) 
                                                in str with new. returns false on error, e.g. start is out of range.
strreplacefirst         : Bool ( str: String, what: String, new: String, offset: i64 := 0 ) --> replaces first occurence of what
                                                with new starting from offset. returns true if a replacement happen.
strreplacelast          : Bool ( str: String, what: String, new: String, offset: i64 := 0 ) --> replaces last occurence of what 
                                                with new starting from offset. returns true if a replacement happen.
strtrim                 : Bool ( str: String, set: String, leading: Bool, trailing: Bool ) --> trims the string if it starts or ends 
                                                with characters in given set. note: set must be ASCII only!

"minimalistic (text) file io support" (Note: text files must be UTF-8 encoded!)
cwd                     : String ( void )   --> returns the current working directory as String
tempdir                 : String ( void )   --> returns configured temp directory as String
file_exists             : Bool ( String )   --> returns whether the given file exists.
file_size               : i64 ( String )    --> returns file size in bytes. -1 on error / file not exists.
readtextfile            : String|Bool ( String ) --> reads the content of an UTF-8 text file and returns it in a String. 
                                                An optional BOM is removed.
writetextfile           : Bool ( file: String, str: String, overwrite: Bool, bom: Bool )  --> writes the content of Sring to 
                                                text file. An optional UTF-8 BOM can be written (last Bool param). 
                                                overwrite indicates if a prior existing file shall be overwritten (old content destroyed!)


=== Known Issues ===
--------------------

Please see Known_Issues.txt


