Вы находитесь на странице: 1из 34

Siebel Scripting, Part Two

Siebel VB Syntax

Introduction

Data Types Dimensioning Variables Operators Decisions Looping Functions and Subroutines Arrays in Siebel VB Some Important VB Methods sing Siebel Ob!ects "rror #andling in Siebel VB

Comments in Siebel VB

se an apostrophe $ At the beginning o% a line to ma&e a single line comment "xample'

$This is a (omment

There are )O multi*line comments in Siebel VB

Data Types

)umbers' Integers+ Fractions Strings Dates,Times Variant Ob!ects


Ob!ect Type Siebel Ob!ects' Bus(omp+ -ropertySet+ others

Siebel VB is a strong typed language

Operators

Mathematical Operators

.+ *+ /+ ,+ 0+ Mod+ 1 2+ 34+ 3+ 4+ 32+ 42 And+ Or+ )ot 2

(onditional Operators

Logical Operators

Assignment

Dimensioning Variables

Syntax'

Dim Var)ame As DataType Dim iScore As Integer Dim bc(ontact As Bus(omp

"xamples'

(an Dim more than one 5ariable in one line'


Dim sLast)ame+ sFirst)ame As String Only last 5ariable gets speci%ied data type' others are type Variant

(annot initiali6e

Decisions: If

Syntax'

I% (ondition Then

$(ode to be executed i% (ondition is True

"nd I% I% iScore 3 78 Then

"xample'

s9rade 2 :Fail;

"nd I%

Simple Decision Ma&ing (onstruct

Decisions: lse

Syntax'

I% (ondition Then

$(ode to "xecute i% (ondition is True $(ode to "xecute i% (ondition is False

"lse

"nd I% I% iScore 3 78 Then

"xample'

s9rade 2 :Fail; s9rade 2 :-assing;

"lse

"nd I%

Decisions: lse If

"xample'

I% iScore 3 78 Then

s9rade 2 :Fail; s9rade 2 :-er%ect; s9rade 2 :-assing;

"lse I% iScore 42 <88 Then

"lse

"nd I%

Decisions: Select Case

sed to ma&e large nested i% structures more readable Syntax'

Select Var)ame
(ase First(ase (ase )ext(ase (ase "lse

"nd Select

Decisions: Select Case


"xample' Select (ase iScore

(ase Is 3 78

s9rade 2 :Fail; s9rade 2 :-er%ect; s9rade 2 :-assing;

(ase Is 42 <88

(ase "lse

"nd Select

!ooping: "or !oop

Syntax'

For i(ounter 2 iStart to iFinish Step iAmount

$(ode to execute each iteration o% loop

)ext i(ounter For i(tr 2 < to <8 Step =

"xample'

sStep)um 2 :Step )umber' : > Str?@i(trA

)ext i(tr

!ooping: Do !oop

Syntax'

Do

$(ode to execute each iteration o% the loop

Loop

ntil @BhileA (ondition

"xample'

i(tr 2 8 Do
i(tr 2 i(tr . < sStep)um 2 :Step )umber' : > Str?@i(trA

Loop

ntil i(tr 2 <8

!ooping: #$ile #end

Syntax'

Bhile (ondition

$(ode to execute each iteration o% the loop

Bend Bhile sSC)um 34 bcSCD9etFieldValue@:SC )umber;A

"xample'

bcSCD)extCecord

Bend

"unction %nd Subroutines


A Function returns a 5alue A Subroutine does not "ither can ha5e data passed into them as parameters

se ByVal or ByCe% By de%ault+ Ob!ects are passed by re%erence Simple data types are passed by 5alue

Subroutines

Syntax'

Sub Sub)ame @Var< as Type+ Var= as TypeA

$(ode to execute inside %unction

"nd Sub Sub Set)ame @s)ame as StringA

"xample'

TheApplicationDSet-ro%ileAttr :S-)E(AE)AM";+ s)ame

"nd Sub

Calling Subroutines

Syntax'

(all Sub)ame Value<+ Value= $(all FeyGord is optional (all Set)ame :9eorge Bush; Set)ame :9eorge Bush;

"xamples'

"unctions

Syntax'

Function Func)ame @Var< as TypeA As Type


$(ode to execute inside %unction $ se Func)ame 2 CeturnVal to return a 5alue

"nd Function

"unctions

"xample'

Function 9et)ame @A As String


Dim s)ame As String s)ame 2 9et-ro%ileAttr@:S-)E(AE)AM";A 9et)ame 2 s)ame

"nd Function

Calling "unctions

Syntax'

Var 2 Func)ame@ValueA Sub)ame @Func)ame@ValueAA Dim s)ame as String s)ame 2 9et)ame FindValue@9et)ameA $FindValue is some other sub that ta&es a string as a parameter

"xample'

"xample ='

%rrays

Dimensioning'

Dim Array)ame @)um"lementsA As Type

Max 78 elements Arrays can be multi*dimensional se%ul methods %or arrays


CeDim' sed %or dynamic arrays LBound+ Bound' Ceturn loGer or upper bound o% array "rase' Ceinitiali6e array

Some Important VB &et$ods


)oG Asc Val Str? Le%t?+ Mid?+ Cight? File #andling in Siebel VB

'ow

Ceturns (urrent Time and Date on machine that the script is running on

Cunning Beb (lient or Bireless Beb (lient+ that is the Siebel Ser5er that the AOM is running on Cunning Mobile Beb (lient or Dedicated Beb (lient+ that is the machine that SiebelDexe is running on* the clientHs machine

%sc

Ta&es a string as argument Ceturns the AS(II 5alue o% the %irst char in the string se%ul %or determining Ghether input is 5alid I you can chec& to see i% it is an alphabetic character+ a numeric character+ or anything else

Val and Str(

Val ta&es a String argument that is made up o% numbers @iDeD :<8;A and returns its numeric 5alue Str? ta&es a numeric argument and con5erts it to a string

String &anipulation

Le%t? Ta&es a string and an integer argument Ceturns a substring o% the string passed in Cight? is same+ but returns the substring %rom the right Mid? Ta&es a string and = integersD It returns a substring o% the length o% the second integer+ starting at the character indicated by the %irst

"ile )andling

Open Statement Line Input Statement "o% Function Brite Statement (lose Statement

Opening "iles

Syntax'

Open :-ath0Filename; For Input @OutputA As J Open :('0MyFileDtxt; For Input As J< Open :D0log0"rrorDlog; For Output as JK

"xamples'

*eading "rom "iles

"asiest to se Line Input Statement

See Also' Input Stmt+ Input Function+ 9et Stmt Line Input JFile)um+ Var)ame Open :(0MyFileDtxt; For Input As J<

Syntax'

"xample'

Do Bhile )ot "o%@<A


Line Input J<+ sTemp JsLML 2 sLML > sTemp

Loop

(lose J<

of "unction

Ta&es the number o% an open %ile as argument Ceturns true i% %ile pointer is at the end o% the %ile

#rite Statement

Brites Data to an open %ile Syntax'

Brite JFile)um+ Value Open :('0MyFileDtxt; For Output As J=

"xample'

For i(tr 2 8 to

Bound@MyArrayA

Brite J=+ MyArray@i(trA

)ext i(tr

(lose J=

Close Statement

AlGays Ma&e sure to close your %iles a%ter useM Syntax'

(lose JFile)um

Siebel Specific Ob+ects


Bus(omp BusOb!ect TheApplication -ropertySet Ser5ice Ob!ect

rror )andling in Siebel VB

Syntax'

On "rror 9oTo Label' $other code Label'

$#andle error here

"xample'

On "rror 9oTo "rr#andler' $other code "rr#andler'

$#andle error here

Вам также может понравиться