Siebel Scripting 3

  • Uploaded by: api-3762678
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Siebel Scripting 3 as PDF for free.

More details

  • Words: 1,121
  • Pages: 34
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 ==,

!=, <, >, <=, >=

 Logical &&,

Operators

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  var

Variables can be initialized:

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

}

 elseif {

= “Fail”;

(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

 }while

to execute each iteration of the loop

(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  All

functions 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 Siebel.exe 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

 Next,

Clib.substring()

use for loop to iterate through array, and parse the string as you would in C++

File Handling  Clib.fopen()  File

Pointers  Clib.rewind()  Clib.fgets()  Clib.fprintf()  Clib.close()

Opening Files  Syntax: fpname

= Clib.fopen(filename, “r”|”w”);

 Examples: var

fp; var filename = “C:\MyFile.txt”; fp = Clib.fopen(filename, “r”);

Clib.rewind() 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: Clib.fgets(fpname);

 Example: fp

= Clib.fopen(filename, "r"); Clib.rewind(fp); while

(!Clib.feof(fp))

{  sXML

= sXML + Clib.fgets(fp);

}

Clib.fclose(fp);

Clib.feof() Method  Takes

a file pointer as argument  Returns true if file pointer is at the end of the file

Clib.fprintf() Method  Writes

Data to an open file  Syntax: Clib.fprintf(filepointername,

Value);

 Example: fp

= Clib.fopen(filename, "w"); Clib.rewind(fp); Clib.fprintf(fp, “Write This To the file”); Clib.fclose(fp);

Clib.fclose() Method  Always

Make sure to close your files after use!  Syntax: Clib.fclose(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

Related Documents

Siebel Scripting 3
November 2019 11
Siebel Scripting 2
November 2019 9
Siebel Scripting 1
November 2019 5
Siebel Scripting 4
November 2019 12
Siebel Ondemand 3
July 2020 10
Siebel Configuration
October 2019 25