TScript Function Declarations

Defined Variables are used to implement class functionality and allow users to create a structure that has predefined variables, constants and methods.

Standard function declarationin in many languages are usually in the form:-

[output variable] <function name>([input variable],...)

In TScript this pattern has been changed to a unique function declaration in the form:-

<function name>([input variable],... :[output variable],...)

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 and separate them by a semi column ":", has changed the normal flow of how the functions are called and used. The most noticeable thing about the calling conventions is that now all functions have an integrated error handling purpose similar to try{...}catch(...){...} and trow new Exception() 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.

Shorthand Notation

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

Example with multiple return values
public TextExtent(WString text : Integer width, Integer height){
   text = text.Fragment(L"\n");
   for(height = width = 0; height < text.length; height++){
      if(width < text[height].length) width = text[height].length;
   }
}
Comments
Characters left: 2500
 

Contact Ekky Software

Thank you for your time and interest.
Ekky Software Customer Support Team.

Ekky Software Product Range
Ekky Software Homepage Texas Business Software ObjectDatabase++ TScript Ekky Software Homepage Texas Business Software ObjectDatabase++ TScript