TScript Method Declarations

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

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

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

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

<method name>([input variables],... :[output variables],...)

This change has done two things, first it allows multiple output variables and secondly it changed the return statement to an error handling method.

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 method and return the error message. Alternatively the blank statement;- return; will terminate the method but not return any error.

Shorthand Notation

For convenience TScript offers a short hand method calling in the situation where there is only one returned variable. This notation of will substitute the case of method (: variable); for variable = method();. 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
  • TScript
public TextExtent(WString text : Integer width, Integer height){
   text = text.Fragment(u"\n");
   for(height = width = 0; height < text.length; height++){
      if(width < text[height].length) width = text[height].length;
   }
}
Listen All
Comments (0)
Characters left: 2500
 

Contact Ekky

Thanks for your interest.

Ekky Software Customer Support Team.

Ekky Software Product Range
Ekky Software Homepage T-Accounts Online ObjectDatabase++ TScript Ekky Software Homepage T-Accounts Onlinee ObjectDatabase++ TScript