HOME

TheInfoList



OR:

TScript is an
object-oriented Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of ...
embeddable
scripting language A scripting language or script language is a programming language that is used to manipulate, customize, and automate the facilities of an existing system. Scripting languages are usually interpreted at runtime rather than compiled. A scripti ...
for C++ that supports hierarchical transient typed variables (TVariable). Its main design criterion is to create a scripting language that can interface with C++, transforming data and returning the result. This enables C++ applications to change their functionality after installation.


Hello world example

The basic "Hello World!" TScript example. CTScript ts; ts.SetParameter(CTScript::SOURCE_STRING,0,TEXT("main()")); ts.ExecuteStaticMethod();


TVariables

The standard variable can be formed as fixed data such as a Boolean, Integer or Decimal and a variable length variable such as an ASCII string, wide character string or a binary string. The type of the data can be used to define variable or the type can be explicitly declared, so for example the code - will create a variable called and assign it the value of zero. An Integer type can also be declared as - and its default value will be set to zero. TVariable are hierarchical in nature and are very similar to
XML Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. ...
,
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
and
PHP PHP is a General-purpose programming language, general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementati ...
variables. The TVariable type is also transient as an Integer can be changed into an AString by assigning it a string value or by casting the variable to an AString. For example, after an integer variable has been created and used, it can be reassigned by equating it to an AString. TVariables can also be used to hold an array of TVariables. Once a valid variable has been created, the array index subscripting notation can be used to transform it into an array, so for example the code - will create an array with four elements. The TVariable type for "list.type" will be that of a structure and each element of will be an Integer. Class in TScript are similar to array in how TVariable handle them, but use strings as array scriptures. For example, the code - will create a structured variable where list. Monday is true and is false. In the native C++ code, structured TVariable elements are accessible in C++ by - or by either or in native code.


Defined variables (classes)

Supporting hierarchical variables, TScript is able to store both primitive and complex variables within the same variable structure. This removes any requirement for any unique difference between primitives and structured data, therefore making the class structure a logical grouping of functionality rather than data storage type. TScript implements concepts of inheritance and code encapsulation through defined variables. For example, the following code snippet show a defined variables and that supports a constructor. variable Bar variable Foo extends Bar public main()


Function declarations

Another striking feature of TScript is the function declarations, which use output parameters rather than
return value In computer programming, a return statement causes execution to leave the current subroutine and resume at the point in the code immediately after the instruction which called the subroutine, known as its return address. The return address is s ...
s, and provide syntactic support for these. The standard function in many procedural languages, following Algol, is of the form: :. In TScript this pattern has been changed to the form: :. This change has done two things, first it allows multiple output variables and secondly it changed the return statement to an error handling function. Allowing functions to have a list of input and output variables that are separated by the semi column ":", changed the normal flow of how the function are called and used. This removes some of the need for using reference pointers to return multiple variables that is common in C/C++, and the use of references in most other scripting languages is actually prevented, forcing the use of a structure or array to return multiple values. The second noticeable thing about the calling conventions is that now all functions have an integrated error handling purpose similar to and of C++ and Java. In TScript since all functions return an error, the return statement operates similar to the throw statement. For example, the statement:- return error = "Have an error message"; will terminate the function and return the error message. Alternatively the blank statement;- return; will terminate the function but not return any error.


Example of multiple return values

public TextExtent(WString text : Integer width, Integer height)


Shorthand notation

For convenience TScript offers a shorthand function calling in the situation where there is only one returned variable. This notation of will substitute the case of . This short notation prevents the calling code from catching any errors and they will automatically be return to the parental calling code.


Error handling

Error handling in many other languages is done through the use of exceptions. TScript uses a similar process of error handling,TScript Documentation - Error Handling
/ref> although slightly different. TScript has a global error variable similar to the traditional
errno errno.h is a header file in the standard library of the C programming language. It defines macros for reporting and retrieving error conditions using the symbol errno (short for "error number").International Standard for Programming Language C ...
in C, although the error variable in TScript is capable to holding both an error code and a detailed error message. In many languages that use the syntax the error is returned via the catch statement and this can make the operational flow of the code awkward in situations where some errors are recoverable. TScript uses the notation that allows calling code to filter the error, potentially recovering from the error and returning to normal operation, or returning the error to its own calling function.


Example of return and handling errors

function() public main()


Run-time linking

C++ supports
function overloading In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different implementations. Calls to an overloaded function will run a specific implementation of that f ...
, which enables functions to have the same name while being differentiated by their input parameters. This causes TScript an issue while supporting loose type variables, as there is no way to tell what the type of a variable is until the software is being executed. To counter this problem, TScript has been written with run-time linking. This is when the particular function called is dependent on the type of the variables when the function is called. This is an unusual tactic that has some additional benefits. First it means that there is no need to declare functions before they are used, for example in C++ two functions may call one another, like and . In this situation, the needs to be prototyped in order for the to call it. TScript's run-time linking means the functions can be declared in any order without the need to prototype. This can make writing code much easier for less experienced programmers, allowing them to focus on the logic of the software and not the requirements of the language. Run-time linking also enables the language to support run-time coding with methods like and . This enables TScript programs to write themselves. For example, when using the
SOAP Soap is a salt of a fatty acid used in a variety of cleansing and lubricating products. In a domestic setting, soaps are surfactants usually used for washing, bathing, and other types of housekeeping. In industrial settings, soaps are used ...
interface, the remote
WSDL The Web Services Description Language (WSDL ) is an XML-based interface description language that is used for describing the functionality offered by a web service. The acronym is also used for any specific WSDL description of a web service (also ...
will be encoded into the script library, allowing the functions within to be called as if they were coded at design time. Additionally it is also possible to write code that can learn for itself, writing new functions when it needs it.


Dynamically linking libraries

TScript is among a small group is scripting languages that provide the functionality to dynamically load and link to existing shared libraries. Java through its JNI and VB6 are two other scripting languages that enable code to be written that would load a third party library and execute through its native interface. This gives TScript the ability to use a wealth of pre-existing functionality and code written in different languages and this can be done without any need to change the shared library's interface or to be compiled with the source code.


Memory management

TScript uses the standard C++ class encapsulation to allocate and de-allocate memory resources. This means that all allocated memory is released when the variable containing it is destroyed and operated differently from the Garbage Collection model of Java or the reference counting model of .NET languages. Operation system resources such as files, sockets and encryption keys are managed via a reference counting mechanism similar to .NET, so they will be released as soon as there are no variables containing their values.


Pro-active security

With the ability to load existing shared libraries, script can access all privileges granted to the user who executes it. To guard against malicious code, all resources beyond the basic memory allocation are required to be granted to each script. This also includes the ability to use message boxes to prompt the user, read and/or write access to any file or directory, or using the Internet connection. This security architecture is designed to allow the running of scripts in a similar way to
JavaScript JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
while enabling the usefulness of more powerful scripting languages like
PERL Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
.


References

{{Reflist


External links


Introduction to TScript
Scripting languages Interpreters (computing)