• No results found

A VBScript17

N/A
N/A
Protected

Academic year: 2021

Share "A VBScript17"

Copied!
25
0
0

Loading.... (view fulltext now)

Full text

(1)

VBScript

VBScript

Session 17

Session 17

(2)

?What we learn last session

(3)

Subjects for session 17

Subjects for session 17

Class object.

Class object.

Class statement.

Class statement.

Property Let.

Property Let.

Property Get.

Property Get.

Property Set.

Property Set.

Initialize event.

Initialize event.

Terminate event.

Terminate event.

Inline classes.

Inline classes.

(4)

Classes in VBScript

Classes in VBScript

Class Object

Class Object

The object created using the

The object created using the Class

Class statement.

statement.

Provides access to the events of the class.

Provides access to the events of the class.

You cannot explicitly declare a variable to be of 

You cannot explicitly declare a variable to be of 

type Class.

type Class.

In the VBScript context, the term "class object"

In the VBScript context, the term "class object"

refers to any object defined using the VBScript

refers to any object defined using the VBScript

Class

Class statement.

statement.

Dim

Dim XX Set

(5)

Classes in VBScript

Classes in VBScript

Class Statement

Class Statement

Declares the name of a class, as

Declares the name of a class, as

well as a definition of the v

well as a definition of the variables,

ariables,

properties, and methods that

properties, and methods that

comprise the class.

comprise the class.

Syntax

Syntax

Class

Class namename statements statements End Class End Class

(6)

Classes in VBScript

Classes in VBScript

Class Statement

Class Statement

Within aWithin a ClassClass block, members are declared as eitherblock, members are declared as either PrivatePrivate oror

Public

Public using the using the appropriate declaratioappropriate declaration statements.n statements.

Anything declared asAnything declared as PrivatePrivate is visible only within theis visible only within the ClassClass block.block.

Anything declared asAnything declared as PublicPublic is visible within theis visible within the ClassClass block, as wellblock, as well

as by code outside the

as by code outside the ClassClass block.block.

Anything not explicitly declared as eitherAnything not explicitly declared as either PrivatePrivate oror PublicPublic isis PublicPublic

by default. by default.

Procedures (eitherProcedures (either SubSub oror FunctionFunction) declared) declared PublicPublic within the classwithin the class

block become methods of the class. block become methods of the class.

PublicPublic variables serve as properties of the class, variables serve as properties of the class, as do propertiesas do properties

explicitly declared using

explicitly declared using PropertyProperty GetGet,, PropertyProperty LetLet, and, and PropertyProperty

Set

Set..

Default properties and methods for the class are Default properties and methods for the class are specified in theirspecified in their

declarations using the

(7)

Classes in VBScript

Classes in VBScript

Get Property Statement

Get Property Statement

Declares, in a

Declares, in a Class

Class block, the name,

block, the name,

arguments, and code that form the body

arguments, and code that form the body

of a

of a Property

Property procedure that gets

procedure that gets

(returns) the value of a property.

(returns) the value of a property.

Syntax

Syntax

[[PublicPublic [[DefaultDefault] |] | PrivatePrivate]] Property GetProperty Get namename [([(arglist arglist ))]] [[statementsstatements]]

[[

[[SetSet]] namename == expressionexpression]] [[Exit PropertyExit Property]]

(8)

Classes in VBScript

Classes in VBScript

Get Property Statement

Get Property Statement

If not explicitly specified using eitherIf not explicitly specified using either PublicPublic oror PrivatePrivate,,

Property

Property GetGet procedures are public by default, that is, theyprocedures are public by default, that is, they are visible to all other procedures in your

are visible to all other procedures in your script.script.

 The value of local variables in aThe value of local variables in a Property GetProperty Get procedure isprocedure is

not preserved between calls to the procedure. not preserved between calls to the procedure.

You can't define aYou can't define a Property GetProperty Get procedure inside any otherprocedure inside any other

procedure. procedure.

TheThe Exit PropertyExit Property statement causes an immediate exit fromstatement causes an immediate exit from

a

a PropertyProperty GetGet procedure.procedure.

PropertyProperty GetGet procedure is a separate procedure that procedure is a separate procedure that cancan

take arguments, perform a series of statements, and change take arguments, perform a series of statements, and change the value of its arguments.

(9)

Classes in VBScript

Classes in VBScript

Let Property Statement

Let Property Statement

Declares, in a

Declares, in a Class

Class block, the name,

block, the name,

arguments, and code that form the body

arguments, and code that form the body

of a

of a Property

Property procedure that assigns

procedure that assigns

(sets) the value of a property.

(sets) the value of a property.

Syntax

Syntax

[[PublicPublic [[DefaultDefault] |] | PrivatePrivate]] Property LetProperty Let namename (([[arglist arglist ,],] valuevalue)) [[statementsstatements]]

[[

[[SetSet]] namename == expressionexpression]] [[Exit PropertyExit Property]]

[[statementsstatements]] End Property End Property

(10)

Classes in VBScript

Classes in VBScript

Let Property Statement

Let Property Statement

If not explicitly specified using eitherIf not explicitly specified using either PublicPublic oror

Private

Private,, Property LetProperty Let procedures are public byprocedures are public by default, that is, they

default, that is, they are visible to all other proceduresare visible to all other procedures in your script.

in your script.

The value of local variables in aThe value of local variables in a Property LetProperty Let

procedure is not preserved between calls to the procedure is not preserved between calls to the procedure.

procedure.

You can't define aYou can't define a Property LetProperty Let procedure inside anyprocedure inside any

other procedure. other procedure.

 TheThe Exit PropertyExit Property statement causes an immediatestatement causes an immediate

exit from a

exit from a Property LetProperty Let procedure.procedure.

EveryEvery Property LetProperty Let statement must define at leaststatement must define at least

one argument for the procedure it defines. one argument for the procedure it defines.

(11)

Classes in VBScript

Classes in VBScript

Set Property Statement

Set Property Statement

Declares, in a

Declares, in a Class

Class block, the name,

block, the name,

arguments, and code that form the body

arguments, and code that form the body

of a

of a Property

Property procedure that sets a

procedure that sets a

reference to an object.

reference to an object.

Syntax

Syntax

[[PublicPublic [[DefaultDefault] |] | PrivatePrivate]] Property SetProperty Set namename (([[arglist arglist ,],] referencereference)) [[statementsstatements]]

[[

[[SetSet]] namename == expressionexpression]] [[Exit PropertyExit Property]]

[[statementsstatements]] End Property End Property

(12)

Classes in VBScript

Classes in VBScript

Set Property Statement

Set Property Statement

If not explicitly specified using eitherIf not explicitly specified using either PublicPublic oror

Private

Private,, PropertyProperty SetSet procedures are public byprocedures are public by default, that is, they

default, that is, they are visible to all other proceduresare visible to all other procedures in your script.

in your script.

The value of local variables in aThe value of local variables in a PropertyProperty SetSet

procedure is not preserved between calls to the procedure is not preserved between calls to the procedure.

procedure.

You can't define aYou can't define a PropertyProperty SetSet procedure inside anyprocedure inside any

other other

 TheThe ExitExit PropertyProperty statement causes an immediatestatement causes an immediate

exit from a

exit from a PropertyProperty SetSet procedure.procedure.

EveryEvery PropertyProperty SetSet statement must define at leaststatement must define at least

one argument for the procedure it defines. one argument for the procedure it defines.

(13)

Classes in VBScript

Classes in VBScript

Initialize Event

Initialize Event

Occurs when an instance of the

Occurs when an instance of the

associated class is created.

associated class is created.

Syntax

Syntax

Private Sub

Private Sub

Class_Initialize()

Class_Initialize()

statements

statements

End Sub

End Sub

Set

Set X =X = NewNew TestClassTestClass ' Create an instance of TestClass.' Create an instance of TestClass.

Set

(14)

Classes in VBScript

Classes in VBScript

Terminate Event

Terminate Event

Occurs when an instance of the

Occurs when an instance of the

associated class is terminated.

associated class is terminated.

Syntax

Syntax

Private Sub

Private Sub

Class_Terminate()

Class_Terminate()

statements

statements

End Sub

End Sub

Set

Set X =X = NewNew TestClassTestClass ' Create an instance of TestClass.' Create an instance of TestClass.

Set

(15)

Classes in VBScript

Classes in VBScript

Inline Classes

Inline Classes

Inline class is a class that you

Inline class is a class that you can

can

immediatelly use without registering

immediatelly use without registering

the class.

(16)

Classes in VBScript

Classes in VBScript

MyArray Class - Example

MyArray Class - Example

Inline class is a class that you

Inline class is a class that you can

can

immediatelly use without registering

immediatelly use without registering

the class.

the class.

VBScript\VBS\class.vbs

(17)

Creating a COM Class

Creating a COM Class

Step 1

Step 1

(18)

Creating a COM Class

Creating a COM Class

Step 2

Step 2

(19)

Creating a COM Class

Creating a COM Class

Step 3

Step 3

Remove the existing empty

Remove the existing empty

class

class

(20)

Creating a COM Class

Creating a COM Class

Step 4

Step 4

(21)

Creating a COM Class

Creating a COM Class

Step 5

Step 5

(22)

Creating a COM Class

Creating a COM Class

Step 6

Step 6

Add properties, methods, events and

Add properties, methods, events and

enums using the class builder.

enums using the class builder.

(23)

Creating a COM Class

Creating a COM Class

Step 7

Step 7

(24)

(25)

Make sure to visit us

Make sure to visit us

 

Tutorials

Tutorials

 

Articles

Articles

 

Proikects

Proikects

And much more

And much more

www.AdvancedQTP.com

References

Related documents

i'giEiEi gF5giiE EFg !5gg Eiicg$$$ ;,FtiF'F;Eaiisi. gg ge gg$$ig eg

But especially in relation to urban transportation, the whole principle of private phone ownership can still run counter to the very idea of ‘public’ transit. Why should

By adding some households who cannot access financial and capital markets (hand-to-mouth households) to the standard DSGE model, we broke Ricardian equivalence, and showed that

From an analysis of the line shape broadening, the electron density and gas temperature were deduced to be 5 10 15 cm 3 and 1100 K, respectively, for a discharge using a cathode

In one case we learned of a program whose government coun- terparts were active participants in the various software sprint and release reviews and acting as product owners, while

Conclusions: Although invasive lobular carcinomas comprise 12% of all female breast cancers, they are very rare in males due to lack of acini and lobules in the normal male

In particular, through an extensive formal analysis we have shown that the proposed protocol achieves the following properties: data anonymity, tag location

To fulfill the requirements of SOCI 4096 HONOURS THESIS I, the student must design and submit a completed research proposal, including the thesis problem statement, literature