New Comment System@Siebel Unleashed.. Do Try and give me feedback | Next Tip »Home

Typecasting variables in ST Engine

OkAvarageGoodVery GoodExcellent (7 votes, average: 4.71 out of 5)
Loading ... Loading ...

I think most of Siebel 7.7.x and Siebel 7.8.x applications are ST enabled, by now in readiness to upgrade to Siebel 8.x as ST is the default script engine in Siebel 8.x. You wouldn’t want to upgrade to Siebel 8.0 and realize that most of your scripts are failing there. Though most of us have ST engine enabled for our applications but I don’t think many of us are completely utilizing its capabilities.

One of the main difference between ST and T engine is that in ST we can typecast our variables which helps improving performance and better memory management of application but typecasting of variables is optional not compulsory. So, even if I don’t typecast my variables my script will work.  This post intends answer questions given below:

  1. How do I typecast variables in ST engine?
  2. What types are available?
  3. Do I really need to typecast variables?
  4. Is there any downside of typecasting variables?

How do I typecast variables in ST engine?

The syntax of typecasting a variable is as following
var variablename : type; for example
var psIn : PropertySet;
In the above example I am typecasting “psIn” variable to be of  type PropertySet.

What types are available?

Below is the list of types that we can use in ST scripts. (This list may not complete please feel free to add to this list through comments, in case I have missed something.)

  • var bo : BusObject;
  • var bc : BusComp;
  • var ps : PropertySet;
  • var svc : Service;
  • var flag : bool;
  • var chrType : chars;
  • var intFloat: float;
  • var intNum : Number;
  • var str : String;
  • var boolObj: Boolean;

Do I really need to typecast variable?

Syntactically it is not necessary to typecast variables. ST engine can run on script using both typeless variable (using only var statement) and typecast variables (using appropriate type) but to make use of complete capabilities of ST engine you should consider typecasting at least variables that will store objects such as Business Objects, Business Components, Business Service etc.

 Is there any downside of typecasting variables?

Surprisingly the answer of this question is Yes, there is downside. Typecasting variables to String and Number does have an impact as you cannot compare two different data types. For example

var fnum = “10”;
var snum = 10;
if(fnum == snum)
   return(1);
else
return(0);

 Above statement will return 1 because when you don’t typecast your variables then an implicit conversion takes place but if I change my code to:

var fnum : String;
fnum = “10”;
var snum : Number ;
sunm = 10;
if(fnum == snum)
return(1);
else
return(0);

Then comparison will fail and it will return 0 as you cannot compare a “String” and a “Number” type which means that typecasting your variable can cause lot of “if” conditions to fail.

Also it has been observed that typecasting variables to “String” and “Number” can have adverse impact on performance. So, it is better to take middle path which is to typecast variables that will store objects types such as Property Sets, Business Objects and Bus Components and leave your other variables as it is.

Please feel free to express your thoughts!

  • Share/Bookmark

Related Posts


Article by neel

Authors bio is coming up shortly. neel tagged this post with: Read 387 articles by neel
  • A pleasure to read, thanks Neel.
  • Hi @lex,

    Great tip .. I can see many types that I had no idea are available such as RegExp which I think stands for Regular Expression.

    Going to play with these new types and see what they are capable of
  • Kantesh Guttal
    One word: Excellent!
  • Nice post,

    to complete the list of available data types, simply enter "var test :" and press CTRL+SPACE in your eScript editor window ;-)

    have a nice day

    @lex
blog comments powered by Disqus

Polls

Do you like the new Comment System and new look to Site?

View Results

Loading ... Loading ...