100% found this document useful (1 vote)
181 views34 pages

Siebel eScript Syntax and Methods

This document provides an overview of eScript syntax including: - Data types are loosely typed and variables can change type dynamically. - Common operators include mathematical, conditional, logical, and assignment. - Variables are declared with var and can be initialized. - Decision making includes if/else, elseif, and switch/case statements. - Looping includes for, do/while, and while loops. - Functions can return values and be called. - Arrays can be manipulated through methods like getArrayLength(). - Important methods include new Date, Clib object methods, and file I/O. - Siebel objects like BusComp and BusObject can be used. - Error

Uploaded by

api-3762678
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
181 views34 pages

Siebel eScript Syntax and Methods

This document provides an overview of eScript syntax including: - Data types are loosely typed and variables can change type dynamically. - Common operators include mathematical, conditional, logical, and assignment. - Variables are declared with var and can be initialized. - Decision making includes if/else, elseif, and switch/case statements. - Looping includes for, do/while, and while loops. - Functions can return values and be called. - Arrays can be manipulated through methods like getArrayLength(). - Important methods include new Date, Clib object methods, and file I/O. - Siebel objects like BusComp and BusObject can be used. - Error

Uploaded by

api-3762678
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

Siebel Scripting, Part

Two
eScript Syntax
Introduction
 Data Types
 Declaring Variables
 Operators
 Decisions
 Looping
 Functions
 Arrays in eScript
 Some Important eScript Methods
 Using Siebel Objects
Comments in eScript
 Use two forward slashes // at the
front of a line to make a single line
comment
 Example:
//This is a single line comment
 Use /* to start and */ to end a
multi-line comment
 Example:
/*This Comment
stretches over
Data Types
 There ARE no data types in eScript
 eScript is a loose typed language
 Variables can change type
dynamically
 eScript is Case Sensitive
 var MyString and var mystring are
two DIFFERENT variables!
Operators
 Mathematical Operators
+, -, *, /, % (no exponentiation)
 Conditional Operators
==, !=, <, >, <=, >=
 Logical Operators
&&, ||, !
 Assignment
=
 Ternary
Condition ? Do If True : Do If False
Declaring Variables
 Syntax:
 var VarName;
 Examples:
 var iScore;
 var bcContact;

 Can
declare more than one variable of the
same type in one line:
 var sLastName, sFirstName;
 eScript Variables can be initialized:
 var sName = “Charlie”;
 var iCount = 1;
Decisions: if
 Syntax:
 if (Condition)
{
 ‘Code to be executed if Condition is True
}
 Example:
 if (iScore < 60)
{
 sGrade = “Fail”;
}
 Simple Decision Making Construct
Decisions: else
 Syntax:
if (Condition)
{
‘Code to Execute if Condition is True
}
else
{
‘Code to Execute if Condition is False
}
Decisions: else
 Example:
if (iScore < 60)
{
sGrade = “Fail”;
}
else
{
sGrade = “Passing”;
}
Decisions: elseif
 Example:
 if (iScore < 60)
{
 sGrade = “Fail”;
}
 elseif (iScore >= 100)
{
 sGrade = “Perfect”;
}
 else
{
 sGrade = “Passing”;
 };
Decisions: switch case
 Used to make large nested if structures
more readable
 Syntax:
switch(VarName)
{
case FirstCase:
 break;

case NextCase:
 break;

default:

}
Decisions: switch case
 Example:
switch(iScore)
{
case 60:
 sGrade = “Fail”;
 break;

case 100:
 sGrade = “Perfect”:
 break;

default:
 sGrade = “Passing”
}
Looping: for Loop
 Syntax:
for (start;condition;increment)
{
‘Code to execute each iteration of loop
}

 Example:
for (iCtr = 0;iCtr<10;iCtr++)
{
sStepNum = “Step Number: “ + Str$(iCtr);
}
Looping: do Loop
 Syntax:
 do
{
 ‘Code to execute each iteration of the loop
 }while (Condition);
 Example:
 iCtr = 0;
 do
{
 iCtr= iCtr + 1;
 sStepNum = “Step Number: “ & Str$(iCtr);

} while (iCtr < 10);


Looping: while Loop
 While loop has same syntax as do loop,
but Condition is at the top, instead of
the bottom
 In a do loop, the loop will always
execute at least once
 In a while loop, the loop will not execute
even once if the condition is not true
the first time through the loop
Functions
 Allfunctions in eScript are referred to
as functions whether or not they
return a value
 Simple types are passed by value
unless you place an ampersand in
front of the variable name (&)
 Objects and arrays are always
passed by reference
Functions
 Syntax:
function FuncName (Var1, Var2)
{
‘Code to execute inside function
‘Use return (Value); to return a value

}
Functions
 Example:
function GetName ()
{
var sName = “”;
sName = GetProfileAttr(“SPN_CA_NAME”);
return (sName);

}
Calling Functions
 Syntax:
Var= FuncName(Value)
FuncName (FuncName(Value))

 Example:
var sName = GetName();
 Example 2:
FindValue(GetName());
‘FindValue is some other function that
takes a string as a parameter
Arrays
 Declaring:
var ArrayName = new
Array(NumElements);
 Useful methods for arrays
getArrayLength(), length property: Returns
the number of elements in an array
reverse(), sort()
setArrayLength(num): dynamically resizes
the array
join() : creates a string from array
Some Important eScript
Methods
 new Date (in place of Now)
 The Clib Object
 String Manipulation in eScript
 File Handling in eScript
new Date
 Returns
Current Time and Date on
machine that the script is running on
Running Web Client or Wireless Web
Client, that is the Siebel Server that the
AOM is running on
Running Mobile Web Client or Dedicated
Web Client, that is the machine that
[Link] is running on- the client’s
machine
 Syntax: var MyDate = new Date;
The Clib Object
 Has many uses, including file
handling, string manipulation,
character typing
 Character Typing functions:
isalpha()
isalnum()
isdigit()
toascii()
Many others
String Manipulation
 More than one way, but the easiest
is:
 First, put the string into an array of
one character long strings (no char
data type)
Use [Link]()
 Next,use for loop to iterate through
array, and parse the string as you
would in C++
File Handling
 [Link]()
 File Pointers
 [Link]()
 [Link]()
 [Link]()
 [Link]()
Opening Files
 Syntax:
fpname = [Link](filename, “r”|”w”);
 Examples:
var fp;
var filename = “C:\[Link]”;
fp = [Link](filename, “r”);
[Link]() Method
 Sets the File pointer position to the
beginning of the file
 Should always be done on opening a
file
Reading From Files
 Use fgets()
 Syntax:
[Link](fpname);
 Example:
fp = [Link](filename, "r");
[Link](fp);
while (![Link](fp))
{
 sXML = sXML + [Link](fp);
}
[Link](fp);
[Link]() Method
 Takes a file pointer as argument
 Returns true if file pointer is at the
end of the file
[Link]() Method
 WritesData to an open file
 Syntax:
[Link](filepointername, Value);
 Example:
fp = [Link](filename, "w");
[Link](fp);
[Link](fp, “Write This To the file”);
[Link](fp);
[Link]() Method
 Always Make sure to close your files
after use!
 Syntax:
[Link](filepointername);
Siebel Specific Objects
 BusComp
 BusObject
 TheApplication
 PropertySet
 Service
 Object
 Parentheses!
Error Handling With eScript
 MUCH more robust than Siebel VB
 Uses try-catch-throw system similar
to C
 Remember that the Siebel system
itself is already set up to handle
many errors, so most don’t even
need to be handled by you
Error Handling Syntax
 try {}
 Place try block around code that might error
 catch(e) {}
 Catch block goes after. If code in try block errors,
will throw error e to catch block. Handle errors
here
 throw(e);
 Alternatively, just use error (for example, to write
a log file), then re-throw it for System to handle.
Place inside catch block
 finally {}
 Used to place code that should be executed even
if the catch block halts execution

You might also like